diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index df35a152..c65b168d 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -40,10 +40,12 @@ void Bitmap::Create(int width, int height, int depth, uchar *data) { surface_->pixels = pixel_data_; } +// Reserve data and draw to surface via pointer void Bitmap::Create(int width, int height, int depth, int size) { width_ = width; height_ = height; depth_ = depth; + data_size_ = size; surface_ = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, SDL_PIXELFORMAT_INDEX8); // Default grayscale palette @@ -57,6 +59,17 @@ void Bitmap::Create(int width, int height, int depth, int size) { surface_->pixels = pixel_data_; } +void Bitmap::Create(int width, int height, int depth, uchar *data, int size, const SNESPalette &palette) { + width_ = width; + height_ = height; + depth_ = depth; + pixel_data_ = data; + surface_ = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, + SDL_PIXELFORMAT_INDEX8); + surface_->format->palette = palette.GetSDL_Palette(); + surface_->pixels = pixel_data_; +} + void Bitmap::CreateTexture(std::shared_ptr renderer) { texture_ = SDL_CreateTextureFromSurface(renderer.get(), surface_); } diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 1e9ecaee..f3f3ea39 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -19,6 +19,7 @@ class Bitmap { void Create(int width, int height, int depth, uchar *data); void Create(int width, int height, int depth, int data_size); + void Create(int width, int height, int depth, uchar *data, int size, const SNESPalette &palette); void CreateTexture(std::shared_ptr renderer); void ApplyPalette(const SNESPalette &palette);