1#ifndef YAZE_APP_GFX_BITMAP_H
2#define YAZE_APP_GFX_BITMAP_H
9#include "absl/status/status.h"
25 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1);
28 SDL_PIXELTYPE_INDEX8, 0,
32 SDL_PIXELTYPE_INDEX8, 0,
36 SDL_PIXELTYPE_INDEX8, 0,
50bool ConvertSurfaceToPNG(SDL_Surface *surface, std::vector<uint8_t> &buffer);
55void ConvertPngToSurface(
const std::vector<uint8_t> &png_data,
56 SDL_Surface **outSurface);
85 std::cerr <<
"Error applying palette in bitmap constructor." << std::endl;
90 std::vector<uint8_t> GetPngData();
99 const std::vector<uint8_t> &
data);
101 const std::vector<uint8_t> &
data);
123 size_t index,
int length = 7);
128 void Get8x8Tile(
int tile_index,
int x,
int y, std::vector<uint8_t> &tile_data,
129 int &tile_data_offset);
131 void Get16x16Tile(
int tile_x,
int tile_y, std::vector<uint8_t> &tile_data,
132 int &tile_data_offset);
151 void WriteColor(
int position,
const ImVec4 &color);
164 throw std::runtime_error(
"Surface is null.");
Represents a bitmap image.
void Reformat(int format)
auto mutable_converted_surface()
std::shared_ptr< SDL_Surface > surface_
absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette, size_t index, int length=7)
auto palette_size() const
void set_active(bool active)
void Get8x8Tile(int tile_index, int x, int y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
Bitmap(int width, int height, int depth, const std::vector< uint8_t > &data)
std::vector< uint8_t > png_data_
void SaveSurfaceToFile(std::string_view filename)
absl::Status ApplyPalette(const SnesPalette &palette)
Copy color data from the SnesPalette into the SDL_Palette.
std::vector< uint8_t > data_
auto mutable_pixel_data()
void Create(int width, int height, int depth, const std::vector< uint8_t > &data)
Creates a bitmap object with the provided graphical data.
void UpdateTexture(SDL_Renderer *renderer)
Updates the underlying SDL_Texture when it already exists.
void set_data(const std::vector< uint8_t > &data)
Bitmap(int width, int height, int depth, const std::vector< uint8_t > &data, const SnesPalette &palette)
void WriteToPixel(int position, uchar value)
auto converted_surface() const
absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette, int palette_id)
void CreateTexture(SDL_Renderer *renderer)
Creates the underlying SDL_Texture to be displayed.
gfx::SnesPalette palette_
void WriteWordToPixel(int position, uint16_t value)
std::shared_ptr< SDL_Surface > converted_surface_
void WriteColor(int position, const ImVec4 &color)
void Get16x16Tile(int tile_x, int tile_y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
std::shared_ptr< SDL_Texture > texture_
void set_modified(bool modified)
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
constexpr Uint32 SNES_PIXELFORMAT_4BPP
constexpr Uint32 SNES_PIXELFORMAT_2BPP
std::unordered_map< int, gfx::Bitmap > BitmapTable
constexpr Uint32 SNES_PIXELFORMAT_8BPP
constexpr Uint32 SNES_PIXELFORMAT_INDEXED