yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::app::gfx::Bitmap Class Reference

Represents a bitmap image. More...

#include <bitmap.h>

Collaboration diagram for yaze::app::gfx::Bitmap:

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 (std::shared_ptr< SDL_Renderer > renderer)
 Creates the underlying SDL_Texture to be displayed.
 
void UpdateTexture (std::shared_ptr< SDL_Renderer > renderer)
 Updates the underlying SDL_Texture when it already exists.
 
void CreateTexture (SDL_Renderer *renderer)
 
void UpdateTexture (SDL_Renderer *renderer, bool use_sdl_update=false)
 
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_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
 

Detailed Description

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.

Definition at line 70 of file bitmap.h.

Constructor & Destructor Documentation

◆ Bitmap() [1/4]

yaze::app::gfx::Bitmap::Bitmap ( )
default

◆ Bitmap() [2/4]

yaze::app::gfx::Bitmap::Bitmap ( int width,
int height,
int depth,
int data_size )

Definition at line 228 of file bitmap.cc.

References Create(), depth(), height(), and width().

Here is the call graph for this function:

◆ Bitmap() [3/4]

yaze::app::gfx::Bitmap::Bitmap ( int width,
int height,
int depth,
const std::vector< uint8_t > & data )
inline

Definition at line 75 of file bitmap.h.

References Create(), data(), depth(), height(), and width().

Here is the call graph for this function:

◆ Bitmap() [4/4]

yaze::app::gfx::Bitmap::Bitmap ( int width,
int height,
int depth,
const std::vector< uint8_t > & data,
const SnesPalette & palette )
inline

Definition at line 79 of file bitmap.h.

References ApplyPalette(), Create(), data(), depth(), height(), palette(), and width().

Here is the call graph for this function:

Member Function Documentation

◆ SaveSurfaceToFile()

void yaze::app::gfx::Bitmap::SaveSurfaceToFile ( std::string_view filename)

Definition at line 224 of file bitmap.cc.

References surface_.

◆ Create() [1/2]

◆ Create() [2/2]

void yaze::app::gfx::Bitmap::Create ( int width,
int height,
int depth,
int format,
const std::vector< uint8_t > & data )

Definition at line 237 of file bitmap.cc.

References active_, data(), data_, data_size_, depth(), depth_, height(), height_, pixel_data_, surface_, width(), and width_.

Here is the call graph for this function:

◆ Reformat()

void yaze::app::gfx::Bitmap::Reformat ( int format)

Definition at line 268 of file bitmap.cc.

References active_, ApplyPalette(), depth_, height_, palette_, pixel_data_, surface_, and width_.

Referenced by yaze::app::gui::Canvas::DrawContextMenu().

Here is the call graph for this function:

◆ CreateTexture() [1/2]

void yaze::app::gfx::Bitmap::CreateTexture ( std::shared_ptr< 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 334 of file bitmap.cc.

References surface_, and texture_.

Referenced by yaze::app::core::Renderer::RenderBitmap().

◆ UpdateTexture() [1/2]

void yaze::app::gfx::Bitmap::UpdateTexture ( std::shared_ptr< SDL_Renderer > renderer)

Updates the underlying SDL_Texture when it already exists.

Definition at line 340 of file bitmap.cc.

References surface_, and texture_.

Referenced by yaze::app::core::Renderer::UpdateBitmap().

◆ CreateTexture() [2/2]

void yaze::app::gfx::Bitmap::CreateTexture ( SDL_Renderer * renderer)

Definition at line 282 of file bitmap.cc.

References converted_surface_, height_, surface_, texture_, texture_pixels, and width_.

◆ UpdateTexture() [2/2]

void yaze::app::gfx::Bitmap::UpdateTexture ( SDL_Renderer * renderer,
bool use_sdl_update = false )

Definition at line 312 of file bitmap.cc.

References converted_surface(), converted_surface_, surface_, texture_, and texture_pixels.

Here is the call graph for this function:

◆ ApplyPalette() [1/2]

◆ ApplyPaletteWithTransparent()

absl::Status yaze::app::gfx::Bitmap::ApplyPaletteWithTransparent ( const SnesPalette & palette,
size_t index,
int length = 7 )

◆ ApplyPalette() [2/2]

void yaze::app::gfx::Bitmap::ApplyPalette ( const std::vector< SDL_Color > & palette)

Definition at line 441 of file bitmap.cc.

References palette(), and surface_.

Here is the call graph for this function:

◆ ApplyPaletteFromPaletteGroup()

absl::Status yaze::app::gfx::Bitmap::ApplyPaletteFromPaletteGroup ( const SnesPalette & palette,
int palette_id )

◆ Get8x8Tile()

void yaze::app::gfx::Bitmap::Get8x8Tile ( int tile_index,
int x,
int y,
std::vector< uint8_t > & tile_data,
int & tile_data_offset )

Definition at line 452 of file bitmap.cc.

References data_, height_, and width_.

◆ Get16x16Tile() [1/2]

void yaze::app::gfx::Bitmap::Get16x16Tile ( int tile_index,
int x,
int y,
std::vector< uint8_t > & tile_data,
int & tile_data_offset )

Definition at line 469 of file bitmap.cc.

References data_, height_, and width_.

◆ Get16x16Tile() [2/2]

void yaze::app::gfx::Bitmap::Get16x16Tile ( int tile_x,
int tile_y,
std::vector< uint8_t > & tile_data,
int & tile_data_offset )

Definition at line 485 of file bitmap.cc.

References data_, and width_.

◆ WriteToPixel()

void yaze::app::gfx::Bitmap::WriteToPixel ( int position,
uchar value )
inline

◆ WriteWordToPixel()

void yaze::app::gfx::Bitmap::WriteWordToPixel ( int position,
uint16_t value )
inline

Definition at line 149 of file bitmap.h.

References data_, modified_, and pixel_data_.

◆ WriteColor()

void yaze::app::gfx::Bitmap::WriteColor ( int position,
const ImVec4 & color )

Definition at line 502 of file bitmap.cc.

References modified_, pixel_data_, and surface_.

Referenced by yaze::app::gui::Canvas::DrawTileOnBitmap().

◆ Cleanup()

void yaze::app::gfx::Bitmap::Cleanup ( )
inline

Definition at line 160 of file bitmap.h.

References active_, yaze::app::gfx::SnesPalette::clear(), data_size_, depth_, height_, palette_, and width_.

Here is the call graph for this function:

◆ sdl_palette()

auto yaze::app::gfx::Bitmap::sdl_palette ( )
inline

Definition at line 169 of file bitmap.h.

References surface_.

Referenced by ApplyPalette().

◆ palette()

auto yaze::app::gfx::Bitmap::palette ( ) const
inline

◆ mutable_palette()

auto yaze::app::gfx::Bitmap::mutable_palette ( )
inline

Definition at line 176 of file bitmap.h.

References palette_.

Referenced by yaze::app::editor::MessageEditor::Initialize().

◆ palette_size()

auto yaze::app::gfx::Bitmap::palette_size ( ) const
inline

Definition at line 177 of file bitmap.h.

References palette_, and yaze::app::gfx::SnesPalette::size().

Here is the call graph for this function:

◆ width()

◆ height()

◆ depth()

auto yaze::app::gfx::Bitmap::depth ( ) const
inline

Definition at line 181 of file bitmap.h.

References depth_.

Referenced by Bitmap(), Bitmap(), Bitmap(), Create(), and Create().

◆ size()

auto yaze::app::gfx::Bitmap::size ( ) const
inline

Definition at line 182 of file bitmap.h.

References data_size_.

◆ data()

auto yaze::app::gfx::Bitmap::data ( ) const
inline

Definition at line 183 of file bitmap.h.

References data_.

Referenced by Bitmap(), Bitmap(), Create(), Create(), yaze::app::editor::Tile16Editor::LoadTile8(), and set_data().

◆ mutable_data()

auto & yaze::app::gfx::Bitmap::mutable_data ( )
inline

Definition at line 184 of file bitmap.h.

References data_.

Referenced by yaze::app::zelda3::screen::TitleScreen::BuildTileset().

◆ mutable_pixel_data()

auto yaze::app::gfx::Bitmap::mutable_pixel_data ( )
inline

Definition at line 185 of file bitmap.h.

References pixel_data_.

◆ surface()

auto yaze::app::gfx::Bitmap::surface ( ) const
inline

Definition at line 186 of file bitmap.h.

References surface_.

Referenced by yaze::app::gui::Canvas::DrawContextMenu().

◆ mutable_surface()

auto yaze::app::gfx::Bitmap::mutable_surface ( )
inline

Definition at line 187 of file bitmap.h.

References surface_.

◆ converted_surface()

auto yaze::app::gfx::Bitmap::converted_surface ( ) const
inline

Definition at line 188 of file bitmap.h.

References converted_surface_.

Referenced by UpdateTexture().

◆ mutable_converted_surface()

auto yaze::app::gfx::Bitmap::mutable_converted_surface ( )
inline

Definition at line 189 of file bitmap.h.

References converted_surface_.

◆ vector()

auto yaze::app::gfx::Bitmap::vector ( ) const
inline

Definition at line 191 of file bitmap.h.

References data_.

Referenced by yaze::app::editor::Tile16Editor::InitBlockset().

◆ at()

auto yaze::app::gfx::Bitmap::at ( int i) const
inline

Definition at line 192 of file bitmap.h.

References data_.

Referenced by yaze::app::editor::GraphicsEditor::UpdateGfxTabView().

◆ texture()

◆ modified()

auto yaze::app::gfx::Bitmap::modified ( ) const
inline

Definition at line 194 of file bitmap.h.

References modified_.

Referenced by set_modified().

◆ is_active()

auto yaze::app::gfx::Bitmap::is_active ( ) const
inline

◆ set_active()

void yaze::app::gfx::Bitmap::set_active ( bool active)
inline

Definition at line 196 of file bitmap.h.

References active_.

◆ set_data()

void yaze::app::gfx::Bitmap::set_data ( const std::vector< uint8_t > & data)
inline

Definition at line 197 of file bitmap.h.

References data(), and data_.

Here is the call graph for this function:

◆ set_modified()

void yaze::app::gfx::Bitmap::set_modified ( bool modified)
inline

Definition at line 198 of file bitmap.h.

References modified(), and modified_.

Referenced by yaze::app::editor::OverworldEditor::RenderUpdatedMapBitmap().

Here is the call graph for this function:

Member Data Documentation

◆ width_

int yaze::app::gfx::Bitmap::width_ = 0
private

◆ height_

int yaze::app::gfx::Bitmap::height_ = 0
private

Definition at line 202 of file bitmap.h.

Referenced by Cleanup(), Create(), CreateTexture(), Get16x16Tile(), Get8x8Tile(), height(), and Reformat().

◆ depth_

int yaze::app::gfx::Bitmap::depth_ = 0
private

Definition at line 203 of file bitmap.h.

Referenced by Cleanup(), Create(), depth(), and Reformat().

◆ data_size_

int yaze::app::gfx::Bitmap::data_size_ = 0
private

Definition at line 204 of file bitmap.h.

Referenced by Cleanup(), Create(), and size().

◆ active_

bool yaze::app::gfx::Bitmap::active_ = false
private

Definition at line 206 of file bitmap.h.

Referenced by Cleanup(), Create(), is_active(), Reformat(), and set_active().

◆ modified_

bool yaze::app::gfx::Bitmap::modified_ = false
private

Definition at line 207 of file bitmap.h.

Referenced by modified(), set_modified(), WriteColor(), WriteToPixel(), and WriteWordToPixel().

◆ texture_pixels

void* yaze::app::gfx::Bitmap::texture_pixels = nullptr
private

Definition at line 208 of file bitmap.h.

Referenced by CreateTexture(), and UpdateTexture().

◆ pixel_data_

uint8_t* yaze::app::gfx::Bitmap::pixel_data_ = nullptr
private

◆ data_

std::vector<uint8_t> yaze::app::gfx::Bitmap::data_
private

◆ png_data_

std::vector<uint8_t> yaze::app::gfx::Bitmap::png_data_
private

Definition at line 213 of file bitmap.h.

◆ palette_

gfx::SnesPalette yaze::app::gfx::Bitmap::palette_
private

◆ texture_

std::shared_ptr<SDL_Texture> yaze::app::gfx::Bitmap::texture_ = nullptr
private

Definition at line 216 of file bitmap.h.

Referenced by CreateTexture(), CreateTexture(), texture(), UpdateTexture(), and UpdateTexture().

◆ surface_

◆ converted_surface_

std::shared_ptr<SDL_Surface> yaze::app::gfx::Bitmap::converted_surface_ = nullptr
private

The documentation for this class was generated from the following files: