SDLPP::Bitmap Class Reference

#include <sdlpp_graphics.h>

Inheritance diagram for SDLPP::Bitmap:
SDLPP::RefCount

List of all members.

Public Member Functions

 Bitmap (const xstring &filename="")
 Bitmap (int width, int height, bool video_memory)
 Bitmap (const iVec2 &size, bool video_memory)
 Bitmap (std::istream &is)
 Bitmap (ResourceFile &rf, const xstring &name)
 Bitmap (SDL_Surface *surface)
 Bitmap (const Bitmap &rhs)
Bitmapoperator= (const Bitmap &rhs)
SDL_Surface * detach ()
Bitmap clone ()
void save (const xstring &filename)
Bitmap cut (const iRect2 &r)
void draw (int x, int y)
void draw (const iVec2 &p)
void draw (Bitmap &target, int x, int y)
void draw (Bitmap &target, const iVec2 &p)
void draw (Bitmap &target, const iRect2 &src_rect, const iVec2 &dest_point)
void fill (const iRect2 &r, Uint32 color)
void fill (Uint32 color)
iVec2 get_size () const
iRect2 get_rect () const
int get_width () const
int get_height () const
int get_bits_per_pixel () const
Uint32 get_colorkey () const
Uint8 get_alpha () const
void set_pixel_32 (int x, int y, Uint32 color)
void set_pixel_32 (const iVec2 &p, Uint32 color)
Uint32 get_pixel_32 (int x, int y)
Uint32 get_pixel_32 (const iVec2 &p)
Uint32 * get_row_32 (int y)
const Uint32 * get_row_32 (int y) const
void set_colorkey (Uint32 colorkey)
void disable_colorkey ()
void set_alpha (Uint8 alpha)
void disable_alpha ()
SDL_Surface * get_surface ()
bool valid () const

Protected Member Functions

void destroy ()

Detailed Description

Bitmap is the representation of an image or off screen surface. It is a two dimensional matrix of pixels, ususally used to draw graphics. Bitmaps in their nature allocate memory. In order to make their usage simple and still not waste resources by duplicating images in memory, Bitmap objects include built in reference counting, so they can be passed by value on the stack without too much overhead.


Constructor & Destructor Documentation

SDLPP::Bitmap::Bitmap ( const xstring filename = ""  ) 

Construct the bitmap and load it from a file. Will only load BMP files, unless you have the SDL_image shared library installed.

SDLPP::Bitmap::Bitmap ( int  width,
int  height,
bool  video_memory 
)

Create an empty bitmap with the specified size. video_memory indicates whether to allocate the bitmap memory in hardware accelerated memory.

SDLPP::Bitmap::Bitmap ( const iVec2 size,
bool  video_memory 
)

Create an empty bitmap with the specified size. video_memory indicates whether to allocate the bitmap memory in hardware accelerated memory.

SDLPP::Bitmap::Bitmap ( std::istream &  is  ) 

Construct the bitmap and load it from an input stream.

SDLPP::Bitmap::Bitmap ( ResourceFile rf,
const xstring name 
)

Construct the bitmap and load it from a resource file.

SDLPP::Bitmap::Bitmap ( SDL_Surface *  surface  ) 

Attach a surface to this bitmap object. Surface will be destroyed when all references to this bitmap are gone.


Member Function Documentation

Bitmap SDLPP::Bitmap::clone (  ) 

Returns a copy of the bitmap, with a separate buffer. Used for editing a copy of the image without affecting the source.

Bitmap SDLPP::Bitmap::cut ( const iRect2 r  ) 

Return a part of the image contained in the rectangle.

SDL_Surface * SDLPP::Bitmap::detach (  ) 

Detaches the SDL_Surface from this bitmap. This is used to get a bitmap's surface out of the object, to eliminate its destruction. Note that copies of this bitmap still retain the surface pointer.

void SDLPP::Bitmap::draw ( Bitmap target,
const iRect2 src_rect,
const iVec2 dest_point 
)

Draw a part of the bitmap on the target bitmap

void SDLPP::Bitmap::draw ( Bitmap target,
int  x,
int  y 
)

Draws the bitmap over another bitmap at the given coordinates. This can be used to compose an image at runtime from multiple bitmaps.

void SDLPP::Bitmap::draw ( const iVec2 p  ) 

Draws the bitmap to the screen at the given coordinates.

void SDLPP::Bitmap::draw ( int  x,
int  y 
)

Draws the bitmap to the screen at the given coordinates.

void SDLPP::Bitmap::fill ( Uint32  color  ) 

Fills the entire bitmap with a solid color.

void SDLPP::Bitmap::fill ( const iRect2 r,
Uint32  color 
)

Fills a rectangle in the bitmap with a solid color.

iVec2 SDLPP::Bitmap::get_size (  )  const

Retrieve size of bitmap

void SDLPP::Bitmap::save ( const xstring filename  ) 

Saves a BMP file of the image.


The documentation for this class was generated from the following files:
Generated on Wed May 26 17:41:00 2010 for SDLPP by  doxygen 1.6.3