1#ifndef YAZE_APP_GFX_BITMAP_H
2#define YAZE_APP_GFX_BITMAP_H
22 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1);
25 SDL_PIXELTYPE_INDEX8, 0,
29 SDL_PIXELTYPE_INDEX8, 0,
42bool ConvertSurfaceToPng(SDL_Surface *surface, std::vector<uint8_t> &buffer);
47void ConvertPngToSurface(
const std::vector<uint8_t> &png_data,
48 SDL_Surface **outSurface);
83 const std::vector<uint8_t> &
data);
89 const std::vector<uint8_t> &
data);
135 void WriteColor(
int position,
const ImVec4 &color);
140 void Get8x8Tile(
int tile_index,
int x,
int y, std::vector<uint8_t> &tile_data,
141 int &tile_data_offset);
146 void Get16x16Tile(
int tile_x,
int tile_y, std::vector<uint8_t> &tile_data,
147 int &tile_data_offset);
168 std::vector<uint8_t> GetPngData();
const uint8_t * data() const
const SnesPalette & palette() const
void WriteToPixel(int position, uint8_t value)
Write a value to a pixel at the given position.
SDL_Texture * texture() const
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.
void UpdateTexture(SDL_Renderer *renderer)
Updates the underlying SDL_Texture when it already exists.
const std::vector< uint8_t > & vector() const
void Reformat(int format)
Reformat the bitmap to use a different pixel format.
void Get8x8Tile(int tile_index, int x, int y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
Extract an 8x8 tile from the bitmap.
SnesPalette * mutable_palette()
void set_modified(bool modified)
void set_active(bool active)
void WriteColor(int position, const ImVec4 &color)
Write a color to a pixel at the given position.
void set_data(const std::vector< uint8_t > &data)
void SetPalette(const SnesPalette &palette)
Set the palette for the bitmap.
std::vector< uint8_t > data_
void CreateTexture(SDL_Renderer *renderer)
Creates the underlying SDL_Texture to be displayed.
void SetPaletteWithTransparent(const SnesPalette &palette, size_t index, int length=7)
Set the palette with a transparent color.
std::vector< uint8_t > & mutable_data()
SDL_Surface * surface() const
void Get16x16Tile(int tile_x, int tile_y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
Extract a 16x16 tile from the bitmap.
gfx::SnesPalette palette_
void UpdateTextureData()
Updates the texture data from the surface.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Contains classes for handling graphical data.
constexpr Uint32 SNES_PIXELFORMAT_8BPP
constexpr Uint32 SNES_PIXELFORMAT_INDEXED
constexpr Uint32 SNES_PIXELFORMAT_4BPP
Uint32 GetSnesPixelFormat(int format)
Get the SDL pixel format for a given bitmap format.
std::unordered_map< int, gfx::Bitmap > BitmapTable
Main namespace for the application.