This reference describes the interfaces provided by the classes in paintlib. It is sorted by class name. You can jump to a particular entry by using the links below.

Library version: 2.3a

[ CAnyBmp | CAnyPicDecoder | CBmp | CBmpDecoder | CBmpEncoder | CDDrawBmp | CDIBSection | CDataSink | CDataSource | CFileSink | CFileSource | CFilter | CFilterContrast | CFilterCrop | CFilterGetAlpha | CFilterGrayscale | CFilterIntensity | CFilterLightness | CFilterQuantize | CFilterResize | CFilterResizeBilinear | CFilterResizeBox | CFilterResizeGaussian | CFilterResizeHamming | CFilterRotate | CFilterThreshold | CJPEGDecoder | CJPEGEncoder | CMemSink | CMemSource | CPCXDecoder | CPGMDecoder | CPLPoint | CPNGDecoder | CPNGEncoder | CPicDecoder | CPicEncoder | CPictDecoder | CPixel32 | CResourceSource | CStreamSink | CTGADecoder | CTIFFDecoder | CTIFFDecoderEx | CTIFFEncoder | CTIFFEncoderEx | CTextException | CWEMFDecoder | CWinBmp | IProgressNotification | Globals ]


CAnyBmp

#include "anybmp.h"

Derived from: public CBmp

Manipulates uncompressed device- and platform-independent bitmaps. Supported data formats are 8 and 32 bpp. The data is stored sequentially without padding in the bitmap. The class implements exactly the interface defined by CBmp without additions.

Public Members

CAnyBmp ();

Creates an empty bitmap.

virtual ~CAnyBmp ();

Destroys the bitmap.

CAnyBmp ( const CBmp &Orig );

Copy constructor

CAnyBmp ( const CAnyBmp &Orig );

Copy constructor

CAnyBmp &operator= ( CBmp const &Orig );

Assignment operator.

long GetMemUsed ();

Returns the amount of memory used by the object.

long GetBytesPerLine ();

Returns number of bytes used per line.

static long GetMemNeeded ( LONG width, LONG height, WORD BitsPerPixel );

Returns memory needed by a bitmap with the specified attributes.

static long GetBitsMemNeeded ( LONG width, LONG height, WORD BitsPerPixel );

Returns memory needed by bitmap bits.


CAnyPicDecoder

#include "anydec.h"

Derived from: public CPicDecoder

Class which decodes pictures with any known format. It auto-detects the format to use and delegates the work to one of the other decoder classes.

The interface to CAnyPicDecoder is the same as CPicDecoder.

Public Members

CAnyPicDecoder ();

Creates a decoder.

~CAnyPicDecoder ();

Destroys the decoder.

void MakeBmp ( CDataSource * pDataSrc, CBmp * pBmp, int BPPWanted );

Decodes a picture in a block of memory.


CBmp

#include "bitmap.h"

Derived from: public CPLObject

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. CBmp 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 (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.

Public Members

CBmp ();

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

virtual ~CBmp ();

Empty destructor.

CBmp &operator= ( CBmp const &Orig );

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

bool const operator == ( CBmp const &Other );

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

virtual void Create ( LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel );

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 CreateCopy ( const CBmp & rSrcBmp, int BPPWanted = 0 );

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

void CreateGrayscaleCopy ( CBmp & rSrcBmp );

Creates a copy of rSrcBmp, converting color information to grayscale in the process. The resulting bitmap is an 8-bit bitmap.

void CreateRotatedCopy ( CBmp & rSrcBmp, double angle, CPixel32 color );

CPLPoint CreateRotatedCopyPoint ( CBmp & rSrcBmp, double angle, CPixel32 color, CPLPoint Point, CPLPoint Pos );

Rotates bitmap around Point. Pos is the current upper-left corner of the bitmap. Returns the new position of the upper-left corner.

void CreateFromAlphaChannel ( CBmp & rSrcBmp );

Creates a bitmap containing only the alpha channel of rSrcBmp.

void CreateResizedBilinear ( CBmp& rSrcBmp, int NewXSize, int NewYSize );

void CreateResizedBox ( CBmp& rSrcBmp, int NewXSize, int NewYSize, double NewRadius );

void CreateResizedGaussian ( CBmp& rSrcBmp, int NewXSize, int NewYSize, double NewRadius );

void CreateResizedHamming ( CBmp& rSrcBmp, int NewXSize, int NewYSize, double NewRadius );

void CreateCropped ( CBmp& rSrcBmp, int XMin, int XMax, int YMin, int YMax );

void SetQuantizationMode ( int DitherType, int DitherPaletteType );

Sets quality of conversion to 8 bpp. Valid parameters are defined in FilterQuantize.h.

void 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 SetPalette ( CPixel32 * pPal );

Sets the color table to pPal. The contents or pPal are copied.

void SetPaletteEntry ( BYTE Entry, BYTE r, BYTE g, BYTE b, BYTE a );

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.

void SetAlphaChannel ( CBmp * 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 ResizeBilinear ( int NewXSize, int NewYSize );

void ResizeBox ( int NewXSize, int NewYSize, double NewRadius );

void ResizeGaussian ( int NewXSize, int NewYSize, double NewRadius );

void ResizeHamming ( int NewXSize, int NewYSize, double NewRadius );

void Crop ( int XMin, int XMax, int YMin, int YMax );

void Threshold (int threshold_min, int threshold_max, int channel );

void MakeGrayscale ();

void Rotate ( double angle, CPixel32 color );

void Invert ();

void SetPixel ( int x, int y, CPixel32 pixel );

Slow but simple function to set a single pixel. 32 bpp only.

CPixel32 GetPixel ( int x, int y );

Slow but simple function to get a single pixel. 32 bpp only.

BYTE FindNearestColor ( CPixel32 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.

CPixel32 * GetPalette () const;

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 CPixel32 objects.

BYTE ** GetLineArray () const;

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.

virtual void Lock ( bool bReadable, bool bWriteable );

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 CDDrawBmp), the lock count will always be >= 1, so access is always possible.

virtual void Unlock ();

Unlocks the Bitmap surface.

Protected Members

virtual void internalCreate ( LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel ) = 0;

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

virtual void freeMembers () = 0;

Delete memory allocated by member variables.

virtual void initLineArray () = 0;

Initialize internal table of line addresses.

void internalCopy ( const CBmp & rSrcBmp );

Creates a new CBmp as copy of rSrcBmp. Assumes there is no memory allocated yet.

void initLocals ( LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel );

Can be called from internalCreate() to initialize object state.


CBmpDecoder

#include "bmpdec.h"

Derived from: public CPicDecoder

Windows bitmap file decoder. Decodes bitmap files (compressed and uncompressed) of all bit depths. Returns an 8 or 32 bpp bitmap.

Public Members

CBmpDecoder ();

Creates a decoder

virtual ~CBmpDecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Does the actual decoding of bitmap data.


CBmpEncoder

#include "bmpenc.h"

Derived from: public CPicEncoder


Public Members

CBmpEncoder ();

Creates an encoder

~CBmpEncoder ();

Destroys a encoder


CDDrawBmp

#include "ddrawbmp.h"

Derived from: public CBmp


Public Members

CDDrawBmp ( IDirectDraw * pDDraw );

Creates an empty bitmap.

virtual ~CDDrawBmp ();

Destroys the bitmap.

virtual long GetMemUsed ();

Returns the amount of memory used by the object.

long GetBytesPerLine ();

Returns number of bytes used per line.

SIZE GetSize ();

Returns the size of the bitmap in pixels

virtual void Lock ( bool bReadable, bool bWriteable );

Draws the bitmap. Locks the DirectDraw surface and fills the line array. GetLineArray() returns NULL if the surface isn't locked.

virtual void Unlock ();

Unlocks the DirectDraw surface.

IDirectDrawSurface * GetSurface ();

Gets a pointer to the directdraw surface used.

Protected Members

virtual void internalCreate ( LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel );

Create a new empty DIB. Bits are uninitialized. Assumes that no memory is allocated before the call.

virtual void freeMembers ();

Deletes memory allocated by member variables.

virtual void initLineArray ();

Initializes internal table of line addresses.


CDIBSection

#include "dibsect.h"

Derived from: public CWinBmp

This is a windows DIBSection wrapped in a CBmp-derived class. It can be used just like a CWinBmp can be used. In addition, CDIBSection can give access to the bitmap as a GDI bitmap handle. This bitmap handle can be selected into a device context. All normal GDI drawing functions can be used to write on the bitmap in this way.

Internally, CDIBSections are stored with header and bits in two separate buffers.

Public Members

CDIBSection ();

Creates an empty bitmap.

virtual ~CDIBSection ();

Destroys the bitmap.

CDIBSection ( const CBmp &Orig );

Copy constructor

CDIBSection ( const CDIBSection &Orig );

Copy constructor

CDIBSection &operator= ( CBmp const &Orig );

Assignment operator.

CDIBSection &operator= ( CDIBSection const &Orig );

Assignment operator.

virtual void Detach ();

Calling this function causes the windows DIBSection to be detached from the CDIBSection object. The bitmap data are not deleted in this function. This means that the bitmap handle and the bitmap memory (bits and BMI) must be deleted by some other object. The CDIBSection object is in the same state as after a constructor call after this function is called.

virtual void Draw ( HDC hDC, int x, int y, DWORD rop = SRCCOPY );

Draws the bitmap on the given device context using BitBlt.

virtual BOOL DrawExtract ( HDC hDC, POINT pntDest, RECT rcSrc );

Draws a portion of the bitmap on the given device context

HBITMAP GetHandle ();

Returns a GDI handle to the bitmap. This handle can be selected into a DC and used in normal GDI operations. Under Windows NT, GDI operations can be queued. This means that a program running under NT must call GdiFlush() before the DIBSection can be used again after GetHandle() has been called. See the documentation for GdiFlush() for details.

Protected Members

virtual void internalCreate ( LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel );

Create a new empty DIB. Bits are uninitialized. Assumes that no memory is allocated before the call.

virtual void freeMembers ();

Deletes memory allocated by member variables.

virtual HANDLE createCopyHandle ();

Creates a copy of the current bitmap in a global memory block and returns a handle to this block.

virtual void initPointers ();

Set color table pointer & pointer to bits based on m_pBMI.


CDataSink

#include "datasink.h"

Derived from: public CPLObject

This is a base class for a destination of picture data. It defines methods to open, write to, close data sinks.

Restriction: actually writes to a memory buffer that needs to be foreseen large enough by user (descendant class)

Public Members

void Open ( const char* pszName, BYTE* pData, size_t MaxDataSize );

virtual void Close ();

char* GetName ();

BYTE* GetBufferPtr ();

size_t GetDataSize ();

size_t GetMaxDataSize ();

size_t WriteNBytes ( size_t n, BYTE* pData );

void Skip ( size_t n );

void CheckEOF ();

Test to see if we didn't go past the "end of the file"

Protected Members

CDataSink ();

virtual ~CDataSink ();


CDataSource

#include "datasrc.h"

Derived from: public CPLObject

This is a base class for a source of picture data. It defines methods to open, close, and read from data sources. Does byte-order-conversions in the ReadByte, ReadWord, and ReadLong routines.

Public Members

CDataSource ( IProgressNotification * pNotification = NULL );

virtual ~CDataSource ();

virtual void Open ( const char * pszName, int FileSize );

virtual void Close ();

char * GetName ();

virtual BYTE * GetBufferPtr ( int MinBytesInBuffer ) = 0;

Read but don't advance file pointer.

virtual BYTE * ReadNBytes ( int n );

This needs to be overridden in derived classes.

int GetFileSize ();

virtual BYTE * ReadEverything () = 0;

This is a legacy routine that interferes with progress notifications. Don't call it!

BYTE * Read1Byte ();

BYTE * Read2Bytes ();

BYTE * Read4Bytes ();

void OProgressNotification ( double part );

handles progress notification from other libs

void AlignToWord ();

void Skip ( int n );

void CheckEOF ();

Test to see if we didn't go past the end of the file


CFileSink

#include "filesink.h"

Derived from: public CDataSink

This is a class which takes a file as a destination of picture data.

Restriction: needs to allocate a buffer large enough to hold a complete image file. But we don't know its size before it's actually encoded, so we have to be generous or "accidents will happen" A better implementation would rely on memory-mapped files or implement dynamic buffering.

Public Members

CFileSink ();

virtual ~CFileSink ();

virtual int Open ( const char * pszFName, int MaxFileSize );

virtual void Close ();


CFileSource

#include "filesrc.h"

Derived from: public CDataSource

This is a class which takes a file as a source of picture data.

Public Members

CFileSource ( IProgressNotification * pNotification = NULL );

virtual ~CFileSource ();

virtual int Open ( const char * pszFName );

virtual void Close ();

virtual BYTE * GetBufferPtr ( int MinBytesInBuffer );

Read but don't advance file pointer.


CFilter

#include "Filter.h"

Derived from: public CPLObject

Base class for filters that operate on bitmaps. Derived classes need to override either the ApplyInPlace or the Apply function.

Public Members

CFilter();

virtual ~CFilter();

virtual void ApplyInPlace(CBmp * pBmp);

In-Place Apply. Applies the filter to pBmp. The base-class version copies the bitmap after calling Apply (pBmp, pTempBmp).

virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);

Applies the Filter to pBmpSource and stores the result in pBmpDest. The base-class version copies the bitmap before calling ApplyInPlace (pBmpDest).


CFilterContrast

#include "FilterContrast.h"

Derived from: public CFilter

Enhances or reduces the image contrast using a linear mapping between input and output. The zero point (i. e., the intensity that is neither enhanced nor reduced) has to be provided. (A Contrast filter is defined in the following way: It lowers all intensity values below a given threshold, and it raises them beyond. Most applications position the threshold at 50 %. This does not always yield the best results, especially if you have an unbalanced dark/light ratio of pixels. The best you can do here is play around with the threshold.)

Public Members

CFilterContrast(double contrast, BYTE offset);

contrast is the slope of the function. offset is the intensity at which the color stays the same. Above this value, intensities are increased. Below it, they are reduced. With offset 128 and contrast 1, the image stays unchanged.


CFilterCrop

#include "FilterCrop.h"

Derived from: public CFilter

Filter that cuts part of the image off.

Public Members

CFilterCrop(int XMin, int XMax, int YMin, int YMax);

virtual ~CFilterCrop();

virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterGetAlpha

#include "FilterGetAlpha.h"

Derived from: public CFilter

Returns an 8 bpp grayscale bitmap containing only the alpha channel of the source bitmap.

Public Members

CFilterGetAlpha();

virtual ~CFilterGetAlpha();

virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterGrayscale

#include "FilterGrayscale.h"

Derived from: public CFilter

Creates a grayscale version of the bitmap.

Public Members

CFilterGrayscale();



virtual ~CFilterGrayscale();



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterIntensity

#include "FilterIntensity.h"

Derived from: public CFilter

Changes the intensity of a bitmap image. Applies the factor intensityFactor = 1.0 + csupp * pow((v-m_offset), m_exponent) with csupp = intensity/pow(255.0, m_exponent); on the v-Value of the image after a HSV transform (who is going to write a HSV2RGB() transform in Assembler?). The bitmap stays unchanged for intensity = 20, offset = 128, exponent = 1.


CFilterLightness

#include "FilterLightness.h"

Derived from: public CFilter

Filter that changes the lightness of a bitmap image. lightness values must be in the range -100..100. A value of 0 leaves the image unchanged.

Public Members

CFilterLightness (int lightness);

virtual ~CFilterLightness();

virtual void Apply(CBmp *pBmpSource, CBmp* pBmpDest);


CFilterQuantize

#include "FilterQuantize.h"

Derived from: public CFilter

Returns an 8 bpp bitmap containing a best-fit representation of the source 32 bpp bitmap.

Public Members

CFilterQuantize (int DitherPaletteType, int DitherType);

DitherPaletteType and DitherType determine the type of quantization:

DTHPAL_MEDIAN (0): Median Cut

DTHPAL_POPULARITY (1): Popularity Sort

DTHPAL_DEFAULT (2): Use Default Palette

DTH_NONE (0): None

DTH_ORDERED (1): Ordered Dithering

DTH_FS (2): Floyd-Steinberg Dithering

virtual ~CFilterQuantize();

virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterResize

#include "FilterResize.h"

Derived from: public CFilter

Base class for filters that resize the image.

Public Members

CFilterResize(int NewXSize, int NewYSize);



virtual ~CFilterResize();



void SetNewSize(int NewXSize, int NewYSize);




CFilterResizeBilinear

#include "FilterResizeBilinear.h"

Derived from: public CFilterResize

Resizes a bitmap using bilinear interpolation.

Public Members

CFilterResizeBilinear (int NewXSize, int NewYSize);



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterResizeBox

#include "FilterResizeBox.h"

Derived from: public CFilterResize

Resizes a bitmap and applies a box filter to it.

Public Members

CFilterResizeBox (int NewXSize, int NewYSize, double NewRadius);



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterResizeGaussian

#include "FilterResizeGaussian.h"

Derived from: public CFilterResize

Resizes a bitmap and applies a gaussian blur to it.

Public Members

CFilterResizeGaussian (int NewXSize, int NewYSize, double NewRadius);



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterResizeHamming

#include "FilterResizeHamming.h"

Derived from: public CFilterResize

Resizes a bitmap and applies a hamming filter to it.

Public Members

CFilterResizeHamming (int NewXSize, int NewYSize, double NewRadius);



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterRotate

#include "FilterRotate.h"

Derived from: public CFilter

Rotates a bitmap by angle radians.

Public Members

CFilterRotate(double angle, CPixel32 crDefault);



virtual ~CFilterRotate();



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CFilterThreshold

#include "FilterThreshold.h"

Derived from: public CFilter

Returns an 8 bpp grayscale bitmap that contains only the channel selected and is black wherever this channel has values <= threshold_min or >= threshold_max.

Public Members

CFilterThreshold(int threshold_min,int threshold_max, int channel);



virtual ~CFilterThreshold();



virtual void Apply(CBmp * pBmpSource, CBmp * pBmpDest);




CJPEGDecoder

#include "jpegdec.h"

Derived from: public CPicDecoder

JPEG file decoder. Uses the independent JPEG group's library to do the actual conversion.

Public Members

CJPEGDecoder ();

Creates a decoder

~CJPEGDecoder ();

Destroys a decoder

void SetFast ( BOOL bFast );

TRUE (the default) selects fast but sloppy decoding.

static void JNotification (j_common_ptr cinfo );

callback for jpeglib's progress notification

Protected Members

void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Sets up the jpeg library data source and error handler and calls the jpeg decoder.


CJPEGEncoder

#include "jpegenc.h"

Derived from: public CPicEncoder

JPEG file encoder. Uses the independent JPEG group's library to do the actual conversion.

Public Members

CJPEGEncoder ();

Creates an encoder

~CJPEGEncoder ();

Destroys a encoder

void SetQuality(int iQuality);

Set the compression quality on a scale from 0 to 100.

void SetOptimizeCoding(bool bOptimizeCoding);

Enable or disable the generation of optimal Huffmann coding tables.

void SetSmoothingFactor(int iSmoothingFactor);

Set the smoothing factor (<=100). 0 turns it off.

void SetDensity(unsigned int uiX, unsigned int uiY);

Set the resolution information (DPI) for the image.


CMemSink

#include "memsink.h"

Derived from: public CDataSink

This is a class which takes a memory region as a destination of picture data.

Public Members

CMemSink ();

virtual ~CMemSink ();

virtual int Open ( const char * pszFName, int MaxFileSize );

virtual void Close ();


CMemSource

#include "memsrc.h"

Derived from: public CDataSource

This is a class which takes a memory pointer as a source of picture data.

Public Members

CMemSource ();

virtual ~CMemSource ();

virtual int Open( unsigned char *pek, int size);

virtual void Close ();

virtual BYTE * GetBufferPtr ( int MinBytesInBuffer );

Read but don't advance file pointer.

virtual BYTE * ReadEverything ();

This is a legacy routine that interferes with progress notifications. Don't call it!


CPCXDecoder

#include "pcxdec.h"

Derived from: public CPicDecoder

PCX file decoder. Decodes 8, 15, 16, 24 and 32 bpp PCX files (compressed and uncompressed) and returns an 8 or 32 bpp CBitmap. Preserves the alpha channel.

Public Members

CPCXDecoder();

Creates a decoder

virtual ~CPCXDecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode (CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc);

Main decoder routine. Reads the header, Creates the bitmap, reads the palette, and reads the image data.


CPGMDecoder

#include "pgmdec.h"

Derived from: public CPicDecoder

Portable Graymap file decoder. Delivers an 8 bpp grayscale image.

Public Members

CPGMDecoder ();

Creates a decoder

virtual ~CPGMDecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Main decoder routine. Reads the header, Creates the bitmap, reads the palette, and reads the image data.


CPLPoint

#include "plpoint.h"

Simple point class for 2d coordinate manipulations. This class contains only inline functions and nothing virtual. Its member variables are public.
In effect, this class emulates most of MFC's point class for non-MFC compiles. For MFC compiles, we have a #define CPLPoint CPoint.

Public Members

CPLPoint ();

CPLPoint ( int X, int Y );

bool operator == ( CPLPoint pt ) const;

bool operator != ( CPLPoint pt ) const;

void operator += ( CPLPoint pt );

void operator -= ( CPLPoint pt );

CPLPoint operator - () const;

CPLPoint operator + ( CPLPoint pt ) const;


CPNGDecoder

#include "pngdec.h"

Derived from: public CPicDecoder

PNG file decoder. Uses LibPng to do the actual decoding. PNG supports many pixel formats not supported by paintlib. These pixel formats are converted to the nearest paintlib equivalent. Images with less or more than 8 bits per channel are converted to 8 bits per channel. Images with 16-bit palettes or grayscale images with an alpha channel are returned as full 32-bit RGBA bitmaps.

Public Members

CPNGDecoder ();

Creates a decoder

virtual ~CPNGDecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Main decoder routine. Reads the header, creates the bitmap, reads the palette, and reads the image data.


CPNGEncoder

#include "pngenc.h"

Derived from: public CPicEncoder

PNG file encoder. Uses LIBPNG to do the actual conversion.

Public Members

CPNGEncoder ();

Creates an encoder

virtual ~CPNGEncoder ();

Destroys a encoder

Protected Members

virtual void DoEncode ( CBmp* pBmp, CDataSink* pDataSnk );

Sets up LIBPNG environment and calls LIBPNG to encode an image.


CPicDecoder

#include "picdec.h"

Derived from: public CPLObject

CPicDecoder is an abstract base class. It defines common routines for all decoders. Decoders for specific file formats can be derived from this class. Objects of this class interact with a CDataSource to decode bitmaps.

Public Members

CPicDecoder ();

Empty constructor. The actual initialization takes place in a derived class.

virtual ~CPicDecoder ();

Destructor. Frees memory allocated.

virtual void MakeBmpFromFile ( const char * pszFName, CBmp * pBmp, int BPPWanted = 0, IProgressNotification * pProgNot = NULL );

Decodes a picture in a file and stores the results in pBmp. BPPWanted is the number of bits per pixel in the bitmap returned. Valid values for BPPWanted are 8, 24, and 0. 0 means 'keep the input format'. Decoding a true-color image to 8 bpp is not supported. As an exception, BPPWanted can be 1 for b/w tiff files.

void MakeBmpFromResource ( HINSTANCE hInstResource, int ResourceID, CBmp * pBmp, int BPPWanted = 0, const char* ResType = NULL, HMODULE hResModule = 0 );

Decodes a picture in a resource by creating a resource data source and calling MakeBmp with this data source. BPPWanted is the number of bits per pixel in the bitmap returned. Valid values for BPPWanted are 8, 24, and 0. 0 means 'keep the input format'. Decoding a true-color image to 8 bpp is not supported. As an exception, BPPWanted can be 1 for b/w tiff files. ResType is the windows resource type (e.g. "JPEG") to be used.

New optional parameter: hResModule (04.01.2000 ms) If a module handle is passed as hResModule, then the resource will be loaded from this module, otherwise, the resource will be searched for by AfxFindResourceHandle (! MFC dependent!)

virtual void CPicDecoder::MakeBmpFromMemory ( unsigned char * ucMemSrc, int MemSrcSize, CBmp * pBmp, int BPPWanted = 0, IProgressNotification * pProgNot = NULL );

Decodes a picture from a memory location which directly resembles the image file as it would be on disc. The result is stored in pBmp. BPPWanted is the number of bits per pixel in the bitmap returned. Valid values for BPPWanted are 8, 24, and 0. 0 means 'keep the input format'. Decoding a true-color image to 8 bpp is not supported. As an exception, BPPWanted can be 1 for b/w tiff files.

virtual void MakeBmp ( CDataSource * pDataSrc, CBmp * pBmp, int BPPWanted = 0 );

Decodes a picture by getting the encoded data from pDataSrc. Stores the results in pBmp. BPPWanted is the number of bits per pixel in the bitmap returned. Valid values for BPPWanted are 8, 24, and 0. 0 means 'keep the input format'. Decoding a true-color image to 8 bpp is not supported.

static void SetTraceConfig ( int Level, char * pszFName );

Sets the amount and destination of debug traces output by the debug version. pszFName contains either a valid file name or is NULL. If it contains a file name, this file is used to store debug information. If pszFName is NULL, the destination is either the MSVC debug console or stderr depending on the version of the library. Valid values for Level are:

0: Trace only errors.
1: Trace top-level calls.
2: Trace picture format information
3: Trace all miscellaneous info.

The trace configuration is global to all decoders.

static void Trace ( int TraceLevel, const char * pszMessage );

Called to output status messages to the current debug console

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Implements the actual decoding process. Uses variables local to the object to retrieve and store the data. Implemented in derived classes.

This routine should never be called. It's here so derived classes can override MakeDIB directly if they want to. (CAnyDecoder does this).


CPicEncoder

#include "picenc.h"

Derived from: public CPLObject

CPicEncoder is an abstract base class. It defines common routines for all encoders. Encoders for specific file formats can be derived from this class. Objects of this class interact with a CDataSink to encode bitmaps.

Public Members

CPicEncoder ();

Empty constructor. The actual initialization takes place in a derived class.

virtual ~CPicEncoder ();

Destructor. Frees memory allocated.

virtual void MakeFileFromBmp( const char *, CBmp* );

Encodes a bitmap to a file and stores.

virtual void SaveBmp( CBmp*, CDataSink* );

Encodes a picture to a pre-existing data destination (sink).

Protected Members

virtual void DoEncode ( CBmp* pBmp, CDataSink* pDataSrc ) = 0;

Implements the actual encoding process. Uses variables local to the object to retrieve and store the data. Implemented in derived classes.




CPictDecoder

#include "pictdec.h"

Derived from: public CPicDecoder

This class decodes macintosh PICT files with 1,2,4,8,16 and 32 bits per pixel as well as PICT/JPEG. If an alpha channel is present in a 32-bit-PICT, it is decoded as well. The PICT format is a general picture file format and can contain a lot of other elements besides bitmaps. These elements are ignored.

There are several opcodes for which I did not find examples. I have marked the appropriate code as "untested". It'll probably work anyway.

Public Members

CPictDecoder ( CJPEGDecoder * pJPEGDecoder );

Creates a decoder. A JPEG decoder is needed to decode PICT files containing JPEGs.

virtual ~CPictDecoder ();

Destroys a decoder.

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Does the actual decoding after a data source has been set up.


CPixel32

#include "pixel32.h"

32 bit pixel class. A pixel in this class contains 8 bits each of red, green, blue and alpha. The order of the color components is OS-dependent and defined in config.h. This class is meant to be fast, so all methods are inlined.

Public Members

CPixel32 ();

CPixel32 (BYTE r, BYTE g, BYTE b, BYTE a);

void Set (BYTE r, BYTE g, BYTE b, BYTE a);

void SetR (BYTE R);

void SetG (BYTE g);

void SetB (BYTE b);

void SetA (BYTE a);

BYTE GetR ();

BYTE GetG ();

BYTE GetB ();

BYTE GetA ();

bool operator ==(const CPixel32&);

bool operator !=(const CPixel32&);

int BoxDist (CPixel32 Pix);

Simple and fast 'distance' between two pixels. Just adds the distances between the color components and treats colors equally.


CResourceSource

#include "ressrc.h"

Derived from: public CDataSource

This is a class which takes a windows resource as a source of picture data.

Public Members

CResourceSource ();

virtual ~CResourceSource ();

virtual int Open ( HINSTANCE lh_ResInst, int ResourceID, const char * pResType = NULL );

virtual void Close ();

virtual BYTE * GetBufferPtr ( int MinBytesInBuffer );

Read but don't advance file pointer.

virtual BYTE * ReadEverything ();

This is a legacy routine that interferes with progress notifications. Don't call it!


CStreamSink

#include "StreamSink.h"

Derived from: public CDataSink


Public Members

virtual int Open ( int MaxFileSize );

virtual void Close ();


CTGADecoder

#include "tgadec.h"

Derived from: public CPicDecoder

Targa file decoder. Decodes 8, 15, 16, 24 and 32 bpp targa files (compressed and uncompressed) and returns an 8 or 32 bpp CBitmap. Preserves the alpha channel.

Public Members

CTGADecoder ();

Creates a decoder

virtual ~CTGADecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Main decoder routine. Reads the header, Creates the bitmap, reads the palette, and reads the image data.


CTIFFDecoder

#include "tiffdec.h"

Derived from: public CPicDecoder

TIFF file decoder. Uses LIBTIFF to do the actual conversion. Supports 1, 8 and 24 bits per pixel as output formats.

Public Members

CTIFFDecoder ();

Creates a decoder

virtual ~CTIFFDecoder ();

Destroys a decoder

Protected Members

virtual void DoDecode ( CBmp * pBmp, CPixel32 ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Sets up LIBTIFF environment and calls LIBTIFF to decode an image.


CTIFFDecoderEx

#include "tiffdecex.h"

Derived from: public CTIFFDecoder

Modest interface to get access to tagged fields This should move to CTiffDecoder but I dare not re-introduce data members in the reworked thread-safe base decoder

Public Members

TIFF* GetTIFFHandle();

this is this first argument to most libtiff's routines use at your own risk; you've been warned!


CTIFFEncoder

#include "tiffenc.h"

Derived from: public CPicEncoder

TIFF file encoder. Uses LIBTIFF to do the actual conversion.

Public Members

CTIFFEncoder ();

Creates an encoder

virtual ~CTIFFEncoder ();

Destroys a encoder

Protected Members

virtual void DoEncode ( CBmp* pBmp, CDataSink* pDataSnk );

Sets up LIBTIFF environment and calls LIBTIFF to encode an image.

virtual void DoTiffEncode ( CBmp* pBmp, TIFF* tif );

this one mostly useful for the "extended" decoder

int SetBaseTags( TIFF*, CBmp* );

According to the characteristics of the given bitmap, set the baseline tags

int SetField( TIFF*, int tag_id, ... );

Set tag value in directory; also, "pseudo-tags" are interpreted by LIBTIFF as modifiers to certain algorithms (compression....). We do _not_ support multiple images by file, nor tiling nor stripping.


CTIFFEncoderEx

#include "tiffencex.h"

Derived from: public CTIFFEncoder

Basic tiff output is available via "CTIFFEncoder::MakeFileFromBmp()". This does not compress data or allow any informative tag to be set. For those who need greater control, CTIFFDecoderEx is provided.

Public Members

CTIFFEncoderEx();

Creates an encoder

virtual ~CTIFFEncoderEx();

Destroys an encoder

BOOL Associate( CDataSink* );

Bind DataSink to Encoder (the link is the TIFF* member)

void Dissociate( void );

Flush the output

int SetBaseTags( CBmp* );

SetBaseTabs and SetField make their base class equivalent usable, without requiring the user to know about the libtiff internals (TIFF*)

int SetField( int tag_id, ... );

SetBaseTabs and SetField make their base class equivalent usable, without requiring the user to know about the libtiff internals (TIFF*)

Protected Members

virtual void DoEncode( CBmp*, CDataSink* = 0 );

Sets up LIBTIFF environment and calls LIBTIFF to encode an image.


CTextException

#include "except.h"

Derived from: public CPLObject

An object of this class is thrown by other classes when an error occurs. It contains an error code and a string describing the error. The error code is meant to be used internally in the program; the descriptive string can be output to the user. Error codes and strings do not correspond 1:1. The strings are more precise.

Public Members

CTextException ( int Code, const char * pszErr );

Creates an exception.

CTextException ( const CTextException& ex );

Copy constructor.

virtual ~CTextException ();

Destroys an exception

virtual int GetCode () const;

Returns the code of the error that caused the exception. Valid error codes are:

ERR_WRONG_SIGNATURE (1): Expected file signature not found.

ERR_FORMAT_UNKNOWN (2): Unexpected data encountered. This probably indicates a corrupt file or an unknown file sub-format.

ERR_PATH_NOT_FOUND (3), ERR_FILE_NOT_FOUND (4), ERR_ACCESS_DENIED (5): Problems with the file system.

ERR_FORMAT_NOT_SUPPORTED (6): Known but unsupported format.

ERR_INTERNAL (7): Kaputt. Tell me about it.

ERR_UNKNOWN_FILE_TYPE (8): Couldn't recognize the file type.

ERR_DIB_TOO_LARGE (9): Maximum size for 1 bmp was exceeded. (See MAX_BITMAP_SIZE above for an explanation).

ERR_NO_MEMORY (10): Out of memory.

ERR_END_OF_FILE (11): End of file reached before end of image.

virtual operator const char * () const;

This operator allows the exception to be treated as a string whenever needed. The string contains the error message.


CWEMFDecoder

#include "wemfdec.h"

Derived from: public CPicDecoder

Decoder for 16-Bit Windows Metafiles (*.wmf) and 16-Bit Adobe Placeable Metafiles (*,wmf) and 32-Bit Enhanced Windows Metafiles (*.emf) for Windows 95, Windows 98 and Windows NT >= 3.1.

Comments by the author, Mario Westphal:
It can handle at least the 500 tested images I've got from various free and commercial clipart sources. If you find a WMF/EMF file it cannot handle, attach it to an email and send it to mw@mwlabs.de. I'll see what I can do. But, please, test it with another program before you send itin to see if it is really a valid metafile.

Public Members

CWEMFDecoder();

virtual ~CWEMFDecoder();

Protected Members

virtual void DoDecode(CBmp * pBmp, CPixel32** ppPal, int* pDestBPP, CDataSource* pDataSrc);


CWinBmp

#include "winbmp.h"

Derived from: public CBmp

This is the windows version of CBmp. The internal storage format is a windows DIB. It supports all color depths allowed by windows: 1, 4, 8, 16, 24, and 32 bpp. The bits are always accessible: m_LockCount is always > 0 and IsLocked always returns true.

The subset of the windows DIB format supported is as follows: The DIB is stored so that header, palette, and bits are in one buffer. The bottom line is stored first (biHeight must be > 0) and the data is uncompressed (BI_RGB). Color tables for 16, 24, and 32 bpp are not supported. biClrUsed is always 0. The palette mode is DIB_RGB_COLORS. DIB_PAL_COLORS is not supported.

Note that almost all real-life DIBs conform to this subset anyway, so there shouldn't be any problems.

In the current version, some functions (notably CreateCopy) only support 1, 8 and 32 bpp. Sorry!

Public Members

CWinBmp ( const CWinBmp &Orig );

Copy constructor

CWinBmp ( const CBmp &Orig );

Copy constructor

virtual ~CWinBmp ();

Destroys the bitmap.

CWinBmp &operator= (CBmp const &Orig);

Assignment operator.

CWinBmp &operator= (CWinBmp const &Orig);

Assignment operator.

virtual long GetMemUsed ();

Returns the amount of memory used by the object.

long GetBytesPerLine ();

Returns number of bytes used per line.

virtual void CreateRes (HINSTANCE lh_ResInst, int ID);

Loads a bitmap from a windows resource (.rc or .res linked to the exe). Fails if the bitmap is compressed.

void CreateFromHBitmap (HBITMAP hBitMap);

Takes a HBITMAP and converts it to a CWinBmp.

void CreateFromHDIBBitmap(BITMAPINFOHEADER* pBIH, HPALETTE hPal = NULL);

Takes an existing device-independent bitmap and converts it to a CWinBmp.

SIZE GetSize ();

Returns the size of the bitmap in pixels

BITMAPINFOHEADER * GetBMI ();

Access the windows bitmap structure. Using this structure, all standard DIB manipulations can be performed.

virtual void Draw (HDC hDC, int x, int y, DWORD rop = SRCCOPY);

Draws the bitmap on the given device context using StretchDIBits.

virtual void StretchDraw (HDC hDC, int x, int y, double Factor, DWORD rop = SRCCOPY);

Draws the bitmap on the given device context using StretchDIBits. Scales the bitmap by Factor.

virtual void StretchDraw (HDC hDC, int x, int y, int w, int h, DWORD rop = SRCCOPY);

Draws the bitmap on the given device context using StretchDIBits. Scales the bitmap so w is the width and h the height.

virtual BOOL DrawExtract (HDC hDC, POINT pntDest, RECT rcSrc);

Draws a portion of the bitmap on the given device context

void ToClipboard ();

Puts a copy of the bitmap in the clipboard

bool FromClipboard (UINT uFormat = CF_BITMAP);

Reads the clipboard into the bitmap. uFormat can be either CF_BITMAP or CF_DIB.

BYTE * GetBits ();

Gets a pointer to the bitmap bits. (Usually, using GetLineArray() is much easier!)

void CopyPalette (CWinBmp * pSrcBmp);

Copies the palette over from pSrcBmp.

void TracePalette();

Traces the values in the palette via PLTRACE();

static long GetMemNeeded (LONG width, LONG height, WORD BitsPerPixel);

Returns memory needed by a bitmap with the specified attributes.

static long GetBitsMemNeeded (LONG width, LONG height, WORD BitsPerPixel);

Returns memory needed by bitmap bits.

static int GetLineMemNeeded (LONG width, WORD BitsPerPixel);

Returns memory needed by one line.

Protected Members

virtual void internalCreate (LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel);

Create a new empty DIB. Bits are uninitialized. Assumes that no memory is allocated before the call.

virtual void internalCreate (BITMAPINFOHEADER* pBMI);

Creates a CWinBmp from an existing bitmap pointer. Assumes that no memory is allocated before the call.

virtual void freeMembers ();

Deletes memory allocated by member variables.

virtual void initLineArray ();

Initializes internal table of line addresses.


IProgressNotification

#include "prognot.h"

Defines an interface for progress notifications.

Public Members

virtual void OnProgress ( double Part ) = 0;

Called during decoding as progress gets made.


Globals

#include "bitmap.h"
MAX_BITMAP_SIZE

This constant defines the maximum amount of memory that a bitmap may use. If more memory would be used by one bitmap, an exception is raised. If MAX_BITMAP_SIZE isn't defined, no checks for huge bitmaps are performed. This is the current default.

This constant was defined to prevent inefficient virtual memory systems (Windows 95 ;-) from thrashing when huge bitmaps are loaded.

RGBA_BLUE, RGBA_GREEN, RGBA_RED, and RGBA_ALPHA

These constants define the order of the channels in an image. To reference a particular channel in a pixel, add one of these constants to the pixel address. The constants can be changed if nessesary to change the channel ordering. The contents of RGBA_ALPHA are only valid if HasAlpha() is TRUE.

PIXEL_BGRA_ORDER

If this is defined, the RGBA_XXX constants are defined so that their ordering is equal to the ordering that windows expects.

PIXEL_RGBA_ORDER

If this is defined, the RGBA_XXX constants are defined so that red is first.

RGBAPIXEL

The data type for a 32-bit pixel. The channels in this pixel are arranged according to the constants RGBA_BLUE, RGBA_GREEN, RGBA_RED, and RGBA_ALPHA.



#include "jmemdest.h"

Defines a custom data source for LIBJPEG



#include "jmemsrc.h"

Defines a custom data source for LIBJPEG



#include "optable.h"

Table of the first 200 or so PICT opcodes with size & description. Mostly stolen from pict2pbm. I hope they don't mind.



#include "paintlibdefs.h"

Windows Bitmap Struct Definitions

Contains the windows defines for non windows compilations.



#include "pgm.h"

Defines structures and constants present in PGM files.



#include "qdraw.h"

This file defines the data structures used in pict files. They correspond to the appropriate MAC QuickDraw structs. See QuickDraw docs for an explanation of these structs.



#include "stdpch.h"

Contains most system-specific includes and definitions. On windows systems, it corresponds to stdafx.h. On other systems, the appropriate data types and macros are declared here.

This file defines the basic data types (BOOL, BYTE, WORD,...)

BOOL, FALSE, TRUE

BOOL is the type for boolean values. Variables of this type should only have the values TRUE (1) and FALSE (0).

BYTE

8 bits of unsigned data.

WORD

An unsigned integer with 16 bits. Due to windows madness, this is not nessesarily the size of a machine word!

LONG

A signed 32-bit integer.

ULONG

An unsigned 32-bit integer.

TRACE (char * pszFormat, ...);

In the debug version (_DEBUG defined), this macro outputs a string to the current debug console. In the release version, it expands to nothing. The parameters correspond to those of printf.

ASSERT (BOOL b);

This is an assert for debug purposes. In the debug version (_DEBUG defined), it causes a program halt if b is FALSE. In the release version, nothing is done. (Note: The parameter is not evaluated in release mode, so constructs like ASSERT (pF = fopen ("bla")) will not do what is expected.)



#include "tga.h"

Defines structures and constants present in TGA files.



#include "tif_msrc.h"

Custom data source for libtiff. Assumes all data is in memory at start.



#include "windefs.h"

Windows Bitmap Struct Definitions

Contains the definitions for the data structures used in windows bitmap files. For windows apps, they are already defined - but not with these names.

The WINRGBQUAD, WINBITMAPFILEHEADER, WINBITMAPINFOHEADER, and WINBITMAPINFO structs are defined as RGBQUAD etc. in the windows header files. See the windows documentation for details.