Represents a bitmap image. More...
#include <bitmap.h>
Public Member Functions | |
Bitmap ()=default | |
Bitmap (int width, int height, int depth, int data_size) | |
Bitmap (int width, int height, int depth, const std::vector< uint8_t > &data) | |
Bitmap (int width, int height, int depth, const std::vector< uint8_t > &data, const SnesPalette &palette) | |
void | SaveSurfaceToFile (std::string_view filename) |
void | Create (int width, int height, int depth, const std::vector< uint8_t > &data) |
Creates a bitmap object with the provided graphical data. | |
void | Create (int width, int height, int depth, int format, const std::vector< uint8_t > &data) |
void | Reformat (int 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. | |
absl::Status | ApplyPalette (const SnesPalette &palette) |
Copy color data from the SnesPalette into the SDL_Palette. | |
absl::Status | ApplyPaletteWithTransparent (const SnesPalette &palette, size_t index, int length=7) |
void | ApplyPalette (const std::vector< SDL_Color > &palette) |
absl::Status | ApplyPaletteFromPaletteGroup (const SnesPalette &palette, int palette_id) |
void | Get8x8Tile (int tile_index, int x, int y, std::vector< uint8_t > &tile_data, int &tile_data_offset) |
void | Get16x16Tile (int tile_x, int tile_y, std::vector< uint8_t > &tile_data, int &tile_data_offset) |
void | WriteToPixel (int position, uchar value) |
void | WriteWordToPixel (int position, uint16_t value) |
void | WriteColor (int position, const ImVec4 &color) |
void | Cleanup () |
auto | sdl_palette () |
auto | palette () const |
auto | mutable_palette () |
auto | palette_size () const |
int | width () const |
int | height () const |
auto | depth () const |
auto | size () const |
auto | data () const |
auto & | mutable_data () |
auto | mutable_pixel_data () |
auto | surface () const |
auto | mutable_surface () |
auto | converted_surface () const |
auto | mutable_converted_surface () |
auto | vector () const |
auto | at (int i) const |
auto | texture () const |
auto | modified () const |
auto | 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 |
int | data_size_ = 0 |
bool | active_ = false |
bool | modified_ = false |
void * | texture_pixels = nullptr |
uint8_t * | pixel_data_ = nullptr |
std::vector< uint8_t > | data_ |
std::vector< uint8_t > | png_data_ |
gfx::SnesPalette | palette_ |
std::shared_ptr< SDL_Texture > | texture_ = nullptr |
std::shared_ptr< SDL_Surface > | surface_ = nullptr |
std::shared_ptr< SDL_Surface > | converted_surface_ = 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.
|
default |
yaze::app::gfx::Bitmap::Bitmap | ( | int | width, |
int | height, | ||
int | depth, | ||
int | data_size ) |
|
inline |
|
inline |
void yaze::app::gfx::Bitmap::SaveSurfaceToFile | ( | std::string_view | filename | ) |
void yaze::app::gfx::Bitmap::Create | ( | int | width, |
int | height, | ||
int | depth, | ||
const std::vector< uint8_t > & | data ) |
Creates a bitmap object with the provided graphical data.
Definition at line 230 of file bitmap.cc.
References Create(), data(), depth(), height(), yaze::app::gfx::kIndexed, and width().
Referenced by Bitmap(), Bitmap(), Bitmap(), yaze::app::zelda3::screen::Inventory::BuildTileset(), Create(), yaze::app::zelda3::screen::Inventory::Create(), yaze::app::zelda3::screen::TitleScreen::Create(), yaze::app::core::Renderer::CreateAndRenderBitmap(), yaze::app::editor::GraphicsEditor::DecompressImportData(), yaze::app::editor::GraphicsEditor::DrawCgxImport(), yaze::app::editor::GraphicsEditor::DrawScrImport(), and yaze::app::zelda3::dungeon::DungeonObjectRenderer::UpdateObjectBitmap().
void yaze::app::gfx::Bitmap::Create | ( | int | width, |
int | height, | ||
int | depth, | ||
int | format, | ||
const std::vector< uint8_t > & | data ) |
void yaze::app::gfx::Bitmap::Reformat | ( | int | format | ) |
Definition at line 266 of file bitmap.cc.
References active_, ApplyPalette(), depth_, height_, palette_, pixel_data_, surface_, and width_.
Referenced by yaze::app::gui::Canvas::DrawContextMenu().
void yaze::app::gfx::Bitmap::CreateTexture | ( | SDL_Renderer * | renderer | ) |
Creates the underlying SDL_Texture to be displayed.
Converts the surface from a RGB to ARGB format. Uses SDL_TEXTUREACCESS_STREAMING to allow for live updates.
Definition at line 280 of file bitmap.cc.
References converted_surface_, height_, surface_, texture_, texture_pixels, and width_.
Referenced by yaze::app::core::Renderer::RenderBitmap().
void yaze::app::gfx::Bitmap::UpdateTexture | ( | SDL_Renderer * | renderer | ) |
Updates the underlying SDL_Texture when it already exists.
Definition at line 310 of file bitmap.cc.
References converted_surface(), converted_surface_, surface_, texture_, and texture_pixels.
Referenced by yaze::app::core::Renderer::UpdateBitmap().
absl::Status yaze::app::gfx::Bitmap::ApplyPalette | ( | const SnesPalette & | palette | ) |
Copy color data from the SnesPalette into the SDL_Palette.
Definition at line 327 of file bitmap.cc.
References ASSIGN_OR_RETURN, palette(), palette_, yaze::app::gfx::SnesColor::rgb(), sdl_palette(), and surface_.
Referenced by Bitmap(), yaze::app::zelda3::screen::Inventory::BuildTileset(), yaze::app::zelda3::screen::Inventory::Create(), yaze::app::core::Renderer::CreateAndRenderBitmap(), yaze::app::editor::GraphicsEditor::DecompressImportData(), yaze::app::editor::GraphicsEditor::DrawCgxImport(), yaze::app::editor::GraphicsEditor::DrawScrImport(), Reformat(), yaze::app::editor::OverworldEditor::RefreshTile16Blockset(), yaze::app::editor::Tile16Editor::SetCurrentTile(), and yaze::app::editor::Tile16Editor::UpdateBlockset().
absl::Status yaze::app::gfx::Bitmap::ApplyPaletteWithTransparent | ( | const SnesPalette & | palette, |
size_t | index, | ||
int | length = 7 ) |
Definition at line 380 of file bitmap.cc.
References ASSIGN_OR_RETURN, palette(), palette_, yaze::app::gfx::SnesPalette::sub_palette(), and surface_.
Referenced by yaze::app::gui::Canvas::DrawContextMenu(), and yaze::app::editor::Tile16Editor::DrawTileEditControls().
void yaze::app::gfx::Bitmap::ApplyPalette | ( | const std::vector< SDL_Color > & | palette | ) |
absl::Status yaze::app::gfx::Bitmap::ApplyPaletteFromPaletteGroup | ( | const SnesPalette & | palette, |
int | palette_id ) |
Definition at line 356 of file bitmap.cc.
References ASSIGN_OR_RETURN, yaze::app::gfx::SnesPalette::GetColor(), palette(), palette_, yaze::app::gfx::SnesPalette::size(), yaze::app::gfx::SnesPalette::sub_palette(), and surface_.
void yaze::app::gfx::Bitmap::Get8x8Tile | ( | int | tile_index, |
int | x, | ||
int | y, | ||
std::vector< uint8_t > & | tile_data, | ||
int & | tile_data_offset ) |
void yaze::app::gfx::Bitmap::Get16x16Tile | ( | int | tile_x, |
int | tile_y, | ||
std::vector< uint8_t > & | tile_data, | ||
int & | tile_data_offset ) |
|
inline |
Definition at line 134 of file bitmap.h.
References data_, modified_, and pixel_data_.
Referenced by yaze::app::editor::Tile16Editor::DrawToCurrentTile16(), and yaze::app::editor::OverworldEditor::RenderUpdatedMapBitmap().
|
inline |
Definition at line 142 of file bitmap.h.
References data_, modified_, and pixel_data_.
void yaze::app::gfx::Bitmap::WriteColor | ( | int | position, |
const ImVec4 & | color ) |
Definition at line 467 of file bitmap.cc.
References modified_, pixel_data_, and surface_.
Referenced by yaze::app::gui::Canvas::DrawTileOnBitmap().
|
inline |
Definition at line 153 of file bitmap.h.
References active_, yaze::app::gfx::SnesPalette::clear(), data_size_, depth_, height_, palette_, and width_.
|
inline |
|
inline |
Definition at line 168 of file bitmap.h.
References palette_.
Referenced by ApplyPalette(), ApplyPalette(), ApplyPaletteFromPaletteGroup(), ApplyPaletteWithTransparent(), Bitmap(), and yaze::app::editor::MessageEditor::Initialize().
|
inline |
Definition at line 169 of file bitmap.h.
References palette_.
Referenced by yaze::app::editor::MessageEditor::Initialize().
|
inline |
Definition at line 170 of file bitmap.h.
References palette_, and yaze::app::gfx::SnesPalette::size().
|
inline |
Definition at line 172 of file bitmap.h.
References width_.
Referenced by Bitmap(), Bitmap(), Bitmap(), Create(), Create(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::DrawBitmapViewer(), yaze::app::gui::Canvas::DrawTileOnBitmap(), yaze::app::gfx::Tilesheet::GetTile16(), and yaze::app::editor::Tile16Editor::LoadTile8().
|
inline |
Definition at line 173 of file bitmap.h.
References height_.
Referenced by Bitmap(), Bitmap(), Bitmap(), Create(), Create(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), and yaze::app::gui::DrawBitmapViewer().
|
inline |
|
inline |
Definition at line 175 of file bitmap.h.
References data_size_.
|
inline |
Definition at line 176 of file bitmap.h.
References data_.
Referenced by Bitmap(), Bitmap(), Create(), Create(), yaze::app::editor::Tile16Editor::LoadTile8(), and set_data().
|
inline |
Definition at line 177 of file bitmap.h.
References data_.
Referenced by yaze::app::zelda3::screen::TitleScreen::BuildTileset().
|
inline |
Definition at line 178 of file bitmap.h.
References pixel_data_.
|
inline |
Definition at line 179 of file bitmap.h.
References surface_.
Referenced by yaze::app::gui::Canvas::DrawContextMenu().
|
inline |
|
inline |
Definition at line 181 of file bitmap.h.
References converted_surface_.
Referenced by UpdateTexture().
|
inline |
Definition at line 182 of file bitmap.h.
References converted_surface_.
|
inline |
|
inline |
Definition at line 185 of file bitmap.h.
References data_.
Referenced by yaze::app::editor::GraphicsEditor::UpdateGfxTabView().
|
inline |
Definition at line 186 of file bitmap.h.
References texture_.
Referenced by yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::DrawBitmapViewer(), and yaze::app::gui::Canvas::DrawTilePainter().
|
inline |
|
inline |
Definition at line 188 of file bitmap.h.
References active_.
Referenced by yaze::app::gui::Canvas::DrawBitmap(), yaze::app::gui::Canvas::DrawBitmap(), and yaze::app::gui::Canvas::DrawTilePainter().
|
inline |
|
inline |
|
inline |
Definition at line 191 of file bitmap.h.
References modified(), and modified_.
Referenced by yaze::app::editor::OverworldEditor::RenderUpdatedMapBitmap().
|
private |
Definition at line 194 of file bitmap.h.
Referenced by Cleanup(), Create(), CreateTexture(), Get16x16Tile(), Get8x8Tile(), Reformat(), and width().
|
private |
Definition at line 195 of file bitmap.h.
Referenced by Cleanup(), Create(), CreateTexture(), Get8x8Tile(), height(), and Reformat().
|
private |
|
private |
|
private |
Definition at line 199 of file bitmap.h.
Referenced by Cleanup(), Create(), is_active(), Reformat(), and set_active().
|
private |
Definition at line 200 of file bitmap.h.
Referenced by modified(), set_modified(), WriteColor(), WriteToPixel(), and WriteWordToPixel().
|
private |
Definition at line 201 of file bitmap.h.
Referenced by CreateTexture(), and UpdateTexture().
|
private |
Definition at line 203 of file bitmap.h.
Referenced by Create(), mutable_pixel_data(), Reformat(), WriteColor(), WriteToPixel(), and WriteWordToPixel().
|
private |
Definition at line 204 of file bitmap.h.
Referenced by at(), Create(), data(), Get16x16Tile(), Get8x8Tile(), mutable_data(), set_data(), vector(), WriteToPixel(), and WriteWordToPixel().
|
private |
|
private |
Definition at line 208 of file bitmap.h.
Referenced by ApplyPalette(), ApplyPaletteFromPaletteGroup(), ApplyPaletteWithTransparent(), Cleanup(), mutable_palette(), palette(), palette_size(), and Reformat().
|
private |
Definition at line 209 of file bitmap.h.
Referenced by CreateTexture(), texture(), and UpdateTexture().
|
private |
Definition at line 210 of file bitmap.h.
Referenced by ApplyPalette(), ApplyPalette(), ApplyPaletteFromPaletteGroup(), ApplyPaletteWithTransparent(), Create(), CreateTexture(), mutable_surface(), Reformat(), SaveSurfaceToFile(), sdl_palette(), surface(), UpdateTexture(), and WriteColor().
|
private |
Definition at line 211 of file bitmap.h.
Referenced by converted_surface(), CreateTexture(), mutable_converted_surface(), and UpdateTexture().