cpp-sdl2
C++ header-only SDL2 wrapper
sdl::Pixel Class Reference

Represent a 4 channel pixel. More...

#include <pixel.hpp>

Public Member Functions

 Pixel (void *target, SDL_PixelFormat const &fmt)
 Construct a pixel structure. More...
 
Pixeloperator= (Color const &c)
 Set color to this pixel via operator =. More...
 
void set_color (Color const &c)
 Set color to this pixel. More...
 
Color color () const
 Get color. More...
 
Uint8 r () const
 Get red channel as byte. More...
 
Uint8 g () const
 Get green channel as byte. More...
 
Uint8 b () const
 Get blue channel as byte. More...
 
Uint8 a () const
 Get alpha channel as byte. More...
 
void set_r (Uint8 r)
 Set red channel from given byte. More...
 
void set_g (Uint8 g)
 Set green channel from given byte. More...
 
void set_b (Uint8 b)
 Set blue channel from given byte. More...
 
void set_a (Uint8 a)
 Set alpha channel from given byte. More...
 

Private Member Functions

void set_raw (Uint32 raw)
 Set this pixel from a 32byte value. More...
 
Uint32 get_raw () const
 Get pixel as 32 bit value. More...
 

Private Attributes

void * target_
 pointer to target structure More...
 
const SDL_PixelFormat & fmt_
 Used pixel format on this format. More...
 

Detailed Description

Represent a 4 channel pixel.

Definition at line 10 of file pixel.hpp.

Constructor & Destructor Documentation

◆ Pixel()

sdl::Pixel::Pixel ( void *  target,
SDL_PixelFormat const &  fmt 
)
inline

Construct a pixel structure.

Definition at line 14 of file pixel.hpp.

References fmt_.

Member Function Documentation

◆ a()

Uint8 sdl::Pixel::a ( ) const
inline

Get alpha channel as byte.

Definition at line 35 of file pixel.hpp.

References color().

Referenced by set_a().

◆ b()

Uint8 sdl::Pixel::b ( ) const
inline

Get blue channel as byte.

Definition at line 33 of file pixel.hpp.

References color().

Referenced by set_b().

◆ color()

Color sdl::Pixel::color ( ) const
inline

Get color.

Definition at line 26 of file pixel.hpp.

References fmt_, and get_raw().

Referenced by a(), b(), g(), r(), set_a(), set_b(), set_g(), and set_r().

◆ g()

Uint8 sdl::Pixel::g ( ) const
inline

Get green channel as byte.

Definition at line 31 of file pixel.hpp.

References color().

Referenced by set_g().

◆ get_raw()

Uint32 sdl::Pixel::get_raw ( ) const
inlineprivate

Get pixel as 32 bit value.

Definition at line 92 of file pixel.hpp.

References fmt_, and target_.

Referenced by color().

◆ operator=()

Pixel& sdl::Pixel::operator= ( Color const &  c)
inline

Set color to this pixel via operator =.

Definition at line 17 of file pixel.hpp.

References set_color().

◆ r()

Uint8 sdl::Pixel::r ( ) const
inline

Get red channel as byte.

Definition at line 29 of file pixel.hpp.

References color().

Referenced by set_r().

◆ set_a()

void sdl::Pixel::set_a ( Uint8  a)
inline

Set alpha channel from given byte.

Definition at line 59 of file pixel.hpp.

References a(), color(), and set_color().

◆ set_b()

void sdl::Pixel::set_b ( Uint8  b)
inline

Set blue channel from given byte.

Definition at line 52 of file pixel.hpp.

References b(), color(), and set_color().

◆ set_color()

void sdl::Pixel::set_color ( Color const &  c)
inline

Set color to this pixel.

Definition at line 23 of file pixel.hpp.

References sdl::Color::as_uint(), fmt_, and set_raw().

Referenced by operator=(), set_a(), set_b(), set_g(), and set_r().

◆ set_g()

void sdl::Pixel::set_g ( Uint8  g)
inline

Set green channel from given byte.

Definition at line 45 of file pixel.hpp.

References color(), g(), and set_color().

◆ set_r()

void sdl::Pixel::set_r ( Uint8  r)
inline

Set red channel from given byte.

Definition at line 38 of file pixel.hpp.

References color(), r(), and set_color().

◆ set_raw()

void sdl::Pixel::set_raw ( Uint32  raw)
inlineprivate

Set this pixel from a 32byte value.

Definition at line 68 of file pixel.hpp.

References fmt_, and target_.

Referenced by set_color().

Member Data Documentation

◆ fmt_

const SDL_PixelFormat& sdl::Pixel::fmt_
private

Used pixel format on this format.

Definition at line 119 of file pixel.hpp.

Referenced by color(), get_raw(), Pixel(), set_color(), and set_raw().

◆ target_

void* sdl::Pixel::target_
private

pointer to target structure

Definition at line 117 of file pixel.hpp.

Referenced by get_raw(), and set_raw().


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