1#ifndef YAZE_APP_EDITOR_SPRITE_SPRITE_EDITOR_INTERNAL_H_
2#define YAZE_APP_EDITOR_SPRITE_SPRITE_EDITOR_INTERNAL_H_
20 std::vector<int> tiles;
21 for (
const auto& tile : frame.
Tiles) {
22 tiles.push_back(tile.id);
24 tiles.push_back(tile.id + 1);
25 tiles.push_back(tile.id + 16);
26 tiles.push_back(tile.id + 17);
29 std::sort(tiles.begin(), tiles.end());
30 tiles.erase(std::unique(tiles.begin(), tiles.end()), tiles.end());
40 for (
size_t i = 0; i < global.
size() && i < 8; i++) {
43 while (palettes.
size() < 8) {
44 if (palettes.
size() < 4 && aux1.
size() > 0) {
46 }
else if (palettes.
size() < 6 && aux2.
size() > 0) {
48 }
else if (aux3.
size() > 0) {
59 const std::array<SDL_Color, 256>& cgram) {
61 for (
int row = 8; row < 16; ++row) {
63 for (
int i = 0; i < 16; ++i) {
64 const SDL_Color& c = cgram[row * 16 + i];
86 const std::vector<uint8_t>& gfx_buffer) {
91 const std::vector<uint8_t> blank(
92 gfx_buffer.empty() ? 0 :
static_cast<size_t>(width) * height, 0);
93 bmp.
Create(width, height, depth, blank);
103 if (bmp.
surface() !=
nullptr) {
Represents a bitmap image optimized for SNES ROM hacking.
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.
void UpdateSurfacePixels()
Update SDL surface with current pixel data from data_ vector Call this after modifying pixel data via...
void Reformat(int format)
Reformat the bitmap to use a different pixel format.
BitmapMetadata & metadata()
void CreateTexture()
Creates the underlying SDL_Texture to be displayed.
SDL_Surface * surface() const
void UpdateTexture()
Updates the underlying SDL_Texture when it already exists.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
void AddColor(const SnesColor &color)
void EnsureSpritePreviewBitmapReady(gfx::Bitmap &bmp, int width, int height, int depth, const std::vector< uint8_t > &gfx_buffer)
void PublishSpritePreviewPixels(gfx::Bitmap &bmp)
std::vector< int > FrameTiles8x8(const zsprite::Frame &frame)
gfx::PaletteGroup SpritePalettesFromCgram(const std::array< SDL_Color, 256 > &cgram)
gfx::PaletteGroup DefaultSpritePreviewPalettes(const gfx::PaletteGroup &global, const gfx::PaletteGroup &aux1, const gfx::PaletteGroup &aux2, const gfx::PaletteGroup &aux3)
std::vector< OamTile > Tiles
Represents a group of palettes.
auto palette(int i) const
void AddPalette(SnesPalette pal)