Public Member Functions | Private Attributes | List of all members
nom::Image Class Reference

Bitmap storage container. More...

#include <Image.hpp>

Public Member Functions

 Image (void)
 Default constructor – initializes to sane defaults.
 
virtual ~Image (void)
 Destructor.
 
 Image (uint32 img_flags)
 
 Image (const Image &other)
 Copy constructor.
 
Image & operator= (const Image &other)
 Copy assignment constructor.
 
bool initialize (void *pixels, int32 width, int32 height, int32 bpp, uint16 pitch, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask)
 
SDL_SURFACE::RawPtr image (void) const
 Obtain the SDL_Surface struct used in this object instance.
 
bool valid (void) const
 Is this object initialized? Valid when NOT nullptr.
 
int32 width (void) const
 
int32 height (void) const
 
void * pixels (void) const
 
uint16 pitch (void) const
 
uint8 bits_per_pixel (void) const
 
const SDL_PIXELFORMAT::RawPtr pixel_format (void) const
 
const uint32 red_mask (void) const
 Obtain the video surface's red alpha mask.
 
const uint32 green_mask (void) const
 Obtain the video surface's green alpha mask.
 
const uint32 blue_mask (void) const
 Obtain the video surface's blue alpha mask.
 
const uint32 alpha_mask (void) const
 Obtain the video surface's alpha mask.
 
const Coords bounds (void) const
 
void set_bounds (const Coords &clip_bounds)
 
bool load (const std::string &filename)
 
bool load_bmp (const std::string &filename)
 
bool save (const std::string &filename, SDL_SURFACE::RawPtr video_buffer) const
 
bool save (const std::string &filename) const
 
const Point2i size (void) const
 Obtain the width and height (in pixels) of the stored bitmap buffer.
 
const Color colorkey (void) const
 
const SDL_BlendMode blend_mode (void) const
 Obtain the blend mode used for blitting.
 
bool set_colorkey (const Color &colorkey, bool flag)
 
bool RLE (bool flag)
 
uint32 pixel (int32 x, int32 y)
 
bool set_blend_mode (const SDL_BlendMode blend)
 Set a new blending mode for blitting.
 

Private Attributes

SDL_SURFACE::SharedPtr image_
 

Detailed Description

Bitmap storage container.

Definition at line 49 of file Image.hpp.

Constructor & Destructor Documentation

nom::Image::Image ( uint32  img_flags)

Construct an Image object with specified flags passed to the library extension(s) used in this object.

Definition at line 50 of file Image.cpp.

Member Function Documentation

uint8 nom::Image::bits_per_pixel ( void  ) const
Todo:
Rename me to bppp

Definition at line 129 of file Image.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const Coords nom::Image::bounds ( void  ) const

I think that we are accessing the value of an (internal?) property of the SDL_Surface structure that is described as being "private" as per the docs.

Return value of this internal property is presumed to be boolean – no verification has been made of this. Testing of this method appears to be in working order. Lock the display context's video surface; this must be done before you attempt to write directly to video memory, such as when you are manipulating surfaces at the pixel level. Unlocks the display context's video surface; this must be done after you are finished writing to the video buffer. During the time that the video surface is locked, no updates (think: rendering) outside of your local access can occur until the surfaces affected by the lock are relinquished.

Definition at line 162 of file Image.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const Color nom::Image::colorkey ( void  ) const

Obtain the set color key for this image

Returns
Returns new nom::Color on success; nom::Color::null on failure

Definition at line 245 of file Image.cpp.

Here is the call graph for this function:

bool nom::Image::initialize ( void *  pixels,
int32  width,
int32  height,
int32  bpp,
uint16  pitch,
uint32  Rmask,
uint32  Gmask,
uint32  Bmask,
uint32  Amask 
)

Initialize an image surface using the data from an existing pixel buffer source.

Parameters
pixelsTypically a void pointer cast to nom::uint16 or nom::uint32
bppBits per pixel
Note
You maintain ownership of your pixel buffer pointer; don't forget to clean up after you're done!

Definition at line 74 of file Image.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Image::load ( const std::string &  filename)

Supports every file type that the libSDL_image extension has been compiled with

Definition at line 185 of file Image.cpp.

Here is the caller graph for this function:

bool nom::Image::load_bmp ( const std::string &  filename)

Uses SDL's built-in BMP file loader; no alpha channeling support ... perfect for setting window icons!

(I have yet to find success using IMG_Load to load an ordinary bitmap file, whereas SDL_LoadBMP does load fine).

Definition at line 202 of file Image.cpp.

uint32 nom::Image::pixel ( int32  x,
int32  y 
)

Pixel reading – supports 8-bit, 15/16-bit, 24-bit & 32-bit color modes

Returns -1 on error

You are responsible for locking & unlocking of the Image before-hand

Todo:
Test 8-bit, 15/16-bit & 24-bit pixels

Definition at line 306 of file Image.cpp.

Here is the call graph for this function:

bool nom::Image::RLE ( bool  flag)

Set RLE acceleration for this image

If enabled, color keying and alpha blending blits are much faster, but at the cost of requiring surface locking before directly accessing pixels.

Parameters
TRUEto enable RLE acceleration; FALSE to disable

Definition at line 296 of file Image.cpp.

Here is the call graph for this function:

bool nom::Image::save ( const std::string &  filename,
SDL_SURFACE::RawPtr  video_buffer 
) const

Save a screenshot as an uncompressed RGB Windows Bitmap (BMP) file.

Parameters
filenameOutput filename path
video_bufferSurface used to save to filename

Definition at line 218 of file Image.cpp.

Here is the caller graph for this function:

bool nom::Image::save ( const std::string &  filename) const

Save a screenshot of this image as an uncompressed RGB Windows Bitmap (BMP) file.

Parameters
filenameOutput filename path

Definition at line 229 of file Image.cpp.

Here is the call graph for this function:

bool nom::Image::set_colorkey ( const Color &  colorkey,
bool  flag 
)

Set a new color key on the image loaded into memory.

Parameters
colorkeyPixel color to mark transparent
flagTRUE to enable color key; FALSE to disable color key

Definition at line 274 of file Image.cpp.

Here is the call graph for this function:


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