add Create and Reformat with GetSnesPixelFormat
This commit is contained in:
@@ -218,6 +218,32 @@ void Bitmap::Create(int width, int height, int depth, const Bytes &data) {
|
|||||||
active_ = true;
|
active_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bitmap::Create(int width, int height, int depth, int format,
|
||||||
|
const Bytes &data) {
|
||||||
|
active_ = true;
|
||||||
|
width_ = width;
|
||||||
|
height_ = height;
|
||||||
|
depth_ = depth;
|
||||||
|
data_ = data;
|
||||||
|
data_size_ = data.size();
|
||||||
|
pixel_data_ = data_.data();
|
||||||
|
surface_ = std::unique_ptr<SDL_Surface, SDL_Surface_Deleter>(
|
||||||
|
SDL_CreateRGBSurfaceWithFormat(0, width_, height_, depth_,
|
||||||
|
GetSnesPixelFormat(format)),
|
||||||
|
SDL_Surface_Deleter());
|
||||||
|
surface_->pixels = pixel_data_;
|
||||||
|
active_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bitmap::Reformat(int format) {
|
||||||
|
surface_ = std::unique_ptr<SDL_Surface, SDL_Surface_Deleter>(
|
||||||
|
SDL_CreateRGBSurfaceWithFormat(0, width_, height_, depth_,
|
||||||
|
GetSnesPixelFormat(format)),
|
||||||
|
SDL_Surface_Deleter());
|
||||||
|
surface_->pixels = pixel_data_;
|
||||||
|
active_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Bitmap::CreateTexture(SDL_Renderer *renderer) {
|
void Bitmap::CreateTexture(SDL_Renderer *renderer) {
|
||||||
if (width_ <= 0 || height_ <= 0) {
|
if (width_ <= 0 || height_ <= 0) {
|
||||||
SDL_Log("Invalid texture dimensions: width=%d, height=%d\n", width_,
|
SDL_Log("Invalid texture dimensions: width=%d, height=%d\n", width_,
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ class Bitmap {
|
|||||||
* @brief Creates a bitmap object with the provided graphical data.
|
* @brief Creates a bitmap object with the provided graphical data.
|
||||||
*/
|
*/
|
||||||
void Create(int width, int height, int depth, const Bytes &data);
|
void Create(int width, int height, int depth, const Bytes &data);
|
||||||
|
void Create(int width, int height, int depth, int format, const Bytes &data);
|
||||||
|
|
||||||
|
void Reformat(int format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates the underlying SDL_Texture to be displayed.
|
* @brief Creates the underlying SDL_Texture to be displayed.
|
||||||
@@ -218,6 +221,7 @@ class Bitmap {
|
|||||||
return surface_->format->palette;
|
return surface_->format->palette;
|
||||||
}
|
}
|
||||||
auto palette() const { return palette_; }
|
auto palette() const { return palette_; }
|
||||||
|
auto mutable_palette() { return &palette_; }
|
||||||
auto palette_size() const { return palette_.size(); }
|
auto palette_size() const { return palette_.size(); }
|
||||||
|
|
||||||
int width() const { return width_; }
|
int width() const { return width_; }
|
||||||
|
|||||||
Reference in New Issue
Block a user