1#ifndef YAZE_APP_GFX_BITMAP_H
2#define YAZE_APP_GFX_BITMAP_H
9#include "absl/status/status.h"
24 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1);
27 SDL_PIXELTYPE_INDEX8, 0,
31 SDL_PIXELTYPE_INDEX8, 0,
35 SDL_PIXELTYPE_INDEX8, 0,
49bool ConvertSurfaceToPng(SDL_Surface *surface, std::vector<uint8_t> &buffer);
54void ConvertPngToSurface(
const std::vector<uint8_t> &png_data,
55 SDL_Surface **outSurface);
84 std::cerr <<
"Error applying palette in bitmap constructor." << std::endl;
89 std::vector<uint8_t> GetPngData();
101 const std::vector<uint8_t> &
data);
103 const std::vector<uint8_t> &
data);
125 size_t index,
int length = 7);
130 void Get8x8Tile(
int tile_index,
int x,
int y, std::vector<uint8_t> &tile_data,
131 int &tile_data_offset);
133 void Get16x16Tile(
int tile_x,
int tile_y, std::vector<uint8_t> &tile_data,
134 int &tile_data_offset);
144 void WriteColor(
int position,
const ImVec4 &color);
void WriteToPixel(int position, uint8_t value)
void UpdateTexture(SDL_Renderer *renderer)
Updates the underlying SDL_Texture when it already exists.
Bitmap(int width, int height, int depth, const std::vector< uint8_t > &data, const SnesPalette &palette)
void Reformat(int format)
absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette, size_t index, int length=7)
absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette, int palette_id)
void SaveSurfaceToFile(std::string_view filename)
void Get8x8Tile(int tile_index, int x, int y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
void Initialize(int width, int height, int depth, std::span< uint8_t > &data)
void set_modified(bool modified)
void set_active(bool active)
void WriteColor(int position, const ImVec4 &color)
void set_data(const std::vector< uint8_t > &data)
std::shared_ptr< SDL_Texture > texture_
std::vector< uint8_t > data_
std::shared_ptr< SDL_Surface > surface_
void CreateTexture(SDL_Renderer *renderer)
Creates the underlying SDL_Texture to be displayed.
Bitmap(int width, int height, int depth, const std::vector< uint8_t > &data)
absl::Status ApplyPalette(const SnesPalette &palette)
Copy color data from the SnesPalette into the SDL_Palette.
void Create(int width, int height, int depth, int data_size)
void Get16x16Tile(int tile_x, int tile_y, std::vector< uint8_t > &tile_data, int &tile_data_offset)
gfx::SnesPalette palette_
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
constexpr Uint32 SNES_PIXELFORMAT_2BPP
std::unordered_map< int, gfx::Bitmap > BitmapTable
Main namespace for the application.