Gosu
Public Member Functions | List of all members
Gosu::Bitmap Class Reference

A two-dimensional array area of pixels, each represented by a Color value. More...

Public Member Functions

 Bitmap ()=default
 
 Bitmap (int width, int height, Color c=Color::NONE)
 
int width () const
 
int height () const
 
void swap (Bitmap &other)
 
void resize (int width, int height, Color c=Color::NONE)
 
Color get_pixel (int x, int y) const
 Returns the color at the specified position without any bounds checking. More...
 
void set_pixel (int x, int y, Color c)
 Sets the pixel at the specified position without any bounds checking. More...
 
void blend_pixel (int x, int y, Color c)
 This updates a pixel using the "over" alpha compositing operator, see: https://en.wikipedia.org/wiki/Alpha_compositing. More...
 
void insert (int x, int y, const Bitmap &source)
 Inserts a bitmap at the given position. More...
 
void insert (int x, int y, const Bitmap &source, int src_x, int src_y, int src_width, int src_height)
 Inserts a portion of a bitmap at the given position. More...
 
const Colordata () const
 Direct access to the array of color values. More...
 
Colordata ()
 Direct access to the array of color values. More...
 

Detailed Description

A two-dimensional array area of pixels, each represented by a Color value.

Bitmaps are typically created only as an intermediate step between loading image files, and creating Gosu::Image objects from them (i.e. transferring the image into video RAM). Has (expensive) value semantics.

Definition at line 14 of file Bitmap.hpp.

Constructor & Destructor Documentation

◆ Bitmap() [1/2]

Gosu::Bitmap::Bitmap ( )
default

◆ Bitmap() [2/2]

Gosu::Bitmap::Bitmap ( int  width,
int  height,
Color  c = Color::NONE 
)

Member Function Documentation

◆ blend_pixel()

void Gosu::Bitmap::blend_pixel ( int  x,
int  y,
Color  c 
)

This updates a pixel using the "over" alpha compositing operator, see: https://en.wikipedia.org/wiki/Alpha_compositing.

Referenced by set_pixel().

◆ data() [1/2]

const Color* Gosu::Bitmap::data ( ) const

Direct access to the array of color values.

The return value is undefined if this bitmap is empty.

Definition at line 65 of file Bitmap.hpp.

◆ data() [2/2]

Color* Gosu::Bitmap::data ( )

Direct access to the array of color values.

The return value is undefined if this bitmap is empty.

Definition at line 72 of file Bitmap.hpp.

References Gosu::apply_border_flags(), Gosu::apply_color_key(), Gosu::load_image_file(), and Gosu::save_image_file().

◆ get_pixel()

Color Gosu::Bitmap::get_pixel ( int  x,
int  y 
) const

Returns the color at the specified position without any bounds checking.

Definition at line 39 of file Bitmap.hpp.

◆ height()

int Gosu::Bitmap::height ( ) const

Definition at line 29 of file Bitmap.hpp.

References Gosu::Color::NONE, resize(), and swap().

◆ insert() [1/2]

void Gosu::Bitmap::insert ( int  x,
int  y,
const Bitmap source 
)

Inserts a bitmap at the given position.

Parts of the inserted bitmap that would be outside of the target bitmap will be clipped away.

Referenced by set_pixel().

◆ insert() [2/2]

void Gosu::Bitmap::insert ( int  x,
int  y,
const Bitmap source,
int  src_x,
int  src_y,
int  src_width,
int  src_height 
)

Inserts a portion of a bitmap at the given position.

Parts of the inserted bitmap that would be outside of the target bitmap will be clipped away.

◆ resize()

void Gosu::Bitmap::resize ( int  width,
int  height,
Color  c = Color::NONE 
)

Referenced by height().

◆ set_pixel()

void Gosu::Bitmap::set_pixel ( int  x,
int  y,
Color  c 
)

Sets the pixel at the specified position without any bounds checking.

Definition at line 45 of file Bitmap.hpp.

References blend_pixel(), and insert().

◆ swap()

void Gosu::Bitmap::swap ( Bitmap other)

Referenced by height().

◆ width()

int Gosu::Bitmap::width ( ) const

Definition at line 24 of file Bitmap.hpp.


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