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, 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 SetPalette (const std::vector< SDL_Color > &palette)
 Set the palette using SDL colors.
 
void SetPaletteWithTransparent (const SnesPalette &palette, size_t index, int length=7)
 Set the palette with a transparent color.
 
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
 

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

Constructor & Destructor Documentation

◆ Bitmap() [1/3]

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

◆ Bitmap() [2/3]

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

Create a bitmap with the given dimensions and data.

Definition at line 201 of file bitmap.cc.

◆ Bitmap() [3/3]

yaze::gfx::Bitmap::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.

Definition at line 207 of file bitmap.cc.

Member Function Documentation

◆ Create() [1/3]

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.

◆ Create() [2/3]

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

Create a bitmap with the given dimensions and data.

Definition at line 223 of file bitmap.cc.

◆ Create() [3/3]

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.

◆ Reformat()

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

Reformat the bitmap to use a different pixel format.

Definition at line 258 of file bitmap.cc.

◆ CreateTexture()

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

Creates the underlying SDL_Texture to be displayed.

Definition at line 275 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 266 of file bitmap.cc.

◆ UpdateTextureData()

void yaze::gfx::Bitmap::UpdateTextureData ( )

Updates the texture data from the surface.

Definition at line 298 of file bitmap.cc.

◆ SetPalette() [1/2]

void yaze::gfx::Bitmap::SetPalette ( const SnesPalette & palette)

Set the palette for the bitmap.

Definition at line 307 of file bitmap.cc.

◆ SetPalette() [2/2]

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

Set the palette using SDL colors.

Definition at line 372 of file bitmap.cc.

◆ SetPaletteWithTransparent()

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

Set the palette with a transparent color.

Definition at line 333 of file bitmap.cc.

◆ WriteToPixel()

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.

◆ WriteColor()

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.

◆ Get8x8Tile()

void yaze::gfx::Bitmap::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.

Definition at line 411 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 )

Extract a 16x16 tile from the bitmap.

Definition at line 427 of file bitmap.cc.

◆ palette()

const SnesPalette & yaze::gfx::Bitmap::palette ( ) const
inline

Definition at line 149 of file bitmap.h.

◆ mutable_palette()

SnesPalette * yaze::gfx::Bitmap::mutable_palette ( )
inline

Definition at line 150 of file bitmap.h.

◆ width()

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

Definition at line 151 of file bitmap.h.

◆ height()

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

Definition at line 152 of file bitmap.h.

◆ depth()

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

Definition at line 153 of file bitmap.h.

◆ size()

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

Definition at line 154 of file bitmap.h.

◆ data()

const uint8_t * yaze::gfx::Bitmap::data ( ) const
inline

Definition at line 155 of file bitmap.h.

◆ mutable_data()

std::vector< uint8_t > & yaze::gfx::Bitmap::mutable_data ( )
inline

Definition at line 156 of file bitmap.h.

◆ surface()

SDL_Surface * yaze::gfx::Bitmap::surface ( ) const
inline

Definition at line 157 of file bitmap.h.

◆ texture()

SDL_Texture * yaze::gfx::Bitmap::texture ( ) const
inline

Definition at line 158 of file bitmap.h.

◆ vector()

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

Definition at line 159 of file bitmap.h.

◆ at()

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

Definition at line 160 of file bitmap.h.

◆ modified()

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

Definition at line 161 of file bitmap.h.

◆ is_active()

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

Definition at line 162 of file bitmap.h.

◆ set_active()

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

Definition at line 163 of file bitmap.h.

◆ set_data()

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

Definition at line 164 of file bitmap.h.

◆ set_modified()

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

Definition at line 165 of file bitmap.h.

Member Data Documentation

◆ width_

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

Definition at line 172 of file bitmap.h.

◆ height_

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

Definition at line 173 of file bitmap.h.

◆ depth_

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

Definition at line 174 of file bitmap.h.

◆ active_

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

Definition at line 176 of file bitmap.h.

◆ modified_

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

Definition at line 177 of file bitmap.h.

◆ texture_pixels

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

Definition at line 180 of file bitmap.h.

◆ pixel_data_

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

Definition at line 183 of file bitmap.h.

◆ palette_

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

Definition at line 186 of file bitmap.h.

◆ data_

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

Definition at line 189 of file bitmap.h.

◆ surface_

SDL_Surface* yaze::gfx::Bitmap::surface_ = nullptr
private

Definition at line 192 of file bitmap.h.

◆ texture_

SDL_Texture* yaze::gfx::Bitmap::texture_ = nullptr
private

Definition at line 195 of file bitmap.h.


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