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

Represents a bitmap image. More...

#include <bitmap.h>

Collaboration diagram for yaze::gui::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 SetPalette (const SnesPalette &palette)
 Copy color data from the SnesPalette into the SDL_Palette.
 
void SetPalette (const std::vector< SDL_Color > &palette)
 
absl::Status SetPaletteWithTransparent (const SnesPalette &palette, size_t index, int length=7)
 
absl::Status SetPaletteFromPaletteGroup (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 67 of file bitmap.h.

Constructor & Destructor Documentation

◆ Bitmap() [1/4]

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

◆ Bitmap() [2/4]

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

Definition at line 212 of file bitmap.cc.

◆ Bitmap() [3/4]

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

Definition at line 72 of file bitmap.h.

◆ 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 76 of file bitmap.h.

Member Function Documentation

◆ SaveSurfaceToFile()

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

Definition at line 208 of file bitmap.cc.

◆ 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.

◆ Create() [1/4]

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

Definition at line 97 of file bitmap.h.

◆ 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.

◆ 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.

◆ 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.

◆ Reformat()

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

Definition at line 267 of file bitmap.cc.

◆ 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.

◆ 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.

◆ SetPalette() [1/2]

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

Copy color data from the SnesPalette into the SDL_Palette.

Definition at line 329 of file bitmap.cc.

◆ SetPalette() [2/2]

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

Definition at line 424 of file bitmap.cc.

◆ SetPaletteWithTransparent()

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

Definition at line 382 of file bitmap.cc.

◆ SetPaletteFromPaletteGroup()

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

Definition at line 358 of file bitmap.cc.

◆ 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.

◆ 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.

◆ WriteToPixel()

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

Definition at line 137 of file bitmap.h.

◆ WriteColor()

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

Definition at line 468 of file bitmap.cc.

◆ Cleanup()

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

Definition at line 147 of file bitmap.h.

◆ palette()

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

Definition at line 156 of file bitmap.h.

◆ mutable_palette()

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

Definition at line 157 of file bitmap.h.

◆ width()

int yaze::gfx::Bitmap::width ( ) const
inline

Definition at line 159 of file bitmap.h.

◆ height()

int yaze::gfx::Bitmap::height ( ) const
inline

Definition at line 160 of file bitmap.h.

◆ depth()

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

Definition at line 161 of file bitmap.h.

◆ size()

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

Definition at line 162 of file bitmap.h.

◆ data()

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

Definition at line 163 of file bitmap.h.

◆ mutable_data()

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

Definition at line 164 of file bitmap.h.

◆ surface()

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

Definition at line 165 of file bitmap.h.

◆ vector()

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

Definition at line 167 of file bitmap.h.

◆ at()

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

Definition at line 168 of file bitmap.h.

◆ texture()

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

Definition at line 169 of file bitmap.h.

◆ modified()

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

Definition at line 170 of file bitmap.h.

◆ is_active()

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

Definition at line 171 of file bitmap.h.

◆ set_active()

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

Definition at line 172 of file bitmap.h.

◆ set_data()

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

Definition at line 173 of file bitmap.h.

◆ set_modified()

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

Definition at line 174 of file bitmap.h.

Member Data Documentation

◆ width_

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

Definition at line 177 of file bitmap.h.

◆ height_

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

Definition at line 178 of file bitmap.h.

◆ depth_

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

Definition at line 179 of file bitmap.h.

◆ data_size_

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

Definition at line 180 of file bitmap.h.

◆ active_

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

Definition at line 182 of file bitmap.h.

◆ modified_

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

Definition at line 183 of file bitmap.h.

◆ texture_pixels

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

Definition at line 184 of file bitmap.h.

◆ pixel_data_

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

Definition at line 186 of file bitmap.h.

◆ data_

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

Definition at line 187 of file bitmap.h.

◆ palette_

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

Definition at line 189 of file bitmap.h.

◆ texture_

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

Definition at line 190 of file bitmap.h.

◆ surface_

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

Definition at line 191 of file bitmap.h.


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