AGS Cleanup surface creation

The main changce is that create_bitmap() now uses the current
get_color_depth(), as it is supposed to (according to the Allegro
documentation).

Also it remove cases where the surface could be created without the transparent color.
This commit is contained in:
Thierry Crozat 2021-03-10 00:19:17 +00:00
parent 19bf58f8c6
commit a2ed9906e4
3 changed files with 3 additions and 10 deletions

View File

@ -288,7 +288,7 @@ public:
/*-------------------------------------------------------------------*/
BITMAP *create_bitmap(int width, int height) {
return new Surface(width, height);
return create_bitmap_ex(get_color_depth(), width, height);
}
BITMAP *create_bitmap_ex(int color_depth, int width, int height) {

View File

@ -62,7 +62,7 @@ public:
}
uint getTransparentColor() const {
return format.RGBToColor(255, 0, 255);
return _owner->getTransparentColor();
}
int getpixel(int x, int y) const;
@ -260,12 +260,6 @@ private:
*/
class Surface : public Graphics::ManagedSurface, public BITMAP {
public:
Surface() : Graphics::ManagedSurface(), BITMAP(this) {
}
Surface(const Graphics::ManagedSurface &surf) : Graphics::ManagedSurface(surf), BITMAP(this) {
}
Surface(int width, int height) : Graphics::ManagedSurface(width, height), BITMAP(this) {
}
Surface(int width, int height, const Graphics::PixelFormat &pixelFormat) :
Graphics::ManagedSurface(width, height, pixelFormat), BITMAP(this) {
// Allegro uses 255, 0, 255 RGB as the transparent color

View File

@ -43,8 +43,7 @@ BITMAP *decodeImage(const char *filename, color *pal) {
const Graphics::Surface *src = decoder.getSurface();
// Copy the decoded surface
Surface *dest = new Surface();
dest->create(src->w, src->h, src->format);
Surface *dest = new Surface(src->w, src->h, src->format);
dest->blitFrom(*src);
// Copy the palette