Represents a bitmap image. More...
#include <bitmap.h>
Public Member Functions | |
Bitmap ()=default | |
Bitmap (int width, int height, int depth, const std::vector< uint8_t > &data) | |
Create a bitmap with the given dimensions and data. | |
Bitmap (int width, int height, int depth, const std::vector< uint8_t > &data, const SnesPalette &palette) | |
Create a bitmap with the given dimensions, data, and palette. | |
void | Create (int width, int height, int depth, std::span< uint8_t > data) |
Create a bitmap with the given dimensions and data. | |
void | Create (int width, int height, int depth, const std::vector< uint8_t > &data) |
Create a bitmap with the given dimensions and data. | |
void | Create (int width, int height, int depth, int format, const std::vector< uint8_t > &data) |
Create a bitmap with the given dimensions, format, and data. | |
void | Reformat (int format) |
Reformat the bitmap to use a different pixel format. | |
void | CreateTexture (SDL_Renderer *renderer) |
Creates the underlying SDL_Texture to be displayed. | |
void | UpdateTexture (SDL_Renderer *renderer) |
Updates the underlying SDL_Texture when it already exists. | |
void | UpdateTextureData () |
Updates the texture data from the surface. | |
void | SetPalette (const SnesPalette &palette) |
Set the palette for the bitmap. | |
void | SetPaletteWithTransparent (const SnesPalette &palette, size_t index, int length=7) |
Set the palette with a transparent color. | |
void | SetPalette (const std::vector< SDL_Color > &palette) |
Set the palette using SDL colors. | |
void | WriteToPixel (int position, uint8_t value) |
Write a value to a pixel at the given position. | |
void | WriteColor (int position, const ImVec4 &color) |
Write a color to a pixel at the given position. | |
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. | |
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. | |
const SnesPalette & | palette () const |
SnesPalette * | mutable_palette () |
int | width () const |
int | height () const |
int | depth () const |
auto | size () const |
const uint8_t * | data () const |
std::vector< uint8_t > & | mutable_data () |
SDL_Surface * | surface () const |
SDL_Texture * | texture () const |
const std::vector< uint8_t > & | vector () const |
uint8_t | at (int i) const |
bool | modified () const |
bool | is_active () const |
void | set_active (bool active) |
void | set_data (const std::vector< uint8_t > &data) |
void | set_modified (bool modified) |
Private Attributes | |
int | width_ = 0 |
int | height_ = 0 |
int | depth_ = 0 |
bool | active_ = false |
bool | modified_ = false |
void * | texture_pixels = nullptr |
uint8_t * | pixel_data_ = nullptr |
gfx::SnesPalette | palette_ |
std::vector< uint8_t > | data_ |
SDL_Surface * | surface_ = nullptr |
SDL_Texture * | texture_ = nullptr |
Represents a bitmap image.
The Bitmap
class provides functionality to create, manipulate, and display bitmap images. It supports various operations such as creating a bitmap object, creating and updating textures, applying palettes, and accessing pixel data.
yaze::gfx::Bitmap::Bitmap | ( | int | width, |
int | height, | ||
int | depth, | ||
const std::vector< uint8_t > & | data ) |
yaze::gfx::Bitmap::Bitmap | ( | int | width, |
int | height, | ||
int | depth, | ||
const std::vector< uint8_t > & | data, | ||
const SnesPalette & | palette ) |
void yaze::gfx::Bitmap::Create | ( | int | width, |
int | height, | ||
int | depth, | ||
std::span< uint8_t > | data ) |
Create a bitmap with the given dimensions and data.
Definition at line 218 of file bitmap.cc.
References Create(), data(), data_, depth(), height(), and width().
Referenced by Bitmap(), Bitmap(), Create(), Create(), yaze::core::Renderer::CreateAndRenderBitmap(), yaze::zelda3::LoadDungeonMapTile16(), and yaze::LoadFontGraphics().
void yaze::gfx::Bitmap::Create | ( | int | width, |
int | height, | ||
int | depth, | ||
const std::vector< uint8_t > & | data ) |
void yaze::gfx::Bitmap::Create | ( | int | width, |
int | height, | ||
int | depth, | ||
int | format, | ||
const std::vector< uint8_t > & | data ) |
Create a bitmap with the given dimensions, format, and data.
Definition at line 228 of file bitmap.cc.
References active_, yaze::gfx::Arena::AllocateSurface(), data(), data_, depth(), depth_, yaze::gfx::Arena::Get(), yaze::gfx::GetSnesPixelFormat(), height(), height_, pixel_data_, surface_, width(), and width_.
void yaze::gfx::Bitmap::Reformat | ( | int | format | ) |
Reformat the bitmap to use a different pixel format.
Definition at line 258 of file bitmap.cc.
References active_, yaze::gfx::Arena::AllocateSurface(), depth_, yaze::gfx::Arena::Get(), yaze::gfx::GetSnesPixelFormat(), height_, palette_, pixel_data_, SetPalette(), surface_, and width_.
void yaze::gfx::Bitmap::CreateTexture | ( | SDL_Renderer * | renderer | ) |
Creates the underlying SDL_Texture to be displayed.
Definition at line 275 of file bitmap.cc.
References yaze::gfx::Arena::AllocateTexture(), yaze::gfx::Arena::Get(), height_, texture_, UpdateTextureData(), and width_.
Referenced by yaze::core::Renderer::RenderBitmap(), and UpdateTexture().
void yaze::gfx::Bitmap::UpdateTexture | ( | SDL_Renderer * | renderer | ) |
Updates the underlying SDL_Texture when it already exists.
Definition at line 266 of file bitmap.cc.
References CreateTexture(), data_, yaze::gfx::Arena::Get(), surface_, texture_, and yaze::gfx::Arena::UpdateTexture().
Referenced by yaze::core::Renderer::UpdateBitmap().
void yaze::gfx::Bitmap::UpdateTextureData | ( | ) |
Updates the texture data from the surface.
Definition at line 298 of file bitmap.cc.
References yaze::gfx::Arena::Get(), modified_, surface_, texture_, and yaze::gfx::Arena::UpdateTexture().
Referenced by CreateTexture().
void yaze::gfx::Bitmap::SetPalette | ( | const SnesPalette & | palette | ) |
Set the palette for the bitmap.
Definition at line 307 of file bitmap.cc.
References palette(), palette_, and surface_.
Referenced by Bitmap(), yaze::core::Renderer::CreateAndRenderBitmap(), yaze::gfx::CreateTilemap(), yaze::zelda3::LoadDungeonMapTile16(), and Reformat().
void yaze::gfx::Bitmap::SetPaletteWithTransparent | ( | const SnesPalette & | palette, |
size_t | index, | ||
int | length = 7 ) |
void yaze::gfx::Bitmap::SetPalette | ( | const std::vector< SDL_Color > & | palette | ) |
void yaze::gfx::Bitmap::WriteToPixel | ( | int | position, |
uint8_t | value ) |
Write a value to a pixel at the given position.
Definition at line 383 of file bitmap.cc.
References data_, modified_, and pixel_data_.
Referenced by yaze::gfx::anonymous_namespace{tilemap.cc}::ComposeAndPlaceTilePart(), and yaze::editor::OverworldEditor::RenderUpdatedMapBitmap().
void yaze::gfx::Bitmap::WriteColor | ( | int | position, |
const ImVec4 & | color ) |
Write a color to a pixel at the given position.
Definition at line 392 of file bitmap.cc.
References yaze::gfx::ConvertRgbToSnes(), data_, modified_, pixel_data_, and surface_.
Referenced by yaze::gui::Canvas::DrawTileOnBitmap().
void yaze::gfx::Bitmap::Get8x8Tile | ( | int | tile_index, |
int | x, | ||
int | y, | ||
std::vector< uint8_t > & | tile_data, | ||
int & | tile_data_offset ) |
void yaze::gfx::Bitmap::Get16x16Tile | ( | int | tile_x, |
int | tile_y, | ||
std::vector< uint8_t > & | tile_data, | ||
int & | tile_data_offset ) |
Extract a 16x16 tile from the bitmap.
Definition at line 427 of file bitmap.cc.
Referenced by yaze::gfx::RenderTile16(), and yaze::gfx::UpdateTile16().
|
inline |
Definition at line 149 of file bitmap.h.
References palette_.
Referenced by Bitmap(), Bitmap(), yaze::gui::Canvas::DrawTilemapPainter(), yaze::editor::Tile16Editor::Initialize(), yaze::gfx::RenderTile(), yaze::gfx::RenderTile16(), SetPalette(), SetPalette(), and SetPaletteWithTransparent().
|
inline |
|
inline |
Definition at line 151 of file bitmap.h.
References width_.
Referenced by Bitmap(), Bitmap(), Bitmap(), yaze::gfx::anonymous_namespace{tilemap.cc}::ComposeAndPlaceTilePart(), yaze::gfx::ComposeTile16(), Create(), Create(), Create(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmapGroup(), yaze::gui::DrawBitmapViewer(), yaze::gui::Canvas::DrawTileOnBitmap(), yaze::gfx::GetTilemapData(), yaze::editor::Tile16Editor::Initialize(), yaze::gfx::ModifyTile16(), yaze::gfx::RenderTile16(), and yaze::gfx::UpdateTile16().
|
inline |
Definition at line 152 of file bitmap.h.
References height_.
Referenced by Bitmap(), Bitmap(), Bitmap(), Create(), Create(), Create(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmapGroup(), yaze::gui::DrawBitmapViewer(), and yaze::editor::Tile16Editor::Initialize().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 158 of file bitmap.h.
References texture_.
Referenced by yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::DrawBitmapViewer(), and yaze::gui::Canvas::DrawTilePainter().
|
inline |
Definition at line 159 of file bitmap.h.
References data_.
Referenced by yaze::gfx::GetTilemapData(), and yaze::editor::Tile16Editor::Initialize().
|
inline |
|
inline |
|
inline |
Definition at line 162 of file bitmap.h.
References active_.
Referenced by yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawBitmap(), and yaze::gui::Canvas::DrawTilePainter().
|
inline |
|
inline |
Definition at line 164 of file bitmap.h.
Referenced by yaze::gfx::UpdateTilemap().
|
inline |
Definition at line 165 of file bitmap.h.
References modified(), and modified_.
Referenced by yaze::editor::OverworldEditor::RenderUpdatedMapBitmap().
|
private |
Definition at line 172 of file bitmap.h.
Referenced by Bitmap(), Bitmap(), Create(), CreateTexture(), Get16x16Tile(), Get8x8Tile(), Reformat(), and width().
|
private |
Definition at line 173 of file bitmap.h.
Referenced by Bitmap(), Bitmap(), Create(), CreateTexture(), Get8x8Tile(), height(), and Reformat().
|
private |
|
private |
Definition at line 176 of file bitmap.h.
Referenced by Create(), is_active(), Reformat(), and set_active().
|
private |
Definition at line 177 of file bitmap.h.
Referenced by modified(), set_modified(), UpdateTextureData(), WriteColor(), and WriteToPixel().
|
private |
Definition at line 183 of file bitmap.h.
Referenced by Create(), Reformat(), WriteColor(), and WriteToPixel().
|
private |
Definition at line 186 of file bitmap.h.
Referenced by Bitmap(), mutable_palette(), palette(), Reformat(), SetPalette(), and SetPaletteWithTransparent().
|
private |
Definition at line 189 of file bitmap.h.
Referenced by at(), Bitmap(), Bitmap(), Create(), Create(), data(), Get16x16Tile(), Get8x8Tile(), mutable_data(), set_data(), size(), UpdateTexture(), vector(), WriteColor(), and WriteToPixel().
|
private |
Definition at line 192 of file bitmap.h.
Referenced by Create(), Reformat(), SetPalette(), SetPalette(), SetPaletteWithTransparent(), surface(), UpdateTexture(), UpdateTextureData(), and WriteColor().
|
private |
Definition at line 195 of file bitmap.h.
Referenced by CreateTexture(), texture(), UpdateTexture(), and UpdateTextureData().