#include <plbitmap.h>
Inheritance diagram for PLBmp:
Public Member Functions | |
PLBmp () | |
Empty constructor. | |
virtual | ~PLBmp () |
Empty destructor. | |
PLBmp & | operator= (PLBmp const &Orig) |
Assignment operator. | |
bool const | operator== (PLBmp const &Other) |
Test for equality. | |
virtual void | Create (PLLONG Width, PLLONG Height, PLWORD BitsPerPixel, bool bAlphaChannel, const PLPoint &Resolution=PLPoint(0, 0)) |
Creates a new empty bitmap. | |
void | CreateCopy (const PLBmp &rSrPLBmp, int BPPWanted=0) |
Creates a copy of rSrPLBmp, converting color depth if nessesary. | |
void | CreateFilteredCopy (PLBmp &rSrPLBmp, const PLFilter &rFilter) |
Creates a copy of rSrPLBmp, applying rFilter on the way. | |
void | SetQuantizationMode (int DitherType, int DitherPaletteType) |
Sets quality of conversion to 8 bpp. | |
void | SetGrayPalette () |
Fills the color table with a grayscale palette. | |
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) |
Sets one entry in the color table. | |
void | SetPaletteEntry (PLBYTE Entry, PLPixel32 Value) |
Sets one entry in the color table. | |
void | SetAlphaChannel (PLBmp *pAlphaBmp) |
Replaces the alpha channel of the bitmap with a new one. | |
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) |
Find the nearest color to cr in the palette used by this bitmap Only works for 8 bpp bitmaps. | |
int | GetWidth () const |
int | GetHeight () const |
virtual long | GetMemUsed ()=0 |
int | GetNumColors () |
int | GetBitsPerPixel () const |
bool | HasAlpha () const |
void | SetHasAlpha (bool b) |
virtual long | GetBytesPerLine ()=0 |
Returns number of bytes used per line. | |
PLPixel32 * | GetPalette () const |
Returns the address of the color table of the bitmap or NULL if no color table exists. | |
PLBYTE ** | GetLineArray () const |
Returns pointer to an array containing the starting addresses of the bitmap lines. | |
PLPixel32 ** | GetLineArray32 () const |
Returns pointer to an array containing the starting addresses of the bitmap lines. | |
PLPixel24 ** | GetLineArray24 () const |
Returns pointer to an array containing the starting addresses of the bitmap lines. | |
virtual void | Lock (bool bReadable, bool bWriteable) |
Locks bitmap. | |
virtual void | Unlock () |
Unlocks the Bitmap surface. | |
bool | IsLocked () const |
bool | AlmostEqual (const PLBmp &Bmp, int epsilon) const |
const PLPoint & | GetResolution () const |
Gets the bitmap resolution in pixels per inch. | |
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)=0 |
Create a new bitmap with uninitialized bits. | |
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) |
Creates a new PLBmp as copy of rSrPLBmp. | |
void | initLocals (PLLONG Width, PLLONG Height, PLWORD BitsPerPixel, bool bAlphaChannel) |
Can be called from internalCreate() to initialize object state. | |
void | create8BPPCopy (const PLBmp &rSrPLBmp) |
void | create1BPPCopy (const PLBmp &rSrPLBmp) |
Protected Attributes | |
int | m_Width |
int | m_Height |
PLWORD | m_bpp |
PLPoint | m_Resolution |
PLPixel32 * | m_pClrTab |
bool | m_bAlphaChannel |
PLBYTE ** | m_pLineArray |
int | m_LockCount |
int | m_DitherType |
int | m_DitherPaletteType |
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.
|
Empty constructor. Constructors in derived classes create a small empty bitmap to ensure that the object is always in a sane state. Definition at line 30 of file plbitmap.cpp. References PLDTH_NONE, and PLDTHPAL_DEFAULT. |
|
Empty destructor.
Definition at line 41 of file plbitmap.cpp. References PLASSERT. |
|
Definition at line 362 of file plbitmap.cpp. References linalg::abs(), PL_RGBA_BLUE, PL_RGBA_GREEN, PL_RGBA_RED, PLASSERT, and PLBYTE. |
Here is the call graph for this function:
|
Applies a filter to the bitmap.
Definition at line 320 of file plbitmap.cpp. Referenced by PLFilterFill::ApplyInPlace(). |
|
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. Definition at line 238 of file plbitmap.cpp. References freeMembers(), internalCreate(), m_Resolution, PLASSERT_VALID, PLLONG, and PLWORD. Referenced by PLFilterVideoInvert::Apply(), PLFilterThreshold::Apply(), PLFilterResizeHamming::Apply(), PLFilterResizeGaussian::Apply(), PLFilterResizeBox::Apply(), PLFilterResizeBilinear::Apply(), PLFilterQuantize::Apply(), PLFilterMirror::Apply(), PLFilterLightness::Apply(), PLFilterIntensity::Apply(), PLFilterGrayscale::Apply(), PLFilterGetAlpha::Apply(), PLFilterFlip::Apply(), PLFilterCrop::Apply(), PLFilterContrast::Apply(), CreateCopy(), PLPCXDecoder::DoDecode(), PLGIFDecoder::DoDecode(), PLTIFFDecoder::doHiColor(), and PLTIFFDecoder::doLoColor(). |
Here is the call graph for this function:
|
Definition at line 524 of file plbitmap.cpp. References GetBitsPerPixel(), GetBytesPerLine(), GetHeight(), GetLineArray(), GetPalette(), GetWidth(), Lock(), PLBYTE, SetPaletteEntry(), and Unlock(). Referenced by CreateCopy(). |
Here is the call graph for this function:
|
Definition at line 478 of file plbitmap.cpp. References PLFilterQuantize::Apply(), GetBitsPerPixel(), GetHeight(), GetLineArray(), GetPalette(), GetWidth(), Lock(), m_DitherPaletteType, m_DitherType, PL_RGBA_BLUE, PL_RGBA_GREEN, PL_RGBA_RED, PLBYTE, SetPaletteEntry(), and Unlock(). Referenced by CreateCopy(). |
Here is the call graph for this function:
|
Creates a copy of rSrPLBmp, converting color depth if nessesary. Supports 1, 8 and 32 BPP. Alpha channel information is preserved. Definition at line 150 of file plbitmap.cpp. References Create(), create1BPPCopy(), create8BPPCopy(), createTrueColorCopy(), freeMembers(), GetBitsPerPixel(), GetHeight(), GetResolution(), GetWidth(), HasAlpha(), internalCopy(), PLASSERT, PLASSERT_VALID, and SetResolution(). Referenced by PLPicDecoder::MakeBmp(). |
Here is the call graph for this function:
|
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(). Definition at line 204 of file plbitmap.cpp. References PLFilter::Apply(), and PLASSERT_VALID. |
Here is the call graph for this function:
|
Find the nearest color to cr in the palette used by this bitmap Only works for 8 bpp bitmaps.
Definition at line 340 of file plbitmap.cpp. References PLPixel32::BoxDist(), GetNumColors(), GetPalette(), PLASSERT, and PLBYTE. |
Here is the call graph for this function:
|
Delete memory allocated by member variables.
Implemented in PLAnyBmp. Referenced by Create(), and CreateCopy(). |
|
|
Returns number of bytes used per line.
Implemented in PLAnyBmp. Referenced by create1BPPCopy(), and internalCopy(). |
|
|
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 437 of file plbitmap.h. References PLASSERT. Referenced by PLFilterVideoInvert::Apply(), PLFilterThreshold::Apply(), PLFilterResizeHamming::Apply(), PLFilterResizeGaussian::Apply(), PLFilterResizeBox::Apply(), PLFilterResizeBilinear::Apply(), PLFilterLightness::Apply(), PLFilterIntensity::Apply(), PLFilterGrayscale::Apply(), PLFilterGetAlpha::Apply(), PLFilterCrop::Apply(), PLFilterContrast::Apply(), PLFilterPixel< PixelC, PixelOp >::ApplyInPlace(), PLFilterFillRect< PixelC >::ApplyInPlace(), create1BPPCopy(), create8BPPCopy(), createTrueColorCopy(), PLFilterQuantize::ditherDestBmp(), PLGIFDecoder::DoDecode(), PLPNGEncoder::DoEncode(), PLTIFFDecoder::doLoColor(), PLTIFFEncoder::DoTiffEncode(), GetPixel(), internalCopy(), and SetAlphaChannel(). |
|
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 452 of file plbitmap.h. References PLASSERT. |
|
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 444 of file plbitmap.h. References PLASSERT. Referenced by PLFilterGetAlpha::Apply(), PLPCXDecoder::DoDecode(), PLTIFFDecoder::doHiColor(), PLFilterQuantize::genColorArray(), SetAlphaChannel(), and SetPixel(). |
|
Implemented in PLAnyBmp. Referenced by PLPicEncoder::MakeFileFromBmp(). |
|
Definition at line 396 of file plbitmap.h. References PLASSERT_VALID. Referenced by PLTIFFEncoder::DoTiffEncode(), FindNearestColor(), SetGrayPalette(), and SetPalette(). |
|
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 460 of file plbitmap.h. References PLASSERT_VALID. Referenced by PLFilterMirror::Apply(), PLFilterFlip::Apply(), PLFilterCrop::Apply(), create1BPPCopy(), create8BPPCopy(), createPNGPalette(), createTrueColorCopy(), PLFilterQuantize::ditherDestBmp(), PLPNGEncoder::DoEncode(), PLTIFFEncoder::DoTiffEncode(), FindNearestColor(), PLFilterQuantize::genDefaultPalette(), PLFilterQuantize::genMedianPalette(), PLFilterQuantize::genPopularityPalette(), and internalCopy(). |
|
Slow but simple function to get a single pixel. 32 bpp only.
Definition at line 350 of file plbitmap.h. References GetBitsPerPixel(), GetLineArray(), and PLASSERT. Referenced by PLFilterMirror::Apply(), and PLFilterFlip::Apply(). |
Here is the call graph for this function:
|
Gets the bitmap resolution in pixels per inch. Returns 0 if the resolution is unknown. Definition at line 383 of file plbitmap.h. References PLASSERT_VALID. Referenced by PLFilterVideoInvert::Apply(), PLFilterThreshold::Apply(), PLFilterResizeHamming::Apply(), PLFilterResizeGaussian::Apply(), PLFilterResizeBox::Apply(), PLFilterResizeBilinear::Apply(), PLFilterQuantize::Apply(), PLFilterMirror::Apply(), PLFilterLightness::Apply(), PLFilterIntensity::Apply(), PLFilterGrayscale::Apply(), PLFilterGetAlpha::Apply(), PLFilterFlip::Apply(), PLFilterCrop::Apply(), PLFilterContrast::Apply(), CreateCopy(), PLPNGEncoder::DoEncode(), and internalCopy(). |
|
|
|
Initialize internal table of line addresses.
Implemented in PLAnyBmp. Referenced by initLocals(). |
|
Can be called from internalCreate() to initialize object state.
Definition at line 430 of file plbitmap.cpp. References initLineArray(), m_bAlphaChannel, m_bpp, m_Height, m_Width, PLASSERT_VALID, PLLONG, PLWORD, and SetGrayPalette(). |
Here is the call graph for this function:
|
Creates a new PLBmp as copy of rSrPLBmp. Assumes there is no memory allocated yet. Definition at line 448 of file plbitmap.cpp. References GetBitsPerPixel(), GetBytesPerLine(), GetHeight(), GetLineArray(), GetPalette(), GetResolution(), GetWidth(), HasAlpha(), internalCreate(), Lock(), PLASSERT_VALID, PLBYTE, SetPalette(), SetResolution(), and Unlock(). Referenced by CreateCopy(). |
Here is the call graph for this function:
|
Create a new bitmap with uninitialized bits. (Assume no memory is allocated yet.) Implemented in PLAnyBmp. Referenced by Create(), and internalCopy(). |
|
Definition at line 470 of file plbitmap.h. |
|
Locks bitmap. 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, so access is always possible. Definition at line 326 of file plbitmap.cpp. References m_LockCount, and PLASSERT. Referenced by create1BPPCopy(), create8BPPCopy(), createTrueColorCopy(), PLPCXDecoder::DoDecode(), PLTIFFDecoder::doHiColor(), PLTIFFDecoder::doLoColor(), internalCopy(), and SetAlphaChannel(). |
|
Assignment operator. Note that assignment between different derived classes is possible and results in a format conversion. Reimplemented in PLAnyBmp. Definition at line 322 of file plbitmap.h. Referenced by PLAnyBmp::operator=(). |
|
Test for equality. This function actually tests every pixel, so it's not fast. It's meant mainly for use in asserts and such. Definition at line 47 of file plbitmap.cpp. |
|
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. Definition at line 277 of file plbitmap.cpp. References GetBitsPerPixel(), GetHeight(), GetLineArray(), GetLineArray32(), GetWidth(), Lock(), m_bAlphaChannel, PLASSERT, PLASSERT_VALID, PLBYTE, PLPixel32::SetA(), and Unlock(). |
Here is the call graph for this function:
|
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. Definition at line 255 of file plbitmap.cpp. References GetNumColors(), m_pClrTab, PLASSERT, and SetPaletteEntry(). Referenced by initLocals(). |
Here is the call graph for this function:
|
Definition at line 426 of file plbitmap.h. References PLASSERT_VALID. |
|
Sets the color table to pPal. The contents or pPal are copied.
Definition at line 268 of file plbitmap.cpp. References GetNumColors(), m_pClrTab, and PLASSERT. Referenced by PLFilterQuantize::Apply(), PLFilterMirror::Apply(), PLFilterFlip::Apply(), PLFilterCrop::Apply(), PLTIFFDecoder::doLoColor(), and internalCopy(). |
Here is the call graph for this function:
|
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 342 of file plbitmap.h. References PLBYTE. |
|
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 331 of file plbitmap.h. References PLBYTE. Referenced by create1BPPCopy(), create8BPPCopy(), PLGIFDecoder::DoDecode(), and SetGrayPalette(). |
|
Slow but simple function to set a single pixel. 32 bpp only.
Definition at line 356 of file plbitmap.h. References GetBitsPerPixel(), GetLineArray32(), and PLASSERT. Referenced by PLFilterMirror::Apply(), and PLFilterFlip::Apply(). |
Here is the call graph for this function:
|
Sets quality of conversion to 8 bpp. Valid parameters are defined in FilterQuantize.h. Definition at line 210 of file plbitmap.cpp. References m_DitherPaletteType, m_DitherType, and PLASSERT_VALID. |
|
Sets the bitmap resolution in pixels per inch.
Definition at line 389 of file plbitmap.h. References m_Resolution, and PLASSERT_VALID. Referenced by CreateCopy(), PLTIFFDecoder::DoDecode(), PLPCXDecoder::DoDecode(), and internalCopy(). |
|
Unlocks the Bitmap surface.
Definition at line 334 of file plbitmap.cpp. References PLASSERT. Referenced by create1BPPCopy(), create8BPPCopy(), createTrueColorCopy(), PLPCXDecoder::DoDecode(), PLTIFFDecoder::doHiColor(), PLTIFFDecoder::doLoColor(), internalCopy(), and SetAlphaChannel(). |
|
Definition at line 310 of file plbitmap.h. Referenced by initLocals(), and SetAlphaChannel(). |
|
Definition at line 306 of file plbitmap.h. Referenced by initLocals(). |
|
Definition at line 317 of file plbitmap.h. Referenced by create8BPPCopy(), and SetQuantizationMode(). |
|
Definition at line 316 of file plbitmap.h. Referenced by create8BPPCopy(), and SetQuantizationMode(). |
|
Definition at line 305 of file plbitmap.h. Referenced by initLocals(). |
|
Definition at line 313 of file plbitmap.h. Referenced by Lock(). |
|
Definition at line 309 of file plbitmap.h. Referenced by SetGrayPalette(), and SetPalette(). |
|
Definition at line 311 of file plbitmap.h. |
|
Definition at line 307 of file plbitmap.h. Referenced by Create(), and SetResolution(). |
|
Definition at line 304 of file plbitmap.h. Referenced by initLocals(). |