Add Bitmap::Create overload
Makes use of sheet buffer, sheet buffer size, and custom palette parameters.
This commit is contained in:
@@ -40,10 +40,12 @@ void Bitmap::Create(int width, int height, int depth, uchar *data) {
|
|||||||
surface_->pixels = pixel_data_;
|
surface_->pixels = pixel_data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reserve data and draw to surface via pointer
|
||||||
void Bitmap::Create(int width, int height, int depth, int size) {
|
void Bitmap::Create(int width, int height, int depth, int size) {
|
||||||
width_ = width;
|
width_ = width;
|
||||||
height_ = height;
|
height_ = height;
|
||||||
depth_ = depth;
|
depth_ = depth;
|
||||||
|
data_size_ = size;
|
||||||
surface_ = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth,
|
surface_ = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth,
|
||||||
SDL_PIXELFORMAT_INDEX8);
|
SDL_PIXELFORMAT_INDEX8);
|
||||||
// Default grayscale palette
|
// Default grayscale palette
|
||||||
@@ -57,6 +59,17 @@ void Bitmap::Create(int width, int height, int depth, int size) {
|
|||||||
surface_->pixels = pixel_data_;
|
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<SDL_Renderer> renderer) {
|
void Bitmap::CreateTexture(std::shared_ptr<SDL_Renderer> renderer) {
|
||||||
texture_ = SDL_CreateTextureFromSurface(renderer.get(), surface_);
|
texture_ = SDL_CreateTextureFromSurface(renderer.get(), surface_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class Bitmap {
|
|||||||
|
|
||||||
void Create(int width, int height, int depth, uchar *data);
|
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, int data_size);
|
||||||
|
void Create(int width, int height, int depth, uchar *data, int size, const SNESPalette &palette);
|
||||||
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
||||||
|
|
||||||
void ApplyPalette(const SNESPalette &palette);
|
void ApplyPalette(const SNESPalette &palette);
|
||||||
|
|||||||
Reference in New Issue
Block a user