Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

Bitmap Class Reference

#include <bitmap.h>

Inheritance diagram for Bitmap:

Packed ABGR RGB RGBA List of all members.

Detailed Description

An abstract base class for all sorts of bitmaps.

A bitmap can be resized, converted, copied, painted on, etc. Ultimately it will usually be passed to blit().


Public Types

enum  ColorSpace {
  CS_RGB, CS_RGBA, CS_BGR, CS_ABGR,
  CS_YV12, CS_YV12A
}
 All known color spaces.


Public Member Functions

 Bitmap (int width=0, int height=0)
 Constructor; width and height can be optionally specified.

int w () const
 Returns width.

int h () const
 Returns height.

int get_space () const
 Returns the number of bytes in the buffer returned by get_buf().

int get_space (int width, int height) const
 Returns how many bytes the image would take up if it were width x height pixels.

unsigned char * get_buf () const
 Returns the internal buffer of the image, the actual pixels.

virtual Bitmapcreate () const=0
 "Virtual constructor".

virtual Bitmapclone () const
 "virtual copy constructor".

virtual void set_size (int width, int height)
 Resizes the buffer.

virtual void clear ()
 Sets all bytes in the buffer to zero.

virtual enum ColorSpace get_color_space () const=0
 Used for identifying the type of a Bitmap at runtime.

virtual void convert (Bitmap &target) const
 Convert to a different color space, if possible.

virtual Bitmapunify_csp (Bitmap &bitmap) const
 Convert bitmap to the same color space as this, or fail with an exception.

void resize (int left=0, int right=0, int top=0, int bottom=0)
 Crops or expands the bitmap.

Bitmapresize_copy (int left=0, int right=0, int top=0, int bottom=0) const
 Works like Bitmap::resize, except that it doesn't modify the bitmap, it resizes into a copy that it returns.

virtual void blend (const Bitmap &source, int xoff=0, int yoff=0, int alpha=0)
 Alpha blends source onto this.

virtual void put (const Bitmap &source, int xoff=0, int yoff=0)
 Identical to blend, except that target pixels in this will be overwritten completely.


Protected Member Functions

void alloc (int width, int height)
virtual void resize_into (int left, int right, int top, int bottom, Bitmap *target) const=0
virtual int channel_count () const
virtual int get_pixel_alpha (int pixel) const=0
virtual void set_pixel_alpha (int pixel, int value)=0
virtual int get_pixel_val (int pixel, int channel) const=0
virtual void set_pixel_val (int pixel, int channel, int value)=0

Protected Attributes

int _bpp


Member Function Documentation

void Bitmap::blend const Bitmap source,
int  xoff = 0,
int  yoff = 0,
int  alpha = 0
[virtual]
 

Alpha blends source onto this.

The alpha parameter is a number between -255 and 255 that's added to source's alpha channel, i.e. alpha should usually be negative or 0. You can also specify x and y offsets with xoff and yoff.

This blend funtion works with every type of bitmap, but it's slow. For better performance a virtual blend function should be written for each Bitmap type.

Reimplemented in RGBA.

Bitmap * Bitmap::clone  )  const [virtual]
 

"virtual copy constructor".

Returns a copy of this. Used instead of the copy constructor when the type of Bitmap isn't known.

void Bitmap::convert Bitmap target  )  const [virtual]
 

Convert to a different color space, if possible.

The target parameter is a newly created, empty, bitmap that will be painted onto.

virtual Bitmap* Bitmap::create  )  const [pure virtual]
 

"Virtual constructor".

Returns an empty bitmap of the same derived class as this.

Implemented in RGB, RGBA, and ABGR.

unsigned char* Bitmap::get_buf  )  const [inline]
 

Returns the internal buffer of the image, the actual pixels.

The size of this buffer can be found with get_space(). The returned pointer is only valid until set_size() or resize() is called on the bitmap.

void Bitmap::put const Bitmap source,
int  xoff = 0,
int  yoff = 0
[virtual]
 

Identical to blend, except that target pixels in this will be overwritten completely.

Has better performance than blend.

This put funtion works with every type of bitmap, but it's slow. For better performance a virtual put function should be written for each Bitmap type.

Reimplemented in RGBA.

void Bitmap::resize int  left = 0,
int  right = 0,
int  top = 0,
int  bottom = 0
 

Crops or expands the bitmap.

A positive value for one of the directions will expand the image by adding black transparent pixels. A negative value will crop it.

Bitmap * Bitmap::resize_copy int  left = 0,
int  right = 0,
int  top = 0,
int  bottom = 0
const
 

Works like Bitmap::resize, except that it doesn't modify the bitmap, it resizes into a copy that it returns.

void Bitmap::set_size int  width,
int  height
[virtual]
 

Resizes the buffer.

The contents of the buffer will be preserved if scaling up, but the width/height will no longer be correct. Usually used when discarding the buffer contents anyway.

Bitmap * Bitmap::unify_csp Bitmap bitmap  )  const [virtual]
 

Convert bitmap to the same color space as this, or fail with an exception.

May return the same object it was given if the color spaces already match.


The documentation for this class was generated from the following files:
Generated on Sun Oct 19 17:34:47 2003 for rve by doxygen 1.3.3