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.

[ CAnyBmp | CAnyPicDecoder | CBmp | CBmpDecoder | CDIBSection | CDataSink | CDataSource | CFileSink | CFileSource | CFilter | CFilterCrop | CFilterGetAlpha | CFilterGrayscale | CFilterResize | CFilterResizeBilinear | CFilterResizeBox | CFilterResizeGaussian | CFilterResizeHamming | CFilterRotate | CJPEGDecoder | CJPEGEncoder | CObject | CPCXDecoder | CPNGDecoder | CPicDecoder | CPicEncoder | CPictDecoder | CResourceSource | 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.

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 CObject

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.

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 ( 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, RGBAPIXEL color );

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 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 ( RGBAPIXEL * 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 MakeGrayscale ();

void Rotate ( double angle, RGBAPIXEL color );

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

Slow but simple function to set a single pixel

RGBAPIXEL GetPixel ( int x, int y );

Slow but simple function to get a single pixel

int FindNearestColor ( RGBAPIXEL cr );

Find the nearest color to cr in the palette used by this bitmap The function returns the palette index of the color if the bitmap has a palette. For true-color bitmaps, it returns the color itself.

int GetWidth ();

int GetHeight ();

virtual long GetMemUsed () = 0;

int GetNumColors ();

int GetBitsPerPixel ();

BOOL HasAlpha ();

void SetHasAlpha (BOOL b );

virtual long GetBytesPerLine () = 0;

Returns number of bytes used per line.

RGBAPIXEL * GetPalette ();

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 RGBAPIXELs.

BYTE ** GetLineArray ();

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.

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 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 1, 4, 8, and 24 bpp bitmap files (compressed and uncompressed). 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, RGBAPIXEL ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

Does the actual decoding of bitmap data.


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.

virtual void Detach ();

Calling this function causes the windows DIBSection to be detached from the CDIBSection object. 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 ( CDC* pDC, int x, int y, DWORD rop = SRCCOPY );

Draws the bitmap on the given device context using BitBlt.

virtual BOOL DrawExtract ( CDC* pDC, CPoint pntDest, CRect rcSrc );

Draws a portion of the bitmap on the given device context

HANDLE 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 CObject

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 CObject

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 CObject

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).


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);




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, COLORREF crDefault);



virtual ~CFilterRotate();



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, RGBAPIXEL ** 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


CObject

#include "stdpch.h"

This class is the base class for all objects used in the library. Its definition is empty for all but Microsoft VC++ compiles.


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, RGBAPIXEL ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

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


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, RGBAPIXEL ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

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


CPicDecoder

#include "picdec.h"

Derived from: public CObject

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 ( int ResourceID, CBmp * pBmp, int BPPWanted = 0, char* ResType = NULL );

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.

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, char * pszMessage );

Called to output status messages to the current debug console

Protected Members

virtual void DoDecode ( CBmp * pBmp, RGBAPIXEL ** 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 CObject

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, RGBAPIXEL ** ppPal, int * pDestBPP, CDataSource * pDataSrc );

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


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 ( int ResourceID, 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!


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, RGBAPIXEL ** 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, RGBAPIXEL ** 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


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 CObject

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, RGBAPIXEL** 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 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!

21.01.99, Martin Skinner - I added SaveAsBmp(CFile &) to allow saving the Bmp to any CFile-Derived i/o-object. SaveAsBmp(const char *) is still there to ensure back-comp. but it simply calls SaveAsBmp(CFile &).

Public Members

virtual ~CWinBmp ();

Destroys the bitmap.

virtual long GetMemUsed ();

Returns the amount of memory used by the object.

long GetBytesPerLine ();

Returns number of bytes used per line.

virtual void CreateRes ( int ID );

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

CSize 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.

void SaveAsBmp ( const char * pszFName );

Saves the DIB in windows bmp format.

void CWinBmp::SaveAsBmp ( CFile & rFile );

Saves the DIB in windows bmp format. rFile must be opened for writing. rFile remains open after the call. A CFileException may be thrown by MFC.

virtual void Draw ( CDC* pDC, int x, int y, DWORD rop = SRCCOPY );

Draws the bitmap on the given device context using StretchDIBits.

virtual void StretchDraw ( CDC* pDC, 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 ( CDC * pDC, int x, int y, int w, int h, DWORD rop );

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 ( CDC* pDC, CPoint pntDest, CRect rcSrc );

Draws a portion of the bitmap on the given device context

void ToClipBoard ();

Puts a copy of the DIB in the clipboard

BYTE * GetBits ();

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

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.

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 "Pcx.h"

Defines structures and constants present in GIF files.



#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.

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 "config.h"

Contains configuration information.



#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 "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,...) and some debug macros.

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.