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

PLBmp Class Reference

#include <plbitmap.h>

Inheritance diagram for PLBmp:

PLBmpInfo PLAnyBmp PLDirectFBBmp PLSDLBmp PLWinBmp PLDIBSection List of all members.

Public Member Functions

 PLBmp ()
virtual ~PLBmp ()
 Empty destructor.

PLBmpoperator= (PLBmp const &Orig)
bool const operator== (PLBmp const &Other)
virtual void Create (PLLONG Width, PLLONG Height, PLWORD BitsPerPixel, bool bAlphaChannel, bool bIsGreyscale, PLBYTE *pBits=0, int Stride=0, const PLPoint &Resolution=PLPoint(0, 0))
virtual void Create (const PLBmpInfo &Info)
void CreateCopy (const PLBmp &rSrPLBmp, int BPPWanted=0)
void CreateFilteredCopy (PLBmp &rSrPLBmp, const PLFilter &rFilter)
void SetQuantizationMode (int DitherType, int DitherPaletteType)
void SetGrayPalette ()
void SetPalette (PLPixel32 *pPal)
 Sets the color table to pPal. The contents or pPal are copied.

void SetPaletteEntry (PLBYTE Entry, PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a)
void SetPaletteEntry (PLBYTE Entry, PLPixel32 Value)
void SetAlphaChannel (PLBmp *pAlphaBmp)
void ApplyFilter (const PLFilter &Filter)
 Applies a filter to the bitmap.

void SetPixel (int x, int y, PLPixel32 pixel)
 Slow but simple function to set a single pixel. 32 bpp only.

PLPixel32 GetPixel (int x, int y) const
 Slow but simple function to get a single pixel. 32 bpp only.

PLBYTE FindNearestColor (PLPixel32 cr)
virtual long GetMemUsed ()=0
 Returns memory used by a bitmap.

int GetNumColors ()
void SetHasAlpha (bool b)
virtual long GetBytesPerLine ()=0
 Returns number of bytes used per line.

PLPixel32GetPalette () const
PLBYTE ** GetLineArray () const
PLPixel32 ** GetLineArray32 () const
PLPixel24 ** GetLineArray24 () const
virtual void Lock (bool bReadable, bool bWriteable)
virtual void Unlock ()
 Unlocks the Bitmap surface. (See Lock for specifics.).

bool IsLocked () const
 Returns whether a bitmap surface is locked. (See Lock for specifics.).

bool AlmostEqual (const PLBmp &Bmp, int epsilon) const
void SetResolution (const PLPoint &Resolution)
 Sets the bitmap resolution in pixels per inch.


Protected Member Functions

virtual void internalCreate (PLLONG Width, PLLONG Height, PLWORD BitsPerPixel, bool bAlphaChannel, bool bIsGreyscale)=0
virtual void freeMembers ()=0
 Delete memory allocated by member variables.

virtual void initLineArray ()=0
 Initialize internal table of line addresses.

void internalCopy (const PLBmp &rSrPLBmp)
void initLocals (PLLONG Width, PLLONG Height, PLWORD BitsPerPixel, bool bAlphaChannel, bool bIsGreyscale)
 Can be called from internalCreate() to initialize object state.

void create8BPPCopy (const PLBmp &rSrPLBmp)
void create1BPPCopy (const PLBmp &rSrPLBmp)

Protected Attributes

PLPixel32m_pClrTab
PLBYTE ** m_pLineArray
int m_LockCount
int m_DitherType
int m_DitherPaletteType

Detailed Description

Device- and OS-independent bitmap class. Manipulates uncompressed bitmaps of all color depths.

This class is an abstract base class. It exists to define a format-independent interface for bitmap manipulation and to provide common routines. Derived classes must support at least the color depths 1, 8 and 32 bpp. PLBmp defines a public interface for general use and a protected interface for use by derived classes.

For 32 bpp, alpha channel information is stored in one byte (PL_RGBA_ALPHA) of each 4-byte pixel. To allow for optimizations when no alpha channel is present, a flag is set whenever the alpha information is valid. The complete alpha channel of a bitmap can be replaced by a different one by calling SetAlphaChannel(). A 0 in an alpha channel entry is completely transparent; a 255 is completely opaque.

Definition at line 39 of file plbitmap.h.


Constructor & Destructor Documentation

PLBmp::PLBmp  ) 
 

Empty constructor. Constructors in derived classes create a small empty bitmap to ensure that the object is always in a sane state.


Member Function Documentation

bool PLBmp::AlmostEqual const PLBmp Bmp,
int  epsilon
const
 

Returns true if Bmp and this are almost equal. The comparison is done by comparing the pixels in the bitmaps component-wise. If all components are closer than epsilon, the bitmaps are considered almost equal.

virtual void PLBmp::Create const PLBmpInfo Info  )  [virtual]
 

Creates a new empty bitmap. Info contains the metadata (width, height, etc.) to be used in creation.

virtual void PLBmp::Create PLLONG  Width,
PLLONG  Height,
PLWORD  BitsPerPixel,
bool  bAlphaChannel,
bool  bIsGreyscale,
PLBYTE *  pBits = 0,
int  Stride = 0,
const PLPoint Resolution = PLPoint(0, 0)
[virtual]
 

Creates a new empty bitmap. Memory for the bits is allocated but not initialized. Previous contents of the bitmap object are discarded. If bAlphaChannel is true, the bitmap is assumed to contain a valid alpha channel.

void PLBmp::CreateCopy const PLBmp rSrPLBmp,
int  BPPWanted = 0
 

Creates a copy of rSrPLBmp, converting color depth if nessesary. Supports 1, 8, 24 and 32 BPP. Alpha channel information is preserved.

void PLBmp::CreateFilteredCopy PLBmp rSrPLBmp,
const PLFilter rFilter
 

Creates a copy of rSrPLBmp, applying rFilter on the way. Depending on the filter called, this is often much faster than CreateCopy() followed by ApplyFilter().

PLBYTE PLBmp::FindNearestColor PLPixel32  cr  ) 
 

Find the nearest color to cr in the palette used by this bitmap Only works for 8 bpp bitmaps.

PLBYTE ** PLBmp::GetLineArray  )  const [inline]
 

Returns pointer to an array containing the starting addresses of the bitmap lines. This array should be used whenever the bitmap bits need to be manipulated directly.

Definition at line 375 of file plbitmap.h.

Referenced by PLFilterFillRect< PixelC >::ApplyInPlace(), and GetPixel().

PLPixel24 ** PLBmp::GetLineArray24  )  const [inline]
 

Returns pointer to an array containing the starting addresses of the bitmap lines. This array should be used whenever the bitmap bits need to be manipulated directly.

Definition at line 390 of file plbitmap.h.

PLPixel32 ** PLBmp::GetLineArray32  )  const [inline]
 

Returns pointer to an array containing the starting addresses of the bitmap lines. This array should be used whenever the bitmap bits need to be manipulated directly.

Definition at line 382 of file plbitmap.h.

Referenced by SetPixel().

int PLBmp::GetNumColors  )  [inline]
 

Returns number of colors that can be stored by a bitmap with this this color depth.

Definition at line 361 of file plbitmap.h.

PLPixel32 * PLBmp::GetPalette  )  const [inline]
 

Returns the address of the color table of the bitmap or NULL if no color table exists. The color table is stored as an array of consecutive PLPixel32 objects.

Definition at line 398 of file plbitmap.h.

void PLBmp::internalCopy const PLBmp rSrPLBmp  )  [protected]
 

Creates a new PLBmp as copy of rSrPLBmp. Assumes there is no memory allocated yet.

virtual void PLBmp::internalCreate PLLONG  Width,
PLLONG  Height,
PLWORD  BitsPerPixel,
bool  bAlphaChannel,
bool  bIsGreyscale
[protected, pure virtual]
 

Create a new bitmap with uninitialized bits. (Assume no memory is allocated yet.)

Implemented in PLAnyBmp, PLDirectFBBmp, and PLSDLBmp.

virtual void PLBmp::Lock bool  bReadable,
bool  bWriteable
[virtual]
 

Locks bitmap. Currently, this is only usedby PLDDrawBmp - other derived classes always behave as if the bitmap were locked. GetLineArray() and other direct-access methods should only be called if the bitmap is locked. Lock and Unlock keep a lock count. In most cases (currently: all but PLDDrawBmp), the lock count will always be >= 1.

PLBmp & PLBmp::operator= PLBmp const &  Orig  )  [inline]
 

Assignment operator. Note that assignment between different derived classes is possible and results in a format conversion.

Reimplemented in PLAnyBmp, PLDirectFBBmp, PLSDLBmp, PLDIBSection, and PLWinBmp.

Definition at line 314 of file plbitmap.h.

Referenced by PLWinBmp::operator=(), PLSDLBmp::operator=(), PLDirectFBBmp::operator=(), PLDIBSection::operator=(), and PLAnyBmp::operator=().

bool const PLBmp::operator== PLBmp const &  Other  ) 
 

Test for equality. This function actually tests every pixel, so it's not fast. It's meant mainly for use in asserts and such.

void PLBmp::SetAlphaChannel PLBmp pAlphaBmp  ) 
 

Replaces the alpha channel of the bitmap with a new one. This only works for bitmaps with 32 bpp. pAlphaBmp must point to an 8 bpp bitmap with the same dimensions as the object. The alpha channel information is physically copied into the bitmap.

void PLBmp::SetGrayPalette  ) 
 

Fills the color table with a grayscale palette. This function is only useable for bitmaps containing a color table. Index 0 contains black (0) and the last index contains white (255). The alpha channel is set to opaque (255) for every palette entry.

void PLBmp::SetHasAlpha bool  b  ) 
 

Sets whether a bitmap stores an alpha channel. Works for 8 and 32 bpp bitmaps. In either case, if b is true and the bitmap did not have an alpha channel before the call, the complete alpha channel is set to opaque by the call.

void PLBmp::SetPaletteEntry PLBYTE  Entry,
PLPixel32  Value
[inline]
 

Sets one entry in the color table. The function may only be called if there is a color table stored with the bitmap. The color table entry is set to the red, green, blue, and alpha values specified.

Definition at line 334 of file plbitmap.h.

void PLBmp::SetPaletteEntry PLBYTE  Entry,
PLBYTE  r,
PLBYTE  g,
PLBYTE  b,
PLBYTE  a
[inline]
 

Sets one entry in the color table. The function may only be called if there is a color table stored with the bitmap. The color table entry is set to the red, green, blue, and alpha values specified.

Definition at line 323 of file plbitmap.h.

void PLBmp::SetQuantizationMode int  DitherType,
int  DitherPaletteType
 

Sets quality of conversion to 8 bpp by CreateCopy(). Valid parameters are defined in FilterQuantize.h.


The documentation for this class was generated from the following file:
Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2