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

Represents a bitmap image. More...

#include <bitmap.h>

Collaboration diagram for yaze::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 Initialize (int width, int height, int depth, std::span< uint8_t > &data)
 
void Create (int width, int height, int depth, int data_size)
 
void Create (int width, int height, int depth, std::span< uint8_t > data)
 
void Create (int width, int height, int depth, const std::vector< uint8_t > &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, uint8_t value)
 
void WriteColor (int position, const ImVec4 &color)
 
void Cleanup ()
 
auto palette () const
 
auto mutable_palette ()
 
int width () const
 
int height () const
 
auto depth () const
 
auto size () const
 
auto data () const
 
auto & mutable_data ()
 
auto surface () const
 
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_
 
gfx::SnesPalette palette_
 
std::shared_ptr< SDL_Texture > texture_ = nullptr
 
std::shared_ptr< SDL_Surface > 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 66 of file bitmap.h.

Constructor & Destructor Documentation

◆ Bitmap() [1/4]

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

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

Here is the call graph for this function:

◆ Bitmap() [2/4]

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

Definition at line 212 of file bitmap.cc.

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

Here is the call graph for this function:

◆ Bitmap() [3/4]

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

Definition at line 71 of file bitmap.h.

References Create(), data(), data_, depth(), depth_, height(), height_, width(), and width_.

◆ Bitmap() [4/4]

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

Definition at line 75 of file bitmap.h.

References ApplyPalette(), Create(), data(), data_, depth(), depth_, height(), height_, palette(), palette_, width(), and width_.

Member Function Documentation

◆ SaveSurfaceToFile()

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

Definition at line 208 of file bitmap.cc.

References surface_.

◆ Initialize()

void yaze::gfx::Bitmap::Initialize ( int width,
int height,
int depth,
std::span< uint8_t > & data )

Definition at line 216 of file bitmap.cc.

References data(), data_, depth(), depth_, height(), height_, width(), and width_.

Here is the call graph for this function:

◆ Create() [1/4]

void yaze::gfx::Bitmap::Create ( int width,
int height,
int depth,
int data_size )
inline

Definition at line 96 of file bitmap.h.

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

Referenced by Bitmap(), Bitmap(), Bitmap(), Create(), Create(), Create(), and yaze::core::Renderer::CreateAndRenderBitmap().

Here is the call graph for this function:

◆ Create() [2/4]

void yaze::gfx::Bitmap::Create ( int width,
int height,
int depth,
std::span< uint8_t > data )

Definition at line 224 of file bitmap.cc.

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

◆ Create() [3/4]

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

Definition at line 229 of file bitmap.cc.

References Create(), data(), depth(), height(), yaze::gfx::kIndexed, and width().

◆ Create() [4/4]

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

Definition at line 234 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::gfx::Bitmap::Reformat ( int format)

Definition at line 267 of file bitmap.cc.

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

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

Here is the call graph for this function:

◆ CreateTexture()

void yaze::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 281 of file bitmap.cc.

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

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

◆ UpdateTexture()

void yaze::gfx::Bitmap::UpdateTexture ( SDL_Renderer * renderer)

Updates the underlying SDL_Texture when it already exists.

Definition at line 314 of file bitmap.cc.

References surface_, texture_, and texture_pixels.

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

◆ ApplyPalette() [1/2]

absl::Status yaze::gfx::Bitmap::ApplyPalette ( const SnesPalette & palette)

Copy color data from the SnesPalette into the SDL_Palette.

Definition at line 329 of file bitmap.cc.

References ASSIGN_OR_RETURN, palette(), palette_, yaze::gfx::SnesColor::rgb(), and surface_.

Referenced by Bitmap(), yaze::core::Renderer::CreateAndRenderBitmap(), and Reformat().

Here is the call graph for this function:

◆ ApplyPaletteWithTransparent()

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

Definition at line 382 of file bitmap.cc.

References ASSIGN_OR_RETURN, palette(), palette_, and surface_.

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

Here is the call graph for this function:

◆ ApplyPalette() [2/2]

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

Definition at line 424 of file bitmap.cc.

References palette(), and surface_.

Here is the call graph for this function:

◆ ApplyPaletteFromPaletteGroup()

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

Definition at line 358 of file bitmap.cc.

References ASSIGN_OR_RETURN, palette(), palette_, and surface_.

Here is the call graph for this function:

◆ Get8x8Tile()

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

Definition at line 435 of file bitmap.cc.

References data_, height_, and width_.

◆ Get16x16Tile()

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

Definition at line 451 of file bitmap.cc.

References data_, and width_.

◆ WriteToPixel()

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

Definition at line 136 of file bitmap.h.

References data_, modified_, and pixel_data_.

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

◆ WriteColor()

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

Definition at line 468 of file bitmap.cc.

References yaze::gfx::ConvertRgbToSnes(), data_, modified_, pixel_data_, and surface_.

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

Here is the call graph for this function:

◆ Cleanup()

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

Definition at line 146 of file bitmap.h.

References active_, data_size_, depth_, height_, palette_, and width_.

◆ palette()

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

◆ mutable_palette()

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

Definition at line 156 of file bitmap.h.

References palette_.

◆ width()

◆ height()

◆ depth()

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

◆ size()

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

Definition at line 161 of file bitmap.h.

References data_size_.

◆ data()

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

Definition at line 162 of file bitmap.h.

References data_.

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

◆ mutable_data()

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

Definition at line 163 of file bitmap.h.

References data_.

◆ surface()

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

Definition at line 164 of file bitmap.h.

References surface_.

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

◆ vector()

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

Definition at line 166 of file bitmap.h.

References data_.

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

◆ at()

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

Definition at line 167 of file bitmap.h.

References data_.

◆ texture()

auto yaze::gfx::Bitmap::texture ( ) const
inline

◆ modified()

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

Definition at line 169 of file bitmap.h.

References modified_.

Referenced by set_modified().

◆ is_active()

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

◆ set_active()

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

Definition at line 171 of file bitmap.h.

References active_.

◆ set_data()

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

Definition at line 172 of file bitmap.h.

References data(), and data_.

Here is the call graph for this function:

◆ set_modified()

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

Definition at line 173 of file bitmap.h.

References modified(), and modified_.

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

Here is the call graph for this function:

Member Data Documentation

◆ width_

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

◆ height_

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

◆ depth_

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

Definition at line 178 of file bitmap.h.

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

◆ data_size_

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

Definition at line 179 of file bitmap.h.

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

◆ active_

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

Definition at line 181 of file bitmap.h.

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

◆ modified_

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

Definition at line 182 of file bitmap.h.

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

◆ texture_pixels

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

Definition at line 183 of file bitmap.h.

Referenced by CreateTexture(), and UpdateTexture().

◆ pixel_data_

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

Definition at line 185 of file bitmap.h.

Referenced by Create(), Reformat(), WriteColor(), and WriteToPixel().

◆ data_

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

◆ palette_

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

◆ texture_

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

Definition at line 189 of file bitmap.h.

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

◆ surface_

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

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