ImageViewer - Technionsoftlab-pro-web.technion.ac.il/.../ImageViewer/html/Doc…  · Web...

198
Image Viewer for Image Viewer for Windows Windows ® ® CE 3.0 CE 3.0 Code Review Code Review By: David Klajn Ronny Tuttnauer Supervisors: Alexander Arlievsky Lev Rechnik

Transcript of ImageViewer - Technionsoftlab-pro-web.technion.ac.il/.../ImageViewer/html/Doc…  · Web...

Image Viewer forImage Viewer forWindowsWindows®® CE 3.0 CE 3.0

Code ReviewCode Review

By:David KlajnRonny Tuttnauer

Supervisors:Alexander ArlievskyLev Rechnik

Technion - Israel Institute of TechnologyTechnion - Israel Institute of TechnologyFaculty of Electrical EngineeringFaculty of Electrical EngineeringSoftware Systems LabSoftware Systems Lab

2

ImageViewer Hierarchical Index

ImageViewer Class HierarchyThis inheritance list is sorted roughly, but not completely, alphabetically:

_PgmHeader_TgaHeader_tiff_helperC2PassScale< FilterClass, DataClass >.....................................................................................................9CAboutDlgCAppOptions...........................................................................................................................................14CBmp.......................................................................................................................................................18

CAnyBmp.........................................................................................................................................10CWinBmp.......................................................................................................................................154

CDIBSection.............................................................................................................................35CWinBmpEx

CContrastDlg...........................................................................................................................................27CCopyMoveDlg......................................................................................................................................28CCropFilterDlg........................................................................................................................................29CDataPaintLib32.....................................................................................................................................30CDataPaintLib32::_AccumulatorCDataRGB_UBYTECDataRGB_UBYTE::_AccumulatorCDataRGBA_UBYTECDataRGBA_UBYTE::_AccumulatorCDataSink................................................................................................................................................31

CFileSink..........................................................................................................................................69CDataSource............................................................................................................................................33

CFileSource......................................................................................................................................70CMemSource..................................................................................................................................115CResourceSource...........................................................................................................................137

CDIBSectionLite.....................................................................................................................................38CDibSequence.........................................................................................................................................63CDIBStatic..............................................................................................................................................65CDitherDialog.........................................................................................................................................66CDocManagerEx.....................................................................................................................................68CFilter......................................................................................................................................................71

CFilterContrast.................................................................................................................................73CFilterCrop.......................................................................................................................................75CFilterGetAlpha...............................................................................................................................77CFilterGrayscale...............................................................................................................................78CFilterIntensity.................................................................................................................................79CFilterLightness...............................................................................................................................80CFilterQuantize................................................................................................................................81CFilterResize....................................................................................................................................84

3

CFilterResizeBilinear................................................................................................................85CFilterResizeBox......................................................................................................................86CFilterResizeGaussian..............................................................................................................87CFilterResizeHamming.............................................................................................................88

CFilterRotate....................................................................................................................................89CFilterThreshold..............................................................................................................................90CVideoInvertFilter.........................................................................................................................153

CFilterDialog...........................................................................................................................................76CFilterQuantize::tagHISTONODECFilterQuantize::tagQUBOX..................................................................................................................83CGenericFilter.........................................................................................................................................92

CBilinearFilter..................................................................................................................................16CBlackmanFilter..............................................................................................................................17CBoxFilter........................................................................................................................................26CGaussianFilter................................................................................................................................91CHammingFilter...............................................................................................................................94

CHandTracker.........................................................................................................................................95CImageViewerApp..................................................................................................................................96CIntensityDlg........................................................................................................................................107CLightnessDlg.......................................................................................................................................112CMainFrame..........................................................................................................................................113ContributionType..................................................................................................................................116COptionsPage1......................................................................................................................................117COptionsPage2......................................................................................................................................118COptionsPage3......................................................................................................................................119CPalViewDlg.........................................................................................................................................120CPicDecoder..........................................................................................................................................124

CAnyPicDecoder..............................................................................................................................12CBmpDecoder..................................................................................................................................22CGIFDecoder...................................................................................................................................93CJPEGDecoder...............................................................................................................................108CPCXDecoder................................................................................................................................121CPGMDecoder...............................................................................................................................122CPictDecoder.................................................................................................................................129CPNGDecoder................................................................................................................................132CTGADecoder...............................................................................................................................141CTIFFDecoder...............................................................................................................................147

CPicEncoder..........................................................................................................................................127CBmpEncoder..................................................................................................................................25CJPEGEncoder...............................................................................................................................110CPNGEncoder................................................................................................................................134CTIFFEncoder................................................................................................................................149

CTIFFEncoderEx....................................................................................................................150CPixel32................................................................................................................................................131CPreviewFileDlg...................................................................................................................................135CRenameFileDlg...................................................................................................................................136

4

CRotateDlg............................................................................................................................................138CTextException.....................................................................................................................................139CThresholdDlg......................................................................................................................................146CTimestampDlg....................................................................................................................................152CZoomView..........................................................................................................................................158

CImageViewerView.......................................................................................................................102datasink_dest_mgrDIBINFO...............................................................................................................................................162IProgressNotification.............................................................................................................................163

CImageViewerDoc...........................................................................................................................98LineContribType...................................................................................................................................164MacPatternMacpixMapMacPointMacRectMacRGBColourMemSrcTIFFInfoOpDef....................................................................................................................................................165PALETTEINFOtagPCXHEADER..................................................................................................................................166tagWINBITMAPFILEHEADERtagWINBITMAPINFOtagWINBITMAPINFOHEADERtagWINRGBQUAD

5

ImageViewer Compound Index

ImageViewer Compound ListHere are the classes, structs, unions and interfaces with brief descriptions:

C2PassScale< FilterClass, DataClass > (Used to scale an image using a 2 pass method) ................9CAnyBmp (Manipulates uncompressed device- and platform-independent bitmaps) ..................10CAnyPicDecoder (Class which decodes pictures with any known format. It) ...............................12CAppOptions (Holds user defined options for operating the application) .....................................14CBilinearFilter (Defines a bilinear filter) ...........................................................................................16CBlackmanFilter (Defines a Blackmann filter) .................................................................................17CBmp (Device- and OS-independent bitmap class. Manipulates uncompressed bitmaps of all color depths) ..........................................................................................................................................18CBmpDecoder (Windows bitmap file decoder. Decodes bitmap files (compressed and uncompressed) of all bit depths. Returns an 8 or 32 bpp bitmap) ...................................................22CBmpEncoder (BMP file encoder) .....................................................................................................25CBoxFilter (Defines a box filter) .........................................................................................................26CContrastDlg (This dialog interfaces between the user's input and the CFilterContrast class) . .27CCopyMoveDlg (This class is used to rename or copy the current image) ....................................28CCropFilterDlg (Uses CFilterCrop in order to extract a part of the image) ..................................29CDataPaintLib32 (Helper Class for the Resample-Filter templates) ..............................................30CDataSink (This is a base class for a destination of picture data) ...................................................31CDataSource (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) ..............................................................................................................................33CDIBSection (This is a windows DIBSection wrapped in a CBmp-derived class) .........................35CDIBSectionLite (CDIBSectionLite is DIBSection wrapper class for win32 and WinCE platforms) ..............................................................................................................................................38CDibSequence (This class implements the slide show mechanism of ImageViewer) .....................63CDIBStatic (This class is used to display a static DIB (in a preview dialog etc.)) ..........................65CDitherDialog (This dialog interfaces between the user's input and the CFilterQuantize class) 66CDocManagerEx (This class replaces the default CDocManager class provided by MFC. It is used to show an image preview pane inside the file open dialog) ....................................................68CFileSink (This is a class which takes a file as a destination of picture data) ................................69CFileSource (This is a class which takes a file as a source of picture data) ....................................70CFilter (Base class for filters that operate on bitmaps. Derived classes need to override either the ApplyInPlace or the Apply function) ..................................................................................................71CFilterContrast (Enhances or reduces the image contrast using a linear mapping between input and output) ............................................................................................................................................73CFilterCrop (Filter that cuts part of the image off) ..........................................................................75CFilterDialog (This dialog interfaces between the user's input and the CFilterResizeBilinear/ CFilterResizeBox/CFilterResizeGaussian/CFilterResizeHamming) ...............................................76CFilterGetAlpha (Returns an 8 bpp grayscale bitmap containing only the alpha channel of the source bitmap) ......................................................................................................................................77CFilterGrayscale (Creates a grayscale version of the bitmap) ........................................................78CFilterIntensity (Changes the intensity of a bitmap image) ............................................................79

6

CFilterLightness (Filter that changes the lightness of a bitmap image) ..........................................80CFilterQuantize (Returns an 8 bpp bitmap containing a best-fit representation of the source 32 bpp bitmap) ...........................................................................................................................................81CFilterQuantize::tagQUBOX (Local structs defining the quantization buffer) ............................83CFilterResize (Base class for filters that resize the image) ...............................................................84CFilterResizeBilinear (Resizes a bitmap using bilinear interpolation) ...........................................85CFilterResizeBox (Resizes a bitmap and applies a box filter to it) ..................................................86CFilterResizeGaussian (Resizes a bitmap and applies a gaussian blur to it) .................................87CFilterResizeHamming (Resizes a bitmap and applies a hamming filter to it) .............................88CFilterRotate (Rotates a bitmap by angle radians) ..........................................................................89CFilterThreshold (Returns an 8 bpp grayscale bitmap) ...................................................................90CGaussianFilter (Defines a Gaussian filter) ......................................................................................91CGenericFilter (Base class for alll types of filters) ............................................................................92CGIFDecoder (This class implements the GIF decoder for the application) .................................93CHammingFilter (Defines a Hamming filter) ....................................................................................94CHandTracker (This class implemets the rubber band hand mechanism for panning images) . .95CImageViewerApp (This is the project's main application class) ...................................................96CImageViewerDoc (This is the application document object) .........................................................98CImageViewerView (This is the application frame view object) ...................................................102CIntensityDlg (This dialog interfaces between the user's input and the intensity filter) ............107CJPEGDecoder (JPEG file decoder. Uses the independent JPEG group's library to do the actual conversion) ..........................................................................................................................................108CJPEGEncoder (JPEG file encoder. Uses the independent JPEG group's library to do the actual conversion) ..........................................................................................................................................110CLightnessDlg (This dialog interfaces between the user's input and the lightness filter) ...........112CMainFrame (Functionality of a Windows single document interface (SDI)) .............................113CMemSource (This is a class which takes a memory pointer as a source of picture data) .........115ContributionType (Contirbution information for a single pixel) ..................................................116COptionsPage1 (This class implements the first page of ImageViewer options tabbed panes. This page represents the Viewer properties) ............................................................................................117COptionsPage2 (This class implements the second page of ImageViewer options tabbed panes. This page represents the Slide Show properties) .............................................................................118COptionsPage3 (This class implements the third page of ImageViewer options tabbed panes. This page represents the filing (as in "file") properties) ................................................................119CPalViewDlg (This class implements a dialog that displays the current image palette. It contains a 16x16 color matrix, in which each element represents a single palette color) ...........................120CPCXDecoder (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) ..................121CPGMDecoder (Portable Graymap file decoder. Delivers an 8 bpp grayscale image) ...............122CPicDecoder (CPicDecoder is an abstract base class. It defines common routines for all decoders) ..............................................................................................................................................124CPicEncoder (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) ................................................................................127CPictDecoder (This class decodes macintosh PICT files with 1,2,4,8,16 and 32 bits per pixel as well as PICT/JPEG) ...........................................................................................................................129CPixel32 (32 bit pixel class. A pixel in this class contains 8 bits each of) ......................................131

7

CPNGDecoder (PNG file decoder. Uses LibPng to do the actual decoding) ................................132CPNGEncoder (PNG file encoder. Uses LIBPNG to do the actual conversion) ..........................134CPreviewFileDlg (This dialog replaces the good old MFC's CFileDialog. It adds a preview pane for a chosen image in list) ..................................................................................................................135CRenameFileDlg (This class implements the file renaming dialog) ..............................................136CResourceSource (This is a class which takes a windows resource as a source of picture data) ...............................................................................................................................................................137CRotateDlg (This dialog interfaces between the user's input and the rotate filter) .....................138CTextException (An object of this class is thrown by other classes when an error occurs) .......139CTGADecoder (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) ..................141CThresholdDlg (This dialog interfaces between the user's input and the threshold filter) ........146CTIFFDecoder (TIFF file decoder. Uses LIBTIFF to do the actual conversion. Supports 1, 8 and 24 bits per pixel as output formats) ..................................................................................................147CTIFFEncoder (TIFF file encoder. Uses LIBTIFF to do the actual conversion) ........................149CTIFFEncoderEx (CTIFFEncoder is provided in order to have greater compress/data control) ...............................................................................................................................................................150CTimestampDlg (This dialog implements the Change Timestamp feature of a given image filename) ..............................................................................................................................................152CVideoInvertFilter (This filter inverts a given CBmp. Only works for 32 bpp bitmaps at the moment) ...............................................................................................................................................153CWinBmp (This is the windows version of CBmp) .........................................................................154CZoomView (This is the application zoom frame view object. It can handle various zooming procedures such as: zooming in, zooming out, box zooming etc) ...................................................158DIBINFO (Holds DIB information) ..................................................................................................162IProgressNotification (Used to implement a progress indicator when opening image files) .......163LineContribType (Contribution information for an entire line (row or column)) ......................164OpDef (Table of the first 200 or so PICT opcodes with size & description. Mostly stolen from pict2pbm. I hope they don't mind) ....................................................................................................165tagPCXHEADER (PCX Image File) ................................................................................................166

8

ImageViewer Class Documentation

C2PassScale Class Template ReferenceUsed to scale an image using a 2 pass method. #include <2PassScale.h>

Public Types typedef DataClass::_DataType _DataType typedef DataClass::_RowType _RowType

Public Methods C2PassScale (double Radius, ProgressAnbAbortCallBack callback=NULL) virtual ~C2PassScale () _RowType * Scale (_RowType *pOrigImage, UINT uOrigWidth, UINT uOrigHeight, _RowType *pDstImage, UINT uNewWidth, UINT uNewHeight)

Private Methods LineContribType * AllocContributions (UINT uLineLength, UINT uWindowSize) void FreeContributions (LineContribType *p) LineContribType * CalcContributions (UINT uLineSize, UINT uSrcSize, double dScale) void ScaleRow (_RowType *pSrc, UINT uSrcWidth, _RowType *pRes, UINT uResWidth, UINT uRow, LineContribType *Contrib) void HorizScale (_RowType *pSrc, UINT uSrcWidth, UINT uSrcHeight, _RowType *pDst, UINT uResWidth, UINT uResHeight) void ScaleCol (_RowType *pSrc, UINT uSrcWidth, _RowType *pRes, UINT uResWidth, UINT uResHeight, UINT uCol, LineContribType *Contrib) void VertScale (_RowType *pSrc, UINT uSrcWidth, UINT uSrcHeight, _RowType *pDst, UINT uResWidth, UINT uResHeight)

Private Attributes ProgressAnbAbortCallBack m_Callback BOOL m_bCanceled double m_Radius

template<class FilterClass, class DataClass> class C2PassScale< FilterClass, DataClass >

The documentation for this class was generated from the following file: 2PassScale.h

CAnyBmp Class ReferenceManipulates uncompressed device- and platform-independent bitmaps. #include <AnyBmp.h>

Inheritance diagram for CAnyBmp:

Public Methods 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 Public Methods long GetMemNeeded (LONG width, LONG height, WORD BitsPerPixel)Returns memory needed by a bitmap with the specified attributes.

long GetBitsMemNeeded (LONG width, LONG height, WORD BitsPerPixel)Returns memory needed by bitmap bits.

Protected Methods virtual void internalCreate (LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel)Create a new bitmap with uninitialized bits. (Assume no memory is allocated yet.).

virtual void freeMembers ()Delete memory allocated by member variables.

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

Protected Attributes BYTE * m_pBits

The documentation for this class was generated from the following files: AnyBmp.h AnyBmp.cpp

CAnyPicDecoder Class ReferenceClass which decodes pictures with any known format. It. #include <AnyPicDecoder.h>

Inheritance diagram for CAnyPicDecoder:

Public Methods CAnyPicDecoder ()Creates a decoder.

~CAnyPicDecoder ()Destroys the decoder.

void MakeBmp (CDataSource *pDataSrc, CBmp *pBmp, int BPPWanted)Decodes a picture in a block of memory.

Private Methods int getFileType (BYTE *pData, int DataLen)Check for file-format-specific data & return the file type if something fits.

long epsLongVal (unsigned char *p)

Private Attributes CBmpDecoder * m_pBmpDec CPictDecoder * m_pPictDec CTGADecoder * m_pTGADec CTIFFDecoder * m_pTIFFDec CJPEGDecoder * m_pJPEGDec CPNGDecoder * m_pPNGDec CPCXDecoder * m_pPCXDec CPGMDecoder * m_pPGMDec CGIFDecoder * m_pGIFDec

Detailed Description

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.

Definition at line 67 of file AnyPicDecoder.h.

The documentation for this class was generated from the following files: AnyPicDecoder.h AnyPicDecoder.cpp

CAppOptions Class ReferenceHolds user defined options for operating the application. #include <AppOptions.h>

Public Methods CAppOptions () virtual ~CAppOptions ()

Public Attributes BOOL m_bViewAllImagesView all images in current folder when user chooses a file.

BOOL m_bExitAfterDeleteExit after a delete/move procedure.

BOOL m_bViewFullFilePathView full file path in status bar.

BOOL m_bViewMenuView menu.

BOOL m_bViewStatusBarView status bar.

BOOL m_bViewToolBarView tool bar.

UINT m_nDelaySlide show delay between images.

int m_iSlideShowSequence BOOL m_bSlideShowWrapGo to first image when reaching end of slide show1.

CString m_strSeparatorA char to be used as a separator when using auto-rename.

int m_iMoveCopyConfirm BOOL m_bNoConfirmDelete a file without confirmation.

BOOL m_bNoRecycleBin

Don't use the recycle bin when deleting.

BOOL m_bSkipIdenticalWhen copying/moving duplicate file, skip identical.

Member Data Documentation

int CAppOptions::m_iMoveCopyConfirmWhen copying/moving duplicate files:

Replace (0) Ask (1)

Definition at line 52 of file AppOptions.h.

int CAppOptions::m_iSlideShowSequenceSlide show advancing method:

Forward (0) Reverse (1) Random (2)

Definition at line 41 of file AppOptions.h.

The documentation for this class was generated from the following files: AppOptions.h AppOptions.cpp

CBilinearFilter Class ReferenceDefines a bilinear filter. #include <2PSFilters.h>

Inheritance diagram for CBilinearFilter:

Public Methods CBilinearFilter (double dWidth=1.0) virtual ~CBilinearFilter () virtual double Filter (double dVal)Pure virtual function - implements the filter operation.

The documentation for this class was generated from the following file: 2PSFilters.h

CBlackmanFilter Class ReferenceDefines a Blackmann filter. #include <2PSFilters.h>

Inheritance diagram for CBlackmanFilter:

Public Methods CBlackmanFilter (double dWidth=0.5) virtual ~CBlackmanFilter () virtual double Filter (double dVal)Pure virtual function - implements the filter operation.

The documentation for this class was generated from the following file: 2PSFilters.h

CBmp Class ReferenceDevice- and OS-independent bitmap class. Manipulates uncompressed bitmaps of all color depths. #include <Bmp.h>

Inheritance diagram for CBmp:

Public Methods 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) CPoint CreateRotatedCopyPoint (CBmp &rSrcBmp, double angle, CPixel32 color, CPoint Point, CPoint 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 ()=0Returns number of bytes used per line.

CPixel32 * GetPalette () constReturns 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 () constReturns 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.

bool IsLocked () const

Protected Methods virtual void internalCreate (LONG Width, LONG Height, WORD BitsPerPixel, BOOL bAlphaChannel)=0Create a new bitmap with uninitialized bits. (Assume no memory is allocated yet.).

virtual void freeMembers ()=0Delete memory allocated by member variables.

virtual void initLineArray ()=0Initialize 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.

void create32BPPCopy (const CBmp &rSrcBmp) void create8BPPCopy (const CBmp &rSrcBmp) void create1BPPCopy (const CBmp &rSrcBmp)

Protected Attributes int m_Width int m_Height WORD m_bpp CPixel32 * m_pClrTab BOOL m_bAlphaChannel BYTE ** m_pLineArray int m_LockCount int m_DitherType int m_DitherPaletteType

Detailed Description

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.

Definition at line 31 of file Bmp.h.

The documentation for this class was generated from the following files: Bmp.h Bmp.cpp

CBmpDecoder Class ReferenceWindows bitmap file decoder. Decodes bitmap files (compressed and uncompressed) of all bit depths. Returns an 8 or 32 bpp bitmap. #include <BmpDecoder.h>

Inheritance diagram for CBmpDecoder:

Public Methods CBmpDecoder ()Creates a decoder.

virtual ~CBmpDecoder ()Destroys a decoder.

Protected Methods virtual void DoDecode (CBmp *pBmp, CPixel32 **ppPal, int *pDestBPP, CDataSource *pDataSrc)Does the actual decoding of bitmap data.

Private Methods WINBITMAPINFOHEADER * getInfoHeader (CDataSource *pDataSrc, CPixel32 **ppPal)Decodes the bitmap file & info headers.

void decode1bpp (CDataSource *pDataSrc, CBmp *pBmp, int DestBPP)Decodes a 2-color bitmap. Ignores the palette & just uses black & white as 'colors'.

void decode2bpp (CDataSource *pDataSrc, CBmp *pBmp, CPixel32 *pPal, int DestBPP)Decodes an uncompressed 4-color-bitmap - my addon - WinCE customized.

void decode4bpp (CDataSource *pDataSrc, CBmp *pBmp, CPixel32 *pPal, int DestBPP)Decodes an uncompressed 16-color-bitmap.

void decode8bpp (CDataSource *pDataSrc, CBmp *pBmp, CPixel32 *pPal, int DestBPP)Decodes an uncompressed 256-color-bitmap.

void decodeRLE4 (CDataSource *pDataSrc, CBmp *pBmp, CPixel32 *pPal, int DestBPP)Decodes a compressed 16-color-bitmap.

void decodeRLE8 (CDataSource *pDataSrc, CBmp *pBmp, CPixel32 *pPal, int DestBPP)Decodes a compressed 256-color-bitmap.

void decodeHiColor (CDataSource *pDataSrc, CBmp *pBmp, WINBITMAPINFOHEADER *pBMI) void decodeTrueColor (CDataSource *pDataSrc, CBmp *pBmp, int SrcBPP)Decodes true-color bitmap.

void decode15bppLine (CDataSource *pDataSrc, CBmp *pBmp, BYTE *pDest) void decode16bppLine (CDataSource *pDataSrc, CBmp *pBmp, BYTE *pDest) void decode24bppLine (CDataSource *pDataSrc, CBmp *pBmp, BYTE *pDest) void decode32bppLine (CDataSource *pDataSrc, CBmp *pBmp, BYTE *pDest) void decode2Nibbles (BYTE *pDest, BYTE SrcByte, CPixel32 *pPal, int DestBPP)Decodes two 4-bit pixels using a palette & puts them in pDest and pDest+4.

int readPalette (WINBITMAPINFOHEADER *pBMI, CDataSource *pDataSrc, CPixel32 **ppPal)Makes a private copy of the palette in the file and sets the alpha channel. Returns the size of the palette in bytes.

Member Function Documentation

int CBmpDecoder::readPalette (WINBITMAPINFOHEADER * pBMI, CDataSource * pDataSrc, CPixel32 ** ppPal) [private]

Parameters: pBMI Pointer to bitmapinfoheader in file.

Definition at line 858 of file BmpDecoder.cpp.

Referenced by decode2Nibbles().

863 {864 Trace (3, "Reading palette.\n");865 int i;866 867 int NumColors;868 if (pBMI->biClrUsed == 0)869 NumColors = 1<<(pBMI->biBitCount);870 else871 NumColors = pBMI->biClrUsed;872 873 WINRGBQUAD * pFilePal = (WINRGBQUAD *) pDataSrc->ReadNBytes874 (NumColors*sizeof (WINRGBQUAD));875 *ppPal = new CPixel32 [256];

876 // Correct the byte ordering & copy the data.877 for (i=0; i<NumColors; i++)878 {879 (*ppPal)[i].Set (pFilePal[i].rgbRed, pFilePal[i].rgbGreen, 880 pFilePal[i].rgbBlue, 0xFF);881 }882 883 return NumColors*4;884 }

The documentation for this class was generated from the following files: BmpDecoder.h BmpDecoder.cpp

CBmpEncoder Class ReferenceBMP file encoder. #include <BmpEncoder.h>

Inheritance diagram for CBmpEncoder:

Public Methods CBmpEncoder ()Creates an encoder.

~CBmpEncoder ()Destroys a encoder.

Protected Methods void DoEncode (CBmp *pBmp, CDataSink *pDataSink)encodes in bmp format.

int GetLineMemNeeded (LONG width, WORD BitsPerPixel)Gets the memory needed for one line of the image.

The documentation for this class was generated from the following files: BmpEncoder.h BmpEncoder.cpp

CBoxFilter Class ReferenceDefines a box filter. #include <2PSFilters.h>

Inheritance diagram for CBoxFilter:

Public Methods CBoxFilter (double dWidth=0.5) virtual ~CBoxFilter () virtual double Filter (double dVal)Pure virtual function - implements the filter operation.

The documentation for this class was generated from the following file: 2PSFilters.h

CContrastDlg Class ReferenceThis dialog interfaces between the user's input and the CFilterContrast class. #include <ContrastDlg.h>

Public Types enum { IDD = IDD_CONTRAST }

Public Methods CContrastDlg (CWnd *pParent=NULL) BYTE GetOffset ()Returns the offset (intensity at which the color stays the same).

double GetContrast ()Return the contrast (the slope of the function).

Public Attributes int m_OffsetOffset is the intensity at which the color stays the same.

double m_ContrastContrast is the slope of the function.

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

The documentation for this class was generated from the following files: ContrastDlg.h ContrastDlg.cpp

CCopyMoveDlg Class ReferenceThis class is used to rename or copy the current image. #include <CopyMoveDlg.h>

Public Types enum { IDD = IDD_COPYMOVEFILE }

Public Methods CCopyMoveDlg (CWnd *pParent=NULL) void SetFilename (const CString &strFilename, bool bCopy)This method is used in order to fill the target filename editbox with existing file.

Public Attributes CComboBox m_ctrlExistsCombo CString m_strFilename CString m_strDestDir CString m_strSourceDir int m_iExists

Protected Types enum { Replace, Ask }

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual BOOL OnInitDialog () afx_msg void OnBrowse () virtual void OnOK ()

Protected Attributes bool m_bCopySets the behaviour of this dialog: - true - Copy dialog - false - Move dialog.

The documentation for this class was generated from the following files: CopyMoveDlg.h CopyMoveDlg.cpp

CCropFilterDlg Class ReferenceUses CFilterCrop in order to extract a part of the image. #include <CropFilterDlg.h>

Public Types enum { IDD = IDD_CROPFILTER }

Public Methods void SetParams (CRect rcBounder)Define an initial bounding rectangle (using a marquee)

Parameters: rcBounder The initial bounding rectangle.

CCropFilterDlg (CWnd *pParent=NULL)

Public Attributes int m_XMax int m_XMin int m_YMax int m_YMin

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual void OnOK ()

The documentation for this class was generated from the following files: CropFilterDlg.h CropFilterDlg.cpp

CDataPaintLib32 Class ReferenceHelper Class for the Resample-Filter templates. #include <2PassScale.h>

Public Types typedef unsigned char _DataType [4] typedef _DataType * _RowType

The documentation for this class was generated from the following file: 2PassScale.h

CDataSink Class ReferenceThis is a base class for a destination of picture data. #include <DataSink.h>

Inheritance diagram for CDataSink:

Public Methods void Open (const CString pszName, BYTE *pData, size_t MaxDataSize)Opens a data sink source.

virtual void Close () CString 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 Methods CDataSink () virtual ~CDataSink ()

Protected Attributes BYTE * m_pStartData int m_nCurPos

Private Attributes CString m_pszNameName of the data source for diagnostic purposes.

size_t m_nMaxFileSize

Friends class CTIFFEncoder class CTIFFEncoderEx

The documentation for this class was generated from the following files: DataSink.h DataSink.cpp

CDataSource Class ReferenceThis 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. #include <DataSource.h>

Inheritance diagram for CDataSource:

Public Methods CDataSource (IProgressNotification *pNotification=NULL)Adds a notification object to current object.

virtual ~CDataSource () virtual void Open (CString pszName, int FileSize) virtual void Close () CString GetName () virtual BYTE * GetBufferPtr (int MinBytesInBuffer)=0Read but don't advance file pointer.

virtual BYTE * ReadNBytes (int n)This needs to be overridden in derived classes.

int GetFileSize () virtual BYTE * ReadEverything ()=0This 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.

Private Attributes CString m_pszName

Name of the data source for diagnostic purposes.

int m_FileSize int m_BytesRead BOOL m_bSrcLSBFirstSource byte order: - TRUE for intel order, - FALSE for Motorola et al. (MSB first).

IProgressNotification * m_pNotification

The documentation for this class was generated from the following files: DataSource.h DataSource.cpp

CDIBSection Class ReferenceThis is a windows DIBSection wrapped in a CBmp-derived class. #include <DIBSection.h>

Inheritance diagram for CDIBSection:

Public Methods 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.

BOOL SetColorTable (HDC hdc, UINT uStartIndex, UINT cEntries, CONST RGBQUAD *pColors)

Static Public Methods int NumColorEntries (int nBitsPerPixel, int nCompression, DWORD biClrUsed=0)

Protected Methods 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 CDIBSection from an existing bitmap pointer. 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.

Private Attributes HBITMAP m_hBitmap BOOL m_bOwnsBitmap

Member Function Documentation

BOOL CDIBSection::SetColorTable (HDC hdc, UINT uStartIndex, UINT cEntries, CONST RGBQUAD * pColors)

Parameters: hdc handle to DC uStartIndex color table index of first entry cEntries number of color table entries pColors array of color table entries

Definition at line 368 of file DIBSection.cpp.

References CWinBmp::m_pBMI.

374 {375 unsigned int iColorTableSize = NumColorEntries(m_pBMI->biBitCount, m_pBMI->biCompression, m_pBMI->biClrUsed);376 377 if (!m_hBitmap || !pColors || !(cEntries-uStartIndex) || iColorTableSize == 0 || cEntries > 256)378 return FALSE;379 380 LPRGBQUAD pColorTable = ((BITMAPINFO *)m_pBMI)->bmiColors;381 ASSERT(pColorTable);382 383 384 int nCount = min(iColorTableSize, (cEntries-uStartIndex));385 ::memset(pColorTable, 0, iColorTableSize*sizeof(RGBQUAD));386 ::memcpy(pColorTable, pColors, nCount*sizeof(RGBQUAD));387 388 return TRUE;389 }

The documentation for this class was generated from the following files: DIBSection.h DIBSection.cpp

CDIBSectionLite Class ReferenceCDIBSectionLite is DIBSection wrapper class for win32 and WinCE platforms. #include <DIBSectionLite.h>

Public Methods CDIBSectionLite () virtual ~CDIBSectionLite () void DeleteObject ()Resets the object to an empty state, and frees all memory used.

HBITMAP GetSafeHandle () const operator HBITMAP () const CSize GetSize () const int GetHeight () const int GetWidth () const int GetPlanes () const int GetBitCount () const LPVOID GetDIBits () LPBITMAPINFO GetBitmapInfo () DWORD GetImageSize () const LPBITMAPINFOHEADER GetBitmapInfoHeader () LPRGBQUAD GetColorTable () BOOL SetColorTable (UINT nNumColors, RGBQUAD *pColors) int GetColorTableSize () CPalette * GetPalette () BOOL SetPalette (CPalette *pPalette) BOOL SetLogPalette (LOGPALETTE *pLogPalette) BOOL SetBitmap (UINT nIDResource) BOOL SetBitmap (LPCTSTR lpszResourceName) BOOL SetBitmap (HBITMAP hBitmap, CPalette *pPalette=NULL) BOOL SetBitmap (LPBITMAPINFO lpBitmapInfo, LPVOID lpBits) BOOL Load (LPCTSTR lpszFileName) BOOL Save (LPCTSTR lpszFileName) BOOL Copy (CDIBSectionLite &Bitmap) BOOL Draw (CDC *pDC, CPoint ptDest, BOOL bForceBackground=FALSE) BOOL Stretch (CDC *pDC, CPoint ptDest, CSize size, BOOL bForceBackground=FALSE) BOOL SetDither (BOOL bDither) BOOL GetDither () CDC * GetMemoryDC (CDC *pDC=NULL, BOOL bSelectPalette=TRUE) BOOL ReleaseMemoryDC (BOOL bForceRelease=FALSE)

Static Public Methods int BytesPerLine (int nWidth, int nBitsPerPixel) int NumColorEntries (int nBitsPerPixel, int nCompression, DWORD biClrUsed=0) BOOL UsesPalette (CDC *pDC) BOOL CreateHalftonePalette (CPalette &palette, int nNumColors)

Static Public Attributes RGBQUAD ms_StdColors []

Protected Methods void _ShowLastError () BOOL CreatePalette () BOOL FillDIBColorTable (UINT nNumColors, RGBQUAD *pRGB) UINT GetColorTableEntries (HDC hdc, HBITMAP hBitmap) HDRAWDIB GetDrawDibContext ()

Protected Attributes HBITMAP m_hBitmap DIBINFO m_DIBinfo VOID * m_ppvBits UINT m_iColorDataType UINT m_iColorTableSize CDC m_MemDC BOOL m_bDither HDRAWDIB m_hDrawDib CPalette m_Palette CPalette * m_pOldPalette

Private Attributes HBITMAP m_hOldBitmap

Detailed Description

Properties: NO Abstract class (does not have any objects) NO Derived from CWnd NO Is a CWnd. NO Two stage creation (constructor & Create()) NO Has a message map NO Needs a resource (template) YES Persistent objects (saveable on disk) YES Uses exceptions //////////////////////////////////////////////////////////////////////// Desciption : CDIBSectionLite is DIBSection wrapper class for win32 and WinCE platforms. This class provides a simple interface to DIBSections including loading, saving and displaying DIBsections.

Full palette support is provided for Win32 and CE 2.11 and above. Using CDIBSectionLite :This class is very simple to use. The bitmap can be set using either SetBitmap() (which accepts either a Device dependant or device independant bitmap, or a resource ID) or by using Load(), which allows an image to be loaded from disk. To display the bitmap simply use Draw or Stretch.eg.

CDIBsection dibsection; dibsection.Load(_T("image.bmp")); dibsection.Draw(pDC, CPoint(0,0)); // pDC is of type CDC*CDIBsection dibsection; dibsection.SetBitmap(IDB_BITMAP); dibsection.Draw(pDC, CPoint(0,0)); // pDC is of type CDC*The CDIBsection API includes many methods to extract information about the image, as well as palette options for getting and setting the current palette.

Definition at line 111 of file DIBSectionLite.h.

Member Function Documentation

int CDIBSectionLite::BytesPerLine (int nWidth, int nBitsPerPixel) [static]

Parameters: nWidth Image width in pixels nBitsPerPixel bits per pixel

Returns: Returns the number of storage bytes needed for each scanline in the bitmap

Definition at line 363 of file DIBSectionLite.cpp.

Referenced by GetColorTableEntries(), Load(), and SetBitmap().

364 {365 return ( (nWidth * nBitsPerPixel + 31) & (~31) ) / 8;366 }

BOOL CDIBSectionLite::Copy (CDIBSectionLite & Bitmap)Creates a copy of another CDIBSection object

Parameters: Bitmap DIBSection object to be copied

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 1167 of file DIBSectionLite.cpp.

References CreatePalette(), GetBitmapInfo(), GetColorTable(), GetColorTableSize(), GetDIBits(), GetDither(), SetBitmap(), SetColorTable(), and SetDither().

1168 { 1169 BOOL bResult = SetBitmap(Bitmap.GetBitmapInfo(), Bitmap.GetDIBits()); 1170 1171 if (bResult)1172 {

1173 SetColorTable(Bitmap.GetColorTableSize(), Bitmap.GetColorTable());1174 #ifndef DIBSECTION_NO_PALETTE1175 CreatePalette();1176 #endif1177 #ifndef DIBSECTION_NO_DITHER1178 SetDither(Bitmap.GetDither());1179 #endif1180 }1181 1182 return bResult;1183 }

BOOL CDIBSectionLite::CreateHalftonePalette (CPalette & palette, int nNumColors) [static]

Creates a halftone color palette independant of screen color depth. palette will be filled with the colors, and nNumColors is the No. of colors to file. If nNumColorsis 0 or > 256, then 256 colors are used.Parameters:

palette reference to a palette object which will be filled nNumColors number of color entries to fill

Returns: TRUE on success, false otherwise

Definition at line 380 of file DIBSectionLite.cpp.

Referenced by CreatePalette().

381 {382 palette.DeleteObject();383 384 // Sanity check on requested number of colours.385 if (nNumColors <= 0 || nNumColors > 256)386 nNumColors = 256;387 else if (nNumColors <= 2)388 nNumColors = 2;389 else if (nNumColors <= 16)390 nNumColors = 16;391 else if (nNumColors <= 256)392 nNumColors = 256;393 394 PALETTEINFO pi; 395 pi.palNumEntries = (WORD) nNumColors;396 397 if (nNumColors == 2)398 {399 // According to the MS article "The Palette Manager: How and Why"400 // monochrome palettes not really needed (will use B&W)401 pi.palPalEntry[0].peRed = ms_StdColors[0].rgbRed;402 pi.palPalEntry[0].peGreen = ms_StdColors[0].rgbGreen;403 pi.palPalEntry[0].peBlue = ms_StdColors[0].rgbBlue;404 pi.palPalEntry[0].peFlags = 0;405 pi.palPalEntry[1].peRed = ms_StdColors[255].rgbRed;406 pi.palPalEntry[1].peGreen = ms_StdColors[255].rgbGreen;407 pi.palPalEntry[1].peBlue = ms_StdColors[255].rgbBlue;408 pi.palPalEntry[1].peFlags = 0;409 }410 else if (nNumColors == 16)411 {412 // According to the MS article "The Palette Manager: How and Why"413 // 4-bit palettes not really needed (will use VGA palette)414 for (int i = 0; i < 8; i++)415 {416 pi.palPalEntry[i].peRed = ms_StdColors[i].rgbRed;

417 pi.palPalEntry[i].peGreen = ms_StdColors[i].rgbGreen;418 pi.palPalEntry[i].peBlue = ms_StdColors[i].rgbBlue;419 pi.palPalEntry[i].peFlags = 0;420 }421 for (i = 8; i < 16; i++)422 {423 pi.palPalEntry[i].peRed = ms_StdColors[248+i].rgbRed;424 pi.palPalEntry[i].peGreen = ms_StdColors[248+i].rgbGreen;425 pi.palPalEntry[i].peBlue = ms_StdColors[248+i].rgbBlue;426 pi.palPalEntry[i].peFlags = 0;427 }428 }429 else // if (nNumColors == 256)430 {431 // Fill palette with full halftone palette432 for (int i = 0; i < 256; i++)433 {434 pi.palPalEntry[i].peRed = ms_StdColors[i].rgbRed;435 pi.palPalEntry[i].peGreen = ms_StdColors[i].rgbGreen;436 pi.palPalEntry[i].peBlue = ms_StdColors[i].rgbBlue;437 pi.palPalEntry[i].peFlags = 0;438 }439 }440 441 return palette.CreatePalette((LPLOGPALETTE) pi);442 }

BOOL CDIBSectionLite::CreatePalette () [protected]Creates the palette from the DIBSection's color table. Assumes m_iColorTableSize has been set and the DIBsection m_hBitmap created

Returns: Returns TRUE on success

Definition at line 1232 of file DIBSectionLite.cpp.

References CreateHalftonePalette().

Referenced by Copy(), GetMemoryDC(), SetBitmap(), and SetLogPalette().

1233 {1234 m_Palette.DeleteObject();1235 1236 if (!m_hBitmap)1237 return FALSE;1238 1239 // Create a 256 color halftone palette if there is no color table in the DIBSection1240 if (m_iColorTableSize == 0)1241 return CreateHalftonePalette(m_Palette, 256);1242 1243 // Get space for the color entries1244 RGBQUAD *pRGB = new RGBQUAD[m_iColorTableSize];1245 if (!pRGB)1246 return CreateHalftonePalette(m_Palette, m_iColorTableSize);1247 1248 HDC hDC = ::GetDC(NULL);1249 if (!hDC)1250 {1251 delete [] pRGB;1252 return FALSE;1253 }1254

1255 // Create a memory DC compatible with the current DC1256 CDC MemDC;1257 MemDC.CreateCompatibleDC(CDC::FromHandle(hDC));1258 if (!MemDC.GetSafeHdc())1259 {1260 delete [] pRGB;1261 ::ReleaseDC(NULL, hDC);1262 return CreateHalftonePalette(m_Palette, m_iColorTableSize);1263 }1264 ::ReleaseDC(NULL, hDC);1265 1266 HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(MemDC.GetSafeHdc(), m_hBitmap);1267 if (!hOldBitmap)1268 {1269 delete [] pRGB;1270 return CreateHalftonePalette(m_Palette, m_iColorTableSize);1271 }1272 1273 // Get the colors used. WinCE does not support GetDIBColorTable so if you1274 // are using this on a CE device with palettes, then you need to replace1275 // the call with code that manually gets the color table from the m_DIBinfo structure.1276 #ifdef _WIN32_WCE1277 int nColors = ::CEGetDIBColorTable(MemDC.GetSafeHdc(), 0, m_iColorTableSize, pRGB);1278 #else1279 int nColors = ::GetDIBColorTable(MemDC.GetSafeHdc(), 0, m_iColorTableSize, pRGB);1280 #endif1281 1282 // Clean up1283 ::SelectObject(MemDC.GetSafeHdc(), hOldBitmap);1284 1285 if (!nColors) // No colors retrieved => the bitmap in the DC is not a DIB section1286 {1287 delete [] pRGB;1288 return CreateHalftonePalette(m_Palette, m_iColorTableSize);1289 } 1290 1291 // Create and fill a LOGPALETTE structure with the colors used.1292 PALETTEINFO PaletteInfo;1293 PaletteInfo.palNumEntries = m_iColorTableSize;1294 1295 for (int i = 0; i < nColors; i++)1296 {1297 PaletteInfo.palPalEntry[i].peRed = pRGB[i].rgbRed;1298 PaletteInfo.palPalEntry[i].peGreen = pRGB[i].rgbGreen;1299 PaletteInfo.palPalEntry[i].peBlue = pRGB[i].rgbBlue;1300 PaletteInfo.palPalEntry[i].peFlags = 0;1301 }1302 1303 delete [] pRGB;1304 1305 // Create Palette!1306 return m_Palette.CreatePalette(&PaletteInfo);1307 }

BOOL CDIBSectionLite::Draw (CDC * pDC, CPoint ptDest, BOOL bForceBackground = FALSE)

Draws the image 1:1 on the device contextParameters:

pDC Pointer to a device context ptDest Point at which the topleft corner of the image is drawn

Returns: TRUE on success

Definition at line 592 of file DIBSectionLite.cpp.

References GetDrawDibContext(), GetMemoryDC(), and ReleaseMemoryDC().

593 { 594 if (!m_hBitmap)595 return FALSE;596 597 CSize size = GetSize();598 CPoint ptOrigin = CPoint(0,0);599 600 BOOL bResult = FALSE;601 602 #ifndef DIBSECTION_NO_DITHER603 604 HDRAWDIB hDrawDib = GetDrawDibContext();605 if (hDrawDib)606 {607 #ifndef DIBSECTION_NO_PALETTE608 DrawDibSetPalette( hDrawDib, (HPALETTE)m_Palette);609 DrawDibRealize( hDrawDib, pDC->GetSafeHdc(), FALSE);610 #endif // DIBSECTION_NO_PALETTE611 bResult = DrawDibDraw(hDrawDib, pDC->GetSafeHdc(), 612 ptDest.x, ptDest.y, size.cx, size.cy, 613 GetBitmapInfoHeader(), GetDIBits(), 614 ptOrigin.x, ptOrigin.y, size.cx, size.cy, 615 0/*DDF_HALFTONE*/);616 }617 else618 {619 #endif620 621 CDC* pMemDC = GetMemoryDC(pDC, FALSE);622 if (!pMemDC)623 return FALSE;624 625 #ifndef DIBSECTION_NO_PALETTE626 // Select and realize the palette627 CPalette* pOldPalette = NULL;628 if (m_Palette.m_hObject && UsesPalette(pDC))629 {630 pOldPalette = pDC->SelectPalette(&m_Palette, bForceBackground);631 pDC->RealizePalette();632 }633 #endif // DIBSECTION_NO_PALETTE634 635 bResult = pDC->BitBlt(ptDest.x, ptDest.y, size.cx, size.cy, pMemDC, 636 ptOrigin.x, ptOrigin.y, SRCCOPY);637 638 #ifndef DIBSECTION_NO_PALETTE639 if (pOldPalette)640 pDC->SelectPalette(pOldPalette, FALSE);641 #endif // DIBSECTION_NO_PALETTE642 643 ReleaseMemoryDC();644 #ifndef DIBSECTION_NO_DITHER645 }646 #endif // DIBSECTION_NO_DITHER647 648 return bResult;649 }

BOOL CDIBSectionLite::FillDIBColorTable (UINT nNumColors, RGBQUAD * pRGB) [protected]

Sets the colors used by the image. Only works if # colors <= 256

Parameters: nNumColors Number of colors to set pRGB Colors to fill

Returns: Returns TRUE on success

Definition at line 1385 of file DIBSectionLite.cpp.

Referenced by SetLogPalette().

1386 {1387 if (!pRGB || !nNumColors || !m_iColorTableSize || nNumColors > 256)1388 return FALSE;1389 1390 // get the number of colors to return per BITMAPINFOHEADER docs1391 UINT nColors;1392 LPBITMAPINFOHEADER pBmih = GetBitmapInfoHeader();1393 if (pBmih->biClrUsed)1394 nColors = pBmih->biClrUsed;1395 else1396 nColors = 1 << (pBmih->biBitCount*pBmih->biPlanes);1397 1398 // Initialize the loop variables1399 nColors = min(nNumColors, nColors);1400 1401 LPRGBQUAD pColorTable = GetColorTable();1402 for (UINT iColor = 0; iColor < nColors; iColor++)1403 {1404 pColorTable[iColor].rgbReserved = 0;1405 pColorTable[iColor].rgbBlue = pRGB[iColor].rgbBlue;1406 pColorTable[iColor].rgbRed = pRGB[iColor].rgbRed;1407 pColorTable[iColor].rgbGreen = pRGB[iColor].rgbGreen;1408 }1409 1410 return TRUE;1411 }

UINT CDIBSectionLite::GetColorTableEntries (HDC hdc, HBITMAP hBitmap) [protected]This function is a replacement for GetDIBits, in that it retrieves (or synthesizes) the color table from the given bitmap, and stores the values in the BITMAPINFO structure supplied.Parameters:

hdc The Device Context in which the DIBSection is selected hBitmap The bitmap whose solor entries are to be queried lpbi A pointer to a BITMAPINFO structure that will have it's color table filled.

Returns: The number of colors placed in the color table

Definition at line 1425 of file DIBSectionLite.cpp.

References BytesPerLine().Referenced by SetBitmap().

1426 {1427 #ifndef _WIN32_WCE1428 1429 // Call GetDIBits with NULL bits pointer to fill in the BITMAPINFOHEADER data1430 // Basically we are just getting the color table entries with a minimum of1431 // effort1432 if (!::GetDIBits(hdc, hBitmap, 0, GetHeight(), NULL, m_DIBinfo, m_iColorDataType))1433 {1434 TRACE0("Unable to GetDIBits\n");1435 AfxThrowResourceException();1436 }1437 1438 // If the driver did not fill in the biSizeImage field, then compute it1439 // Each scan line of the image is aligned on a DWORD (32bit) boundary1440 if (m_DIBinfo.bmiHeader.biSizeImage == 0)1441 m_DIBinfo.bmiHeader.biSizeImage = BytesPerLine(m_DIBinfo.bmiHeader.biWidth, 1442 m_DIBinfo.bmiHeader.biBitCount) 1443 * m_DIBinfo.bmiHeader.biHeight;1444 1445 return m_iColorTableSize;1446 1447 #else1448 1449 if (!m_iColorTableSize)1450 return 0;1451 1452 // Fill the color table with the colors from the bitmap's color table1453 LPRGBQUAD pColorTable = GetColorTable();1454 1455 #ifdef _WIN32_WCE1456 //DCR 4/02/01 If you are dealing with a 16bpp bitmap in PocketPC, you must1457 // set the 3 DWORD color mask. This mask will be applied to a 16bit value to find the 1458 // RGB components. Blue is lowest 5 bits, then Green, then Red.1459 if (m_DIBinfo.bmiHeader.biBitCount == 16)1460 {1461 DWORD dw[3];1462 dw[0] = 31744; //RED bitmask Bits: 0 11111 00000 000001463 dw[1] = 992; //GREEN bitmask Bits:0 00000 11111 000001464 dw[2] = 31; //BLUE bitmask Bits:0 00000 00000 111111465 memcpy(pColorTable, dw, 3*sizeof(DWORD));1466 1467 return 3;1468 }1469 #endif1470 1471 // Get the color table from the HBITMAP and copy them over.1472 UINT nCount;1473 RGBQUAD* pRGB = new RGBQUAD[m_iColorTableSize];1474 if (pRGB)1475 {1476 HBITMAP hOldBitmap = (HBITMAP) SelectObject(hdc, hBitmap);1477 nCount = CEGetDIBColorTable(hdc, 0, m_iColorTableSize, pRGB);1478 SelectObject(hdc, hOldBitmap);1479 if (nCount)1480 {1481 // m_iColorTableSize = nCount;1482 memcpy(pColorTable, pRGB, nCount*sizeof(RGBQUAD));1483 }1484 }1485 delete [] pRGB;1486 1487 // Didn't work - so synthesize one.1488 if (!nCount)1489 {

1490 nCount = min( m_iColorTableSize, sizeof(ms_StdColors) / sizeof(ms_StdColors[0]) );1491 memcpy(pColorTable, ms_StdColors, nCount*sizeof(RGBQUAD));1492 }1493 1494 return nCount;1495 #endif1496 }

BOOL CDIBSectionLite::GetDither ()Returns whether or not the DrawDib functions (and hence dithering) is being used.

Returns: TRUE if dithering is used

Definition at line 561 of file DIBSectionLite.cpp.

Referenced by Copy(), and GetDrawDibContext().

562 {563 return (m_bDither && GetBitCount() > 8);564 }

HDRAWDIB CDIBSectionLite::GetDrawDibContext () [protected]Returns a drawdib context for use with DrawDib routines.

Returns: A DrawDib context if dithering is supported, else NULL

Definition at line 570 of file DIBSectionLite.cpp.

References GetDither().

Referenced by Draw(), and Stretch().

571 {572 if (!GetDither())573 return NULL;574 575 if (m_hDrawDib)576 return m_hDrawDib;577 578 m_hDrawDib = DrawDibOpen();579 580 return m_hDrawDib;581 }

CDC * CDIBSectionLite::GetMemoryDC (CDC * pDC = NULL, BOOL bSelectPalette = TRUE)Creates a memory DC and selects in the current bitmap so it can be modified using the GDI functions. Only one memDC can be created for a given CDIBSectionLite object. If you have a memDC but wish to recreate it as compatible with a different DC, then call ReleaseMemoryDC first. If the memory DC

has already been created then it will be recycled. Note that if using this in an environment where the color depth of the screen may change, then you will need to set "m_bReuseMemDC" to FALSE

Parameters: pDC Device context to use when calling CreateCompatibleDC bSelectPalette If TRUE, the current palette will be preselected

Returns: A pointer to a memory DC

Definition at line 1588 of file DIBSectionLite.cpp.

References CreatePalette(), and ReleaseMemoryDC().Referenced by Draw(), and Stretch().

1589 {1590 #ifdef DIBSECTION_NO_MEMDC_REUSE1591 ReleaseMemoryDC(TRUE);1592 #else1593 if (!m_bReuseMemDC)1594 ReleaseMemoryDC(TRUE);1595 else if (m_MemDC.GetSafeHdc()) // Already created?1596 {1597 #ifndef _WIN32_WCE1598 // Flush the GDI batch queue 1599 GdiFlush();1600 #endif1601 return &m_MemDC;1602 }1603 #endif // DIBSECTION_NO_MEMDC_REUSE1604 1605 // Create a memory DC compatible with the given DC1606 if (!m_MemDC.CreateCompatibleDC(pDC))1607 return NULL;1608 1609 // Select in the bitmap1610 m_hOldBitmap = (HBITMAP) ::SelectObject(m_MemDC.GetSafeHdc(), m_hBitmap);1611 1612 #ifndef DIBSECTION_NO_PALETTE1613 // Select in the palette1614 if (bSelectPalette && UsesPalette(&m_MemDC))1615 {1616 // Palette should already have been created - but just in case...1617 if (!m_Palette.GetSafeHandle())1618 CreatePalette();1619 1620 m_pOldPalette = m_MemDC.SelectPalette(&m_Palette, FALSE);1621 m_MemDC.RealizePalette();1622 }1623 else1624 m_pOldPalette = NULL;1625 #endif // DIBSECTION_NO_PALETTE1626 1627 #ifndef _WIN32_WCE1628 // Flush the GDI batch queue 1629 GdiFlush();1630 #endif // _WIN32_WCE1631 1632 return &m_MemDC;1633 }

BOOL CDIBSectionLite::Load (LPCTSTR lpszFileName)Loads the bitmap from a bitmap file with the name lpszFileName. If failure, then object is initialised back to an empty bitmap.

Parameters: lpszFileName Image filename

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 1017 of file DIBSectionLite.cpp.

References BytesPerLine(), DIBINFO::ColorTable(), NumColorEntries(), and SetBitmap().

1018 {1019 CFile file;1020 if (!file.Open(lpszFileName, CFile::modeRead))1021 return FALSE;1022 1023 // Get the current file position. 1024 DWORD dwFileStart = file.GetPosition();1025 1026 // The first part of the file contains the file header.1027 // This will tell us if it is a bitmap, how big the header is, and how big 1028 // the file is. The header size in the file header includes the color table.1029 BITMAPFILEHEADER BmpFileHdr;1030 int nBytes;1031 nBytes = file.Read(&BmpFileHdr, sizeof(BmpFileHdr));1032 if (nBytes != sizeof(BmpFileHdr)) 1033 {1034 TRACE0("Failed to read file header\n");1035 return FALSE;1036 }1037 1038 // Check that we have the magic 'BM' at the start.1039 if (BmpFileHdr.bfType != DS_BITMAP_FILEMARKER)1040 {1041 TRACE0("Not a bitmap file\n");1042 return FALSE;1043 }1044 1045 // Read the header (assuming it's a DIB). 1046 DIBINFO BmpInfo;1047 nBytes = file.Read(&BmpInfo, sizeof(BITMAPINFOHEADER)); 1048 if (nBytes != sizeof(BITMAPINFOHEADER)) 1049 {1050 TRACE0("Failed to read BITMAPINFOHEADER\n");1051 return FALSE;1052 }1053 1054 // Check that we have a real Windows DIB file.1055 if (BmpInfo.bmiHeader.biSize != sizeof(BITMAPINFOHEADER))1056 {1057 TRACE0(" File is not a Windows DIB\n");1058 return FALSE;1059 }1060 1061 // See how big the color table is in the file (if there is one). 1062 int nColors = NumColorEntries(BmpInfo.bmiHeader.biBitCount, BmpInfo.bmiHeader.biCompression, BmpInfo.bmiHeader.biClrUsed);1063 if (nColors > 0) 1064 {1065 // Read the color table from the file.1066 int nColorTableSize = nColors * sizeof(RGBQUAD);1067 nBytes = file.Read(BmpInfo.ColorTable(), nColorTableSize);

1068 if (nBytes != nColorTableSize) 1069 {1070 TRACE0("Failed to read color table\n");1071 return FALSE;1072 }1073 }1074 1075 // So how big the bitmap surface is.1076 int nBitsSize = BmpFileHdr.bfSize - BmpFileHdr.bfOffBits;1077 1078 // Double check that the bitmap surface if ok (sometimes the file size is a1079 // little larger than the bitmap itself, which may cause overflows)1080 int nSurfaceSize = BytesPerLine(BmpInfo.bmiHeader.biWidth, 1081 BmpInfo.bmiHeader.biBitCount) * BmpInfo.bmiHeader.biHeight;1082 if (nSurfaceSize < nBitsSize)1083 {1084 // In this case we don't need the entire file1085 nBitsSize = nSurfaceSize;1086 }1087 1088 // Allocate the memory for the bits and read the bits from the file.1089 BYTE* pBits = (BYTE*) malloc(nBitsSize);1090 if (!pBits) 1091 {1092 TRACE0("Out of memory for DIB bits\n");1093 return FALSE;1094 }1095 1096 // Seek to the bits in the file.1097 file.Seek(dwFileStart + BmpFileHdr.bfOffBits, CFile::begin);1098 1099 // read the bits1100 nBytes = file.Read(pBits, nBitsSize);1101 if (nBytes != nBitsSize) 1102 {1103 TRACE0("Failed to read bits\n");1104 free(pBits);1105 return FALSE;1106 }1107 1108 // Everything went OK.1109 BmpInfo.bmiHeader.biSizeImage = nBitsSize;1110 1111 if (!SetBitmap((LPBITMAPINFO) BmpInfo, pBits))1112 {1113 TRACE0("Failed to set bitmap info\n");1114 free(pBits);1115 return FALSE;1116 }1117 1118 free(pBits);1119 1120 return TRUE;1121 }

int CDIBSectionLite::NumColorEntries (int nBitsPerPixel, int nCompression, DWORD biClrUsed = 0) [static]

Returns the number of color table entries given the number of bits per pixel of a bitmapParameters:

nBitsPerPixel bits per pixel nCompression type of compression

Returns: The number of colors for this color depth

Definition at line 313 of file DIBSectionLite.cpp.

Referenced by Load(), and SetBitmap().

314 {315 int nColors = 0;316 317 switch (nBitsPerPixel) 318 {319 case 1: 320 nColors = 2; 321 break;322 #ifdef _WIN32_WCE323 case 2: 324 nColors = 4; 325 break; // winCE only 326 #endif327 case 4: 328 nColors = 16; 329 break;330 case 8: 331 nColors = 256; 332 break;333 case 24: 334 nColors = 0;335 case 16:336 case 32:337 #ifdef _WIN32_WCE338 nColors = 3; // I've found that PocketPCs need this regardless of BI_RGB or BI_BITFIELDS339 #else340 if (nCompression == BI_BITFIELDS)341 nColors = 3; // 16 or 32 bpp have 3 colors(masks) in the color table if bitfield compression342 else343 nColors = 0; // 16 or 32 bpp have no color table if no bitfield compression344 #endif345 break;346 347 default:348 ASSERT(FALSE);349 }350 351 // If biClrUsed is provided, and it is a legal value, use it352 if (biClrUsed > 0 && biClrUsed <= (DWORD)nColors)353 return biClrUsed;354 355 return nColors;356 }

BOOL CDIBSectionLite::ReleaseMemoryDC (BOOL bForceRelease = FALSE)Selects out the current bitmap and deletes the mem dc. If bForceRelease is FALSE, then the DC release will not actually occur. This is provided so you can haveGetMemoryDC(...) ... do something ReleaseMemoryDC()

bracketed calls. If m_bReuseMemDC is subsequently set to FALSE, then the same code fragment will still work.

Parameters: bForceRelease If TRUE, then the memory DC is forcibly released

Returns: Returns TRUE on success

Definition at line 1650 of file DIBSectionLite.cpp.

Referenced by DeleteObject(), Draw(), GetMemoryDC(), and Stretch().

1651 {1652 if ( !m_MemDC.GetSafeHdc() 1653 #ifndef DIBSECTION_NO_MEMDC_REUSE1654 || (m_bReuseMemDC && !bForceRelease) 1655 #endif // DIBSECTION_NO_MEMDC_REUSE1656 )1657 return TRUE; // Nothing to do1658 1659 #ifndef _WIN32_WCE1660 // Flush the GDI batch queue 1661 GdiFlush();1662 #endif // _WIN32_WCE1663 1664 // Select out the current bitmap1665 if (m_hOldBitmap)1666 ::SelectObject(m_MemDC.GetSafeHdc(), m_hOldBitmap);1667 m_hOldBitmap = NULL;1668 1669 #ifndef DIBSECTION_NO_PALETTE1670 // Select out the current palette1671 if (m_pOldPalette)1672 m_MemDC.SelectPalette(m_pOldPalette, FALSE);1673 m_pOldPalette = NULL;1674 #endif // DIBSECTION_NO_PALETTE1675 1676 // Delete the memory DC1677 return m_MemDC.DeleteDC();1678 }

BOOL CDIBSectionLite::Save (LPCTSTR lpszFileName)Saves the image to file.Parameters:

lpszFileName Image filename Returns:

Returns TRUE on success, FALSE otherwise

Definition at line 1128 of file DIBSectionLite.cpp.

1129 {1130 BITMAPFILEHEADER hdr;1131 LPBITMAPINFOHEADER lpbi = GetBitmapInfoHeader();1132 1133 if (!lpbi || !lpszFileName)1134 return FALSE;1135 1136 CFile file;1137 if (!file.Open(lpszFileName, CFile::modeWrite|CFile::modeCreate))1138 return FALSE;1139 1140 DWORD dwBitmapInfoSize = sizeof(BITMAPINFO) + (m_iColorTableSize - 1)*sizeof(RGBQUAD);1141 DWORD dwFileHeaderSize = dwBitmapInfoSize + sizeof(hdr);1142 1143 // Fill in the fields of the file header

1144 hdr.bfType = DS_BITMAP_FILEMARKER;1145 hdr.bfSize = dwFileHeaderSize + lpbi->biSizeImage;1146 hdr.bfReserved1 = 0;1147 hdr.bfReserved2 = 0;1148 hdr.bfOffBits = dwFileHeaderSize;1149 1150 // Write the file header 1151 file.Write(&hdr, sizeof(hdr));1152 1153 // Write the DIB header1154 file.Write(lpbi, dwBitmapInfoSize);1155 1156 // Write DIB bits1157 file.Write(GetDIBits(), lpbi->biSizeImage);1158 1159 return TRUE;1160 }

BOOL CDIBSectionLite::SetBitmap (LPBITMAPINFO lpBitmapInfo, LPVOID lpBits)Initialises the bitmap using the information in lpBitmapInfo to determine the dimensions and colors, and the then sets the bits from the bits in lpBits. If failure, then object is initialised back to an empty bitmap.Parameters:

lpBitmapInfo Pointer to a BITMAPINFO structure lpBits Pointer to image bits. Can be NULL to simply create empty bitmap

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 781 of file DIBSectionLite.cpp.

References BytesPerLine(), CreatePalette(), DeleteObject(), and NumColorEntries().

782 {783 DeleteObject();784 785 if (!lpBitmapInfo) // || !lpBits)786 return FALSE;787 788 HDC hDC = NULL;789 TRY {790 BITMAPINFOHEADER& bmih = lpBitmapInfo->bmiHeader;791 792 // Compute the number of colors in the color table793 m_iColorTableSize = NumColorEntries(bmih.biBitCount, bmih.biCompression, bmih.biClrUsed);794 795 DWORD dwBitmapInfoSize = sizeof(BITMAPINFO) + m_iColorTableSize*sizeof(RGBQUAD);796 797 // Copy over BITMAPINFO contents798 memcpy(&m_DIBinfo, lpBitmapInfo, dwBitmapInfoSize);799 800 // Should now have all the info we need to create the sucker.801 //TRACE(_T("Width %d, Height %d, Bits/pixel %d, Image Size %d\n"),802 // bmih.biWidth, bmih.biHeight, bmih.biBitCount, bmih.biSizeImage);803 804 // Create a DC which will be used to get DIB, then create DIBsection805 hDC = ::GetDC(NULL);806 if (!hDC) 807 {808 TRACE0("Unable to get DC\n");809 AfxThrowResourceException();

810 }811 812 m_hBitmap = CreateDIBSection(hDC, (const BITMAPINFO*) m_DIBinfo,813 m_iColorDataType, &m_ppvBits, NULL, 0);814 ::ReleaseDC(NULL, hDC);815 if (!m_hBitmap)816 {817 TRACE0("CreateDIBSection failed\n");818 AfxThrowResourceException();819 }820 821 if (m_DIBinfo.bmiHeader.biSizeImage == 0)822 {823 int nBytesPerLine = BytesPerLine(lpBitmapInfo->bmiHeader.biWidth, 824 lpBitmapInfo->bmiHeader.biBitCount);825 m_DIBinfo.bmiHeader.biSizeImage = nBytesPerLine * lpBitmapInfo->bmiHeader.biHeight;826 }827 828 #ifndef _WIN32_WCE829 // Flush the GDI batch queue 830 GdiFlush();831 #endif832 // Only copy bits if they were provided833 if (lpBits != NULL)834 memcpy(m_ppvBits, lpBits, m_DIBinfo.bmiHeader.biSizeImage);835 836 #ifndef DIBSECTION_NO_PALETTE837 if (!CreatePalette())838 {839 TRACE0("Unable to create palette\n");840 AfxThrowResourceException();841 }842 #endif // DIBSECTION_NO_PALETTE843 }844 CATCH (CException, e)845 {846 e->Delete();847 _ShowLastError();848 if (hDC) 849 ::ReleaseDC(NULL, hDC);850 DeleteObject();851 return FALSE;852 }853 END_CATCH854 855 return TRUE;856 }

BOOL CDIBSectionLite::SetBitmap (HBITMAP hBitmap, CPalette * pPalette = NULL)Initialises the bitmap from the HBITMAP supplied. If failure, then object is initialised back to an empty bitmap.Parameters:

hBitmap Handle to image pPalette Optional palette to use when setting image

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 865 of file DIBSectionLite.cpp.

References BytesPerLine(), CreatePalette(), DeleteObject(), GetColorTableEntries(), NumColorEntries(), and SetPalette().

870 {871 DeleteObject();872 873 if (!hBitmap)874 return FALSE;875 876 // Get dimensions of bitmap877 BITMAP bm;878 if (!::GetObject(hBitmap, sizeof(bm),(LPVOID)&bm))879 return FALSE;880 bm.bmHeight = abs(bm.bmHeight);881 882 CWindowDC dc(NULL);883 #ifndef DIBSECTION_NO_PALETTE884 CPalette* pOldPalette = NULL;885 #endif // DIBSECTION_NO_PALETTE886 887 TRY {888 m_iColorTableSize = NumColorEntries(bm.bmBitsPixel, BI_RGB);889 890 // Initialize the BITMAPINFOHEADER in m_DIBinfo891 BITMAPINFOHEADER& bih = m_DIBinfo.bmiHeader;892 bih.biSize = sizeof(BITMAPINFOHEADER);893 bih.biWidth = bm.bmWidth;894 bih.biHeight = bm.bmHeight;895 bih.biPlanes = 1; // Must always be 1 according to docs896 bih.biBitCount = bm.bmBitsPixel;897 898 #ifdef _WIN32_WCE899 // I've found PocketPCs need BI_BITFIELDS for 16 bit dibs.900 if (bm.bmBitsPixel == 16 || bm.bmBitsPixel == 32)901 bih.biCompression = BI_BITFIELDS; 902 else903 bih.biCompression = BI_RGB;904 #else905 bih.biCompression = BI_RGB;906 #endif907 908 bih.biSizeImage = BytesPerLine(bm.bmWidth, bm.bmBitsPixel) * bm.bmHeight;909 bih.biXPelsPerMeter = 0;910 bih.biYPelsPerMeter = 0;911 bih.biClrUsed = 0;912 bih.biClrImportant = 0;913 914 GetColorTableEntries(dc.GetSafeHdc(), hBitmap);915 916 #ifndef DIBSECTION_NO_PALETTE917 // If we have a palette supplied, then set the palette (and hance DIB color918 // table) using this palette919 if (pPalette)920 SetPalette(pPalette);921 922 if (m_Palette.GetSafeHandle())923 {924 pOldPalette = dc.SelectPalette(&m_Palette, FALSE);925 dc.RealizePalette();926 }927 #endif // DIBSECTION_NO_PALETTE928 929 // Create it!930 m_hBitmap = CreateDIBSection(dc.m_hDC, 931 (const BITMAPINFO*) m_DIBinfo,932 m_iColorDataType,933 &m_ppvBits, 934 NULL, 0);935 #ifndef DIBSECTION_NO_PALETTE

936 if (pOldPalette)937 dc.SelectPalette(pOldPalette, FALSE);938 pOldPalette = NULL; 939 #endif // DIBSECTION_NO_PALETTE940 941 if (!m_hBitmap)942 {943 TRACE0("Unable to CreateDIBSection\n");944 AfxThrowResourceException();945 }946 947 #ifndef DIBSECTION_NO_PALETTE948 // If palette was supplied then create a palette using the entries in the DIB949 // color table.950 if (!pPalette)951 CreatePalette();952 #endif // DIBSECTION_NO_PALETTE953 954 // Need to copy the supplied bitmap onto the newly created DIBsection955 CDC memDC, CopyDC;956 if (!CopyDC.CreateCompatibleDC(&dc) || !memDC.CreateCompatibleDC(&dc)) 957 {958 TRACE0("Unable to create compatible DC's\n");959 AfxThrowResourceException();960 }961 962 #ifndef DIBSECTION_NO_PALETTE963 if (m_Palette.GetSafeHandle())964 {965 memDC.SelectPalette(&m_Palette, FALSE); memDC.RealizePalette();966 CopyDC.SelectPalette(&m_Palette, FALSE); CopyDC.RealizePalette();967 }968 #endif // DIBSECTION_NO_PALETTE969 970 #ifndef _WIN32_WCE971 // Flush the GDI batch queue 972 GdiFlush();973 #endif974 975 HBITMAP hOldMemBitmap = (HBITMAP) SelectObject(memDC.m_hDC, hBitmap);976 HBITMAP hOldCopyBitmap = (HBITMAP) SelectObject(CopyDC.m_hDC, m_hBitmap);977 978 CopyDC.BitBlt(0,0, bm.bmWidth, bm.bmHeight, &memDC, 0,0, SRCCOPY);979 980 SelectObject(memDC.m_hDC, hOldMemBitmap);981 SelectObject(CopyDC.m_hDC, hOldCopyBitmap);982 983 #ifndef DIBSECTION_NO_PALETTE984 if (m_Palette.GetSafeHandle())985 {986 memDC.SelectStockObject(DEFAULT_PALETTE);987 CopyDC.SelectStockObject(DEFAULT_PALETTE);988 }989 #endif // DIBSECTION_NO_PALETTE990 }991 CATCH (CException, e)992 {993 e->Delete();994 _ShowLastError();995 #ifndef DIBSECTION_NO_PALETTE996 if (pOldPalette)997 dc.SelectPalette(pOldPalette, FALSE);998 #endif // DIBSECTION_NO_PALETTE999 DeleteObject();1000 return FALSE;1001 }1002 END_CATCH1003 1004 return TRUE;1005 }

BOOL CDIBSectionLite::SetBitmap (LPCTSTR lpszResourceName)Initialises the bitmap from a resource. If failure, then object is initialised back to an empty bitmap.

Parameters: lpszResourceName Resource name

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 749 of file DIBSectionLite.cpp.

References SetBitmap().

750 {751 HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetResourceHandle(), 752 lpszResourceName,753 IMAGE_BITMAP, 754 0,0, 755 #ifdef _WIN32_WCE756 0757 #else758 LR_CREATEDIBSECTION759 #endif760 );761 762 if (!hBmp) 763 {764 TRACE0("Unable to LoadImage");765 return FALSE;766 }767 768 BOOL bResult = SetBitmap(hBmp);769 ::DeleteObject(hBmp);770 return bResult;771 }

BOOL CDIBSectionLite::SetBitmap (UINT nIDResource)Initialises the bitmap from a resource. If failure, then object is initialised back to an empty bitmap.Parameters:

nIDResource Resource ID Returns:

Returns TRUE on success, FALSE otherwise

Definition at line 738 of file DIBSectionLite.cpp.

Referenced by Copy(), CWinBmp::CreateFromHBitmap(), Load(), SetBitmap(), and CWinBmp::StretchDraw().

739 {740 return SetBitmap(MAKEINTRESOURCE(nIDResource));741 }

BOOL CDIBSectionLite::SetColorTable (UINT nNumColors, RGBQUAD * pColors)Sets the colors used by the image. Only works if # colors <= 256Parameters:

nNumColors Number of colors to set pColors Array of RGBQUAD's containing colors to set

Returns: Returns TRUE on success, FALSE otherwise

Definition at line 1194 of file DIBSectionLite.cpp.

Referenced by Copy().

1195 {1196 if (!m_hBitmap ||!pColors || !nNumColors || m_iColorTableSize == 0 1197 || nNumColors > 256)1198 return FALSE;1199 1200 #ifdef _WIN32_WCE1201 LPRGBQUAD pColorTable = GetColorTable();1202 ASSERT(pColorTable);1203 1204 int nCount = min(m_iColorTableSize, nNumColors);1205 ::memset(pColorTable, 0, m_iColorTableSize*sizeof(RGBQUAD));1206 ::memcpy(pColorTable, pColors, nCount*sizeof(RGBQUAD));1207 #else1208 // Create a memory DC compatible with the screen1209 CDC MemDC;1210 if (!MemDC.CreateCompatibleDC(NULL))1211 return FALSE;1212 1213 HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(MemDC.GetSafeHdc(), m_hBitmap);1214 1215 ::SetDIBColorTable(MemDC.GetSafeHdc(), 0, nNumColors, pColors);1216 1217 // Clean up1218 if (hOldBitmap)1219 ::SelectObject(MemDC.GetSafeHdc(), hOldBitmap);1220 #endif1221 1222 return TRUE;1223 }

BOOL CDIBSectionLite::SetDither (BOOL bDither)Turns dithering on by using the DrawDib functions instead of the GDI functions

Parameters: bDither Whether or not dithering should be enabled return TRUE on success

Definition at line 540 of file DIBSectionLite.cpp.

Referenced by Copy().

541 {542 if ( (m_bDither == bDither) &&543 ((m_hDrawDib && m_bDither) || (!m_hDrawDib && !m_bDither)) )544 return TRUE;

545 546 if (!bDither && m_hDrawDib != NULL)547 {548 DrawDibClose(m_hDrawDib);549 m_hDrawDib = NULL;550 }551 552 m_bDither = bDither;553 554 return TRUE;555 }

BOOL CDIBSectionLite::SetLogPalette (LOGPALETTE * pLogPalette)Sets the current palette used by the image from the supplied LOGPALETTEParameters:

pLogPalette New palette to use Returns:

Returns TRUE on success

Definition at line 1338 of file DIBSectionLite.cpp.

References CreatePalette(), and FillDIBColorTable().Referenced by SetPalette().

1339 {1340 if (!pLogPalette)1341 {1342 CreatePalette();1343 return FALSE;1344 }1345 1346 ASSERT(pLogPalette->palVersion == (WORD) 0x300);1347 1348 UINT nColors = pLogPalette->palNumEntries;1349 if (nColors <= 0 || nColors > 256)1350 {1351 CreatePalette();1352 return FALSE;1353 }1354 1355 // Create new palette1356 m_Palette.DeleteObject();1357 if (!m_Palette.CreatePalette(pLogPalette))1358 {1359 CreatePalette();1360 return FALSE;1361 }1362 1363 if (m_iColorTableSize == 0)1364 return TRUE;1365 1366 // Set the DIB colors1367 RGBQUAD RGBquads[256]; 1368 for (UINT i = 0; i < nColors; i++)1369 {1370 RGBquads[i].rgbRed = pLogPalette->palPalEntry[i].peRed;1371 RGBquads[i].rgbGreen = pLogPalette->palPalEntry[i].peGreen;1372 RGBquads[i].rgbBlue = pLogPalette->palPalEntry[i].peBlue;1373 RGBquads[i].rgbReserved = 0;1374 }1375 1376 return FillDIBColorTable(nColors, RGBquads);

1377 }

BOOL CDIBSectionLite::SetPalette (CPalette * pPalette)Sets the current palette used by the image from the supplied CPalette, and sets the color table in the DIBSection

Parameters: pPalette New palette to use

Returns: Returns TRUE on success

Definition at line 1315 of file DIBSectionLite.cpp.

References SetLogPalette().

Referenced by SetBitmap().

1316 {1317 m_Palette.DeleteObject();1318 1319 if (!pPalette)1320 return FALSE;1321 1322 UINT nColors = pPalette->GetEntryCount();1323 if (nColors <= 0 || nColors > 256)1324 return FALSE;1325 1326 // Get palette entries1327 PALETTEINFO pi;1328 pi.palNumEntries = (WORD) pPalette->GetPaletteEntries(0, nColors, (LPPALETTEENTRY) pi);1329 1330 return SetLogPalette(&pi);1331 }

BOOL CDIBSectionLite::Stretch (CDC * pDC, CPoint ptDest, CSize size, BOOL bForceBackground = FALSE)

Stretch draws the image to the desired size on the device contextParameters:

pDC Pointer to a device context ptDest Point at which the topleft corner of the image is drawn size Size to stretch the image

Returns: TRUE on success

Definition at line 658 of file DIBSectionLite.cpp.

References GetDrawDibContext(), GetMemoryDC(), and ReleaseMemoryDC().Referenced by CWinBmp::StretchDraw().

660 { 661 if (!m_hBitmap)662 return FALSE;

663 664 CPoint ptOrigin = CPoint(0,0);665 CSize imagesize = GetSize();666 667 BOOL bResult = FALSE;668 669 #ifndef _WIN32_WCE670 pDC->SetStretchBltMode(COLORONCOLOR);671 #endif672 673 #ifndef DIBSECTION_NO_DITHER674 // We will only be able to get a HDRAWDIB if dithering is enabled675 HDRAWDIB hDrawDib = GetDrawDibContext();676 if (hDrawDib)677 {678 #ifndef DIBSECTION_NO_PALETTE679 DrawDibSetPalette( hDrawDib, (HPALETTE)m_Palette);680 DrawDibRealize( hDrawDib, pDC->GetSafeHdc(), FALSE);681 #endif // DIBSECTION_NO_PALETTE682 683 bResult = DrawDibDraw(hDrawDib, pDC->GetSafeHdc(), 684 ptDest.x, ptDest.y, size.cx, size.cy, 685 GetBitmapInfoHeader(), GetDIBits(), 686 0,0, GetWidth(), GetHeight(), 687 0/*DDF_HALFTONE*/);688 }689 else690 {691 #endif // DIBSECTION_NO_DITHER692 // Create a memory DC compatible with the destination DC693 CDC* pMemDC = GetMemoryDC(pDC, FALSE);694 if (!pMemDC)695 return FALSE;696 697 #ifndef DIBSECTION_NO_PALETTE698 // Select and realize the palette699 CPalette* pOldPalette = NULL;700 if (m_Palette.m_hObject && UsesPalette(pDC))701 {702 pOldPalette = pDC->SelectPalette(&m_Palette, bForceBackground);703 pDC->RealizePalette();704 }705 #endif // DIBSECTION_NO_PALETTE706 707 #ifndef _WIN32_WCE708 pDC->SetStretchBltMode(COLORONCOLOR);709 #endif // _WIN32_WCE710 711 bResult = pDC->StretchBlt(ptDest.x, ptDest.y, size.cx, size.cy, 712 pMemDC, 713 ptOrigin.x, ptOrigin.y, imagesize.cx, imagesize.cy, 714 SRCCOPY);715 716 #ifndef DIBSECTION_NO_PALETTE717 if (pOldPalette)718 pDC->SelectPalette(pOldPalette, FALSE);719 #endif // DIBSECTION_NO_PALETTE720 721 ReleaseMemoryDC();722 #ifndef DIBSECTION_NO_DITHER723 }724 #endif // DIBSECTION_NO_DITHER725 726 return bResult;727 }

The documentation for this class was generated from the following files:

DIBSectionLite.h DIBSectionLite.cpp

CDibSequence Class ReferenceThis class implements the slide show mechanism of ImageViewer. #include <DibSequence.h>

Public Methods CDibSequence () virtual ~CDibSequence () void Serialize (CArchive &archive)Saves/Loads current object on/from an archive (mainly disk file) Parameters:

archive Archive to/from which write/read data.

bool IsEmpty () constCheck if filenames string list is empty

Returns: True if empty, else false.

void Clear ()Clear filenames string list.

void SetPosition (CString Filename)Sets current position of string list pointer

Parameters: Filename Search and point to this filename in list.

CString GetPreviousFilename ()Returns previous filename in list.

CString GetNextFilename ()Returns next filename in list.

CString GetFirstFilename ()Returns first filename in list.

CString GetLastFilename ()Returns last filename in list.

CString GetRandomFilename ()Returns a random filename in list.

void AddFile (const CString &Filename)Adds a new filename to list.

CString RemoveFile (const CString &Filename)Remove an existing filename from list. Parameters:

Filename Filename to remove from list Returns:

Found filename if exist, null string else.

void RemoveAll () CString FillSequence (const CString &Pathname) int GetCount () constGets the number of DIB items in list.

Returns: Number of items in list.

int GetCurrentPosition () constGets the current position of DIB item in list. Current position in list.

Protected Attributes CStringList m_FilenameListFilenames strings linked list.

POSITION m_PositionCurrent position in linked list.

Detailed Description

It consists of a linked list (using MFC's CStringList), and a pointer to one of this list's entries. When ever a user asks for an image, according to his will (forward, reverse or random), he shall get a corresponding CString object that represents the image's filename (including path)

Definition at line 20 of file DibSequence.h.

The documentation for this class was generated from the following files: DibSequence.h DibSequence.cpp

CDIBStatic Class ReferenceThis class is used to display a static DIB (in a preview dialog etc.). #include <DIBStatic.h>

Public Methods CDIBStatic () virtual ~CDIBStatic () BOOL IsValidDib () constChecks if the DIB is valid.

BOOL LoadDib (LPCTSTR lpszFileName)Loads a DIB from file.

void UpdateDib ()Updates DIB.

void RemoveDib ()Remove existing.

BOOL DoRealizePalette (BOOL bForceBackGround)

Protected Methods void ClearDib () void PaintDib (BOOL bDibValid) afx_msg HBRUSH CtlColor (CDC *pDC, UINT nCtlColor) afx_msg BOOL OnQueryNewPalette () afx_msg void OnPaletteChanged (CWnd *pFocusWnd)

Private Attributes CWinBmpEx m_DIBDIB to be displayed.

BOOL m_bHasFileIs a file attached?

The documentation for this class was generated from the following files: DIBStatic.h DIBStatic.cpp

CDitherDialog Class ReferenceThis dialog interfaces between the user's input and the CFilterQuantize class. #include <DitherDialog.h>

Public Types enum { IDD = IDD_CONVERTTO8BPP }

Public Methods CDitherDialog (CWnd *pParent=NULL)

Public Attributes CComboBox m_DitherPaletteTypeBoxDitherPaletteType.

CComboBox m_DitherTypeBoxDitherType.

UINT m_iDitherType UINT m_iDitherPaletteType

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual void OnOK () virtual BOOL OnInitDialog ()

Detailed Description

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

Definition at line 24 of file DitherDialog.h.

The documentation for this class was generated from the following files: DitherDialog.h DitherDialog.cpp

CDocManagerEx Class ReferenceThis class replaces the default CDocManager class provided by MFC. It is used to show an image preview pane inside the file open dialog. #include <DocManagerEx.h>

Public Methods CDocManagerEx () virtual ~CDocManagerEx () virtual BOOL DoPromptFileName (CString &fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate *pTemplate)helper for standard commdlg dialogs.

The documentation for this class was generated from the following files: DocManagerEx.h DocManagerEx.cpp

CFileSink Class ReferenceThis is a class which takes a file as a destination of picture data. #include <FileSink.h>

Inheritance diagram for CFileSink:

Public Methods CFileSink () virtual ~CFileSink () virtual int Open (const CString pszFName, int MaxFileSize) virtual void Close ()

Private Attributes FILE * m_pFile BYTE * m_pDataBuf

Detailed Description

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.

Definition at line 22 of file FileSink.h.

The documentation for this class was generated from the following files: FileSink.h FileSink.cpp

CFileSource Class ReferenceThis is a class which takes a file as a source of picture data. #include <FileSource.h>

Inheritance diagram for CFileSource:

Public Methods CFileSource (IProgressNotification *pNotification=NULL) virtual ~CFileSource () virtual int Open (CString pszFName) virtual void Close () virtual BYTE * ReadNBytes (int n)This needs to be overridden in derived classes.

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!

Private Methods BOOL bytesAvailable (int n) void fillBuffer ()

Private Attributes FILE * m_pFile BYTE * m_pBuffer BYTE * m_pReadPos int m_BytesReadFromFile BYTE * m_pStartData BYTE * m_pCurPos

The documentation for this class was generated from the following files: FileSource.h FileSource.cpp

CFilter Class ReferenceBase class for filters that operate on bitmaps. Derived classes need to override either the ApplyInPlace or the Apply function. #include <Filter.h>

Inheritance diagram for CFilter:

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

The documentation for this class was generated from the following files: Filter.h Filter.cpp

CFilterContrast Class ReferenceEnhances or reduces the image contrast using a linear mapping between input and output. #include <FilterContrast.h>

Inheritance diagram for CFilterContrast:

Public Methods 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.

virtual ~CFilterContrast () 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).

Protected Attributes double m_contrast double m_offset

Detailed Description

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

Definition at line 26 of file FilterContrast.h.

The documentation for this class was generated from the following files: FilterContrast.h

FilterContrast.cpp

CFilterCrop Class ReferenceFilter that cuts part of the image off. #include <FilterCrop.h>

Inheritance diagram for CFilterCrop:

Public Methods CFilterCrop (int XMin, int XMax, int YMin, int YMax) virtual ~CFilterCrop () 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).

Private Attributes int m_XMin int m_XMax int m_YMin int m_YMax

The documentation for this class was generated from the following files: FilterCrop.h FilterCrop.cpp

CFilterDialog Class ReferenceThis dialog interfaces between the user's input and the CFilterResizeBilinear/ CFilterResizeBox/CFilterResizeGaussian/CFilterResizeHamming. #include <FilterDialog.h>

Public Types enum { IDD = IDD_FILTER }

Public Methods CFilterDialog (CWnd *pParent, CBmp *pBmp, const char *pszFilterName, bool bRadiusAllowed) int GetWidth () int GetHeight () double GetRadius ()

Public Attributes CButton m_ConstrainCheck CStatic m_RadiusStatic CEdit m_RadiusEdit CStatic m_NameStatic CEdit m_HeightEdit CEdit m_WidthEdit int m_Height int m_Width double m_Radius

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual void OnOK () afx_msg void OnChangeHeightedit () afx_msg void OnChangeWidthedit () virtual BOOL OnInitDialog ()

Private Attributes CBmp * m_pBmp const char * m_pszFilterName bool m_bRadiusAllowed bool m_bChanging

The documentation for this class was generated from the following files: FilterDialog.h FilterDialog.cpp

CFilterGetAlpha Class ReferenceReturns an 8 bpp grayscale bitmap containing only the alpha channel of the source bitmap. #include <FilterGetAlpha.h>

Inheritance diagram for CFilterGetAlpha:

Public Methods CFilterGetAlpha () virtual ~CFilterGetAlpha () 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).

The documentation for this class was generated from the following files: FilterGetAlpha.h FilterGetAlpha.cpp

CFilterGrayscale Class ReferenceCreates a grayscale version of the bitmap. #include <FilterGrayscale.h>

Inheritance diagram for CFilterGrayscale:

Public Methods CFilterGrayscale () virtual ~CFilterGrayscale () 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).

The documentation for this class was generated from the following files: FilterGrayscale.h FilterGrayscale.cpp

CFilterIntensity Class ReferenceChanges the intensity of a bitmap image. #include <FilterIntensity.h>

Inheritance diagram for CFilterIntensity:

Public Methods CFilterIntensity (double intensity, BYTE offset, double exponent) virtual ~CFilterIntensity () 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).

Protected Attributes double m_intensity double m_offset double m_exponent

Detailed Description

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.

Definition at line 23 of file FilterIntensity.h.

The documentation for this class was generated from the following files: FilterIntensity.h FilterIntensity.cpp

CFilterLightness Class ReferenceFilter that changes the lightness of a bitmap image. #include <FilterLightness.h>

Inheritance diagram for CFilterLightness:

Public Methods CFilterLightness (int lightness) virtual ~CFilterLightness () 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).

Protected Attributes double m_lightness

Detailed Description

lightness values must be in the range -100..100. A value of 0 leaves the image unchanged.

Definition at line 20 of file FilterLightness.h.

The documentation for this class was generated from the following files: FilterLightness.h FilterLightness.cpp

CFilterQuantize Class ReferenceReturns an 8 bpp bitmap containing a best-fit representation of the source 32 bpp bitmap. #include <FilterQuantize.h>

Inheritance diagram for CFilterQuantize:

Public Methods 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)Applies the Filter to pBmpSource and stores the result in pBmpDest. The base-class version copies the bitmap before calling ApplyInPlace (pBmpDest).

Private Types typedef CFilterQuantize::tagQUBOX QUBOXLocal structs defining the quantization buffer.

typedef CFilterQuantize::tagHISTONODE HISTONODE

Private Methods void initLUT () void deleteLUT () void genMedianPalette (CBmp *pBmpSource, CBmp *pBmpDest) void split (QUBOX *pBox0, QUBOX *pBox1, int ColComp) void squeeze (QUBOX *pBox) void genPopularityPalette (CBmp *pBmpSource, CBmp *pBmpDest) void genColorArray (CBmp *pBmpSource) void genDefaultPalette (CBmp *pBmpSource) void addColor (CPixel32 col, ULONG count) void makeBox (CPixel32 col, int i, ULONG c) int getColorTableIndex (CPixel32 col) int getShiftedColorTableIndex (CPixel32 col) void ditherDestBmp (CBmp *pBmpSource, CBmp *pBmpDest)

void jitterPixel (int i, int y, CPixel32 *pPixel) void ditherPixelOrdered (int x, int y, CPixel32 *pPixel) void ditherCompOrdered (int x, int y, BYTE *pComp) void ditherPixelFS (double *pR, double *pG, double *pB, double *pCurErrors) void ditherCompFS (double *pComp, double Error) BYTE getNeighbor (CPixel32 Color, CPixel32 *pPal) int colorDist (CPixel32 c0, CPixel32 c1) int clip (int c)

Private Attributes int m_DitherPaletteType int m_DitherType HISTONODE ** m_ppHisto QUBOX * m_pQuBoxes

The documentation for this class was generated from the following files: FilterQuantize.h FilterQuantize.cpp

CFilterQuantize::tagQUBOX Struct ReferenceLocal structs defining the quantization buffer.

Public Attributes CPixel32 Corner0 CPixel32 Corner1 CPixel32 Average ULONG count

The documentation for this struct was generated from the following file: FilterQuantize.h

CFilterResize Class ReferenceBase class for filters that resize the image. #include <FilterResize.h>

Inheritance diagram for CFilterResize:

Public Methods CFilterResize (int NewXSize, int NewYSize) virtual ~CFilterResize () void SetNewSize (int NewXSize, int NewYSize)

Protected Attributes int m_NewXSize int m_NewYSize

The documentation for this class was generated from the following files: FilterResize.h FilterResize.cpp

CFilterResizeBilinear Class ReferenceResizes a bitmap using bilinear interpolation. #include <FilterResizeBilinear.h>

Inheritance diagram for CFilterResizeBilinear:

Public Methods CFilterResizeBilinear (int NewXSize, int NewYSize) 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).

The documentation for this class was generated from the following files: FilterResizeBilinear.h FilterResizeBilinear.cpp

CFilterResizeBox Class ReferenceResizes a bitmap and applies a box filter to it. #include <FilterResizeBox.h>

Inheritance diagram for CFilterResizeBox:

Public Methods CFilterResizeBox (int NewXSize, int NewYSize, double NewRadius) 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).

Private Attributes double m_NewRadius

The documentation for this class was generated from the following files: FilterResizeBox.h FilterResizeBox.cpp

CFilterResizeGaussian Class ReferenceResizes a bitmap and applies a gaussian blur to it. #include <FilterResizeGaussian.h>

Inheritance diagram for CFilterResizeGaussian:

Public Methods CFilterResizeGaussian (int NewXSize, int NewYSize, double NewRadius) 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).

Private Attributes double m_NewRadius

The documentation for this class was generated from the following files: FilterResizeGaussian.h FilterResizeGaussian.cpp

CFilterResizeHamming Class ReferenceResizes a bitmap and applies a hamming filter to it. #include <FilterResizeHamming.h>

Inheritance diagram for CFilterResizeHamming:

Public Methods CFilterResizeHamming (int NewXSize, int NewYSize, double NewRadius) 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).

Private Attributes double m_NewRadius

The documentation for this class was generated from the following files: FilterResizeHamming.h FilterResizeHamming.cpp

CFilterRotate Class ReferenceRotates a bitmap by angle radians. #include <FilterRotate.h>

Inheritance diagram for CFilterRotate:

Public Methods CFilterRotate (double angle, CPixel32 crDefault) virtual ~CFilterRotate () 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).

Protected Attributes double m_angle CPixel32 m_crDefault

The documentation for this class was generated from the following files: FilterRotate.h FilterRotate.cpp

CFilterThreshold Class ReferenceReturns an 8 bpp grayscale bitmap. #include <FilterThreshold.h>

Inheritance diagram for CFilterThreshold:

Public Methods CFilterThreshold (int threshold_min, int threshold_max, int channel) virtual ~CFilterThreshold () 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).

Protected Attributes int m_threshold_min int m_threshold_max int m_channel

Detailed Description

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.

Definition at line 19 of file FilterThreshold.h.

The documentation for this class was generated from the following files: FilterThreshold.h FilterThreshold.cpp

CGaussianFilter Class ReferenceDefines a Gaussian filter. #include <2PSFilters.h>

Inheritance diagram for CGaussianFilter:

Public Methods CGaussianFilter (double dWidth=3.0) virtual ~CGaussianFilter () virtual double Filter (double dVal)Pure virtual function - implements the filter operation.

The documentation for this class was generated from the following file: 2PSFilters.h

CGenericFilter Class ReferenceBase class for alll types of filters. #include <2PSFilters.h>

Inheritance diagram for CGenericFilter:

Public Methods CGenericFilter (double dWidth) virtual ~CGenericFilter () double GetWidth ()Gets filter width.

void SetWidth (double dWidth)Sets filter width.

virtual double Filter (double dVal)=0Pure virtual function - implements the filter operation.

Protected Attributes double m_dWidthWidth of filter.

The documentation for this class was generated from the following file: 2PSFilters.h

CGIFDecoder Class ReferenceThis class implements the GIF decoder for the application. #include <GIFDecoder.h>

Inheritance diagram for CGIFDecoder:

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

CGIFDecoder () virtual ~CGIFDecoder ()

The documentation for this class was generated from the following files: GIFDecoder.h GIFDecoder.cpp

CHammingFilter Class ReferenceDefines a Hamming filter. #include <2PSFilters.h>

Inheritance diagram for CHammingFilter:

Public Methods CHammingFilter (double dWidth=0.5) virtual ~CHammingFilter () virtual double Filter (double dVal)Pure virtual function - implements the filter operation.

The documentation for this class was generated from the following file: 2PSFilters.h

CHandTracker Class ReferenceThis class implemets the rubber band hand mechanism for panning images.

Public Methods CHandTracker (CImageViewerView *pView) virtual void OnChangedRect (const CRect &rectOld) virtual void DrawTrackerRect (LPCRECT lpRect, CWnd *pWndClipTo, CDC *pDC, CWnd *pWnd)

Private Attributes CImageViewerView * m_pView

The documentation for this class was generated from the following file: ImageViewerView.cpp

CImageViewerApp Class ReferenceThis is the project's main application class. #include <ImageViewer.h>

Public Methods CImageViewerApp ()default constructor.

CImageViewerApp (LPCTSTR lpszHelpName)

Parameters: Application help filename.

CAnyPicDecoder * GetDecoder ()Gets the image decoder object.

int GetScreenBPP () constReturns the current platform's bits-per-pixel.

virtual BOOL InitInstance ()

Public Attributes CAppOptions m_OptionsHold the application's options made by user.

Protected Methods afx_msg void OnAppAbout () afx_msg void OnToolsOptions ()

Protected Attributes CAnyPicDecoder m_theDecoderGlobal decoder object (embedded in unique app instance).

Detailed Description

It is inherited from CWinApp, the MFC application class. This class will hold the user settings for the project, as well as the generic decoder for any supported image formats.

Definition at line 32 of file ImageViewer.h.

The documentation for this class was generated from the following files: ImageViewer.h ImageViewer.cpp

CImageViewerDoc Class ReferenceThis is the application document object. #include <ImageViewerDoc.h>

Inheritance diagram for CImageViewerDoc:

Public Methods CSize GetDocSize ()Get image size.

HPALETTE GetDocPalette ()Get a handle to logical palette.

void SlideshowNext ()Show next image in sequence.

void SlideshowRandom ()Show a random image in sequence.

void SlideshowPrevious ()Show previous image in sequence.

void SlideshowLast ()Show last image in sequence.

void SlideshowFirst ()Show first image in sequence.

void ReloadDib ()Reload image from file (used to refresh).

void ConvertTo8BPP (UINT iDitherPaletteType, UINT iDitherType) virtual void DeleteContents ()Delete document's contents.

CWinBmpEx * GetDib ()Gets current image (as DIB).

void OnProgress (double Part)Update the progress indicator.

void SetOrigDib ()Sets the current image in a copy for an undo operation.

bool IsSequenceEmpty ()Checks if the sequence is empty.

Public Attributes CWinBmpEx * m_pDibCurrent shown image.

CWinBmpEx * m_pOrigDibPrevious image copy for an undo operation.

CDibSequence m_DibSeqImage sequence used for slide shows.

Protected Methods CImageViewerDoc () virtual ~CImageViewerDoc () BOOL OpenSequenceFile (LPCTSTR lpszPathName)Opens a sequence file from file.

virtual BOOL OnOpenDocument (LPCTSTR lpszPathName)Opens an image from file.

void CopyMoveTo (bool bCopy)Performs copy/move operation using current image.

void DeleteDib ()Deletes current image.

BOOL OpenDib (LPCTSTR lpszPathName)Opens an image from file.

afx_msg void OnFileSaveAs () afx_msg void OnUpdateFileSaveAs (CCmdUI *pCmdUI) afx_msg void OnUpdateFileSaveSeqAs (CCmdUI *pCmdUI)

afx_msg void OnUpdateEditCommands (CCmdUI *pCmdUI) afx_msg void OnFileClose () afx_msg void OnFileCloseAll () afx_msg void OnSaveSeqAs () afx_msg void OnEditUndo () afx_msg void OnUpdateEditUndo (CCmdUI *pCmdUI) afx_msg void OnEditCopyTo ()Handler of the "Edit\Copy-To" menu command.

afx_msg void OnEditMoveTo () afx_msg void OnEditDeleteImage () afx_msg void OnEditRename () afx_msg void OnToolsWallpaperCentered () afx_msg void OnToolsWallpaperRestore () afx_msg void OnToolsTimestamp () afx_msg void OnUpdateFilenameInfo (CCmdUI *pCmdUI) afx_msg void OnUpdateSlideInfo (CCmdUI *pCmdUI)

Detailed Description

In this application, it will be a singleton, initialized whenever a user starts the program. It hold the actual image being shown, as well as the string list containing the slide show images filenames. It can also manipulate an image file (ie: change timestamp etc.)

Definition at line 27 of file ImageViewerDoc.h.

Member Function Documentation

void CImageViewerDoc::ConvertTo8BPP (UINT iDitherPaletteType, UINT iDitherType)Convert image to 8bpp using specified method Parameters:

iDitherPaletteType Dithering method. Can be one of the following: DitherPaletteType and DitherType determine the type of quantization:

DTHPAL_MEDIAN (0): Median Cut DTHPAL_POPULARITY (1): Popularity Sort DTHPAL_DEFAULT (2): Use Default Palette

Parameters: iDitherType Dither quantization method. Can be one of the following:

DTH_NONE (0): None DTH_ORDERED (1): Ordered Dithering DTH_FS (2): Floyd-Steinberg Dithering

Definition at line 224 of file ImageViewerDoc.cpp.

References CBmp::CreateCopy(), m_DibSeq, m_pDib, and CBmp::SetQuantizationMode().Referenced by CImageViewerView::OnConvertTo8BPP().

225 {226 CWinBmpEx* bpp8Copy = new CWinBmpEx;227 bpp8Copy->SetQuantizationMode (iDitherType, iDitherPaletteType);228 bpp8Copy->CreateCopy((CBmp&)*m_pDib, 8);229 delete m_pDib;230 m_pDib = bpp8Copy;231 }

The documentation for this class was generated from the following files: ImageViewerDoc.h ImageViewerDoc.cpp

CImageViewerView Class ReferenceThis is the application frame view object. #include <ImageViewerView.h>

Inheritance diagram for CImageViewerView:

Public Methods CImageViewerDoc * GetDocument ()Gets active document object.

virtual ~CImageViewerView () virtual void OnDraw (CDC *pDC)overridden to draw this view.

virtual void OnInitialUpdate ()Called by the framework after the view is first attached to the document, but before the view is initially displayed. The default implementation of this function calls the OnUpdate member function with no hint information (that is, using the default values of 0 for the lHint parameter and NULL for the pHint parameter). Here it sets the scroll bar according to current image.

virtual void OnActivateView (BOOL bActivate, CView *pActivateView, CView *pDeactiveView)Called by the framework when a view is activated or deactivated. In this class it will refresh the current image's palette.

void OnConvertTo8BPP ()A handler for converting the image to 8bpp.

Protected Methods CImageViewerView () virtual BOOL OnPreparePrinting (CPrintInfo *pInfo)Called by the framework before a document is printed or previewed.

virtual void OnPrepareDC (CDC *pDC, CPrintInfo *pInfo=NULL)Called by the framework before the OnDraw member function is called for screen display and before the OnPrint member function is called for each page during printing or print preview. Parameters:

pDC Points to the device context to be used for rendering an image of the document. pInfo Points to a CPrintInfo structure that describes the current print job if OnPrepareDC is being called for printing or print preview; the m_nCurPage member specifies the page about to be printed. This parameter is NULL if OnPrepareDC is being called for screen display.

afx_msg BOOL OnEraseBkgnd (CDC *pDC) afx_msg void OnSize (UINT nType, int cx, int cy) afx_msg LRESULT OnDoRealize (WPARAM wParam, LPARAM lParam) afx_msg void OnUpdateFitImage (CCmdUI *pCmdUI) afx_msg void OnEditCopy () afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags) afx_msg void OnFilterBilinear () afx_msg void OnFilterBox () afx_msg void OnFilterGauss () afx_msg void OnFilterHamming () afx_msg void OnFilterCrop () afx_msg void OnFilterGrayscale () afx_msg void OnFilterRotate () afx_msg void OnEditPaste () afx_msg void OnLButtonDown (UINT nFlags, CPoint point) afx_msg void OnMButtonDown (UINT nFlags, CPoint point) afx_msg void OnRButtonDown (UINT nFlags, CPoint point) afx_msg BOOL OnSetCursor (CWnd *pWnd, UINT nHitTest, UINT message) afx_msg void OnUpdateZoomMode (CCmdUI *pCmdUI) afx_msg void OnUpdateZoomLock (CCmdUI *pCmdUI) afx_msg void OnZoomMode () afx_msg void OnUpdateMarqueeMode (CCmdUI *pCmdUI) afx_msg void OnMarqueeMode () afx_msg void OnPaint () afx_msg void OnMouseMove (UINT nFlags, CPoint point) afx_msg void OnFilterInvertImage () afx_msg void OnFilterThreshold () afx_msg void OnFilterContrast () afx_msg void OnFilterIntensity () afx_msg void OnFilterLightness () afx_msg void OnUpdateTrueColFilter (CCmdUI *pCmdUI) afx_msg void OnUpdateFilter (CCmdUI *pCmdUI) afx_msg void OnSlideshowNext () afx_msg void OnSlideshowRandom () afx_msg void OnSlideshowPrevious () afx_msg void OnSlideshowRun () afx_msg void OnUpdateSlideshowRun (CCmdUI *pCmdUI) afx_msg void OnUpdateSlideshow (CCmdUI *pCmdUI) afx_msg void OnTimer (UINT nIDEvent) afx_msg void OnFitImage () afx_msg void OnZoomLock () afx_msg void OnZoomMore () afx_msg void OnZoomLess () afx_msg void OnDither () afx_msg void OnUpdateDither (CCmdUI *pCmdUI) afx_msg void OnViewShowpalette () afx_msg void OnSizeToFit () afx_msg void OnEditSelectNone () afx_msg void OnUpdateEditPaste (CCmdUI *pCmdUI) afx_msg void OnUpdateEditCopy (CCmdUI *pCmdUI)

afx_msg void OnUpdateZooming (CCmdUI *pCmdUI) afx_msg void OnUpdateViewShowpalette (CCmdUI *pCmdUI) afx_msg void OnViewImageLast () afx_msg void OnViewImageFirst () afx_msg void OnViewReload () afx_msg void OnZoomActualsize () afx_msg void OnLButtonUp (UINT nFlags, CPoint point) virtual void OnUpdate (CView *pSender, LPARAM lHint, CObject *pHint) afx_msg void OnUpdateEditSelectNone (CCmdUI *pCmdUI) afx_msg void OnUpdateBmpInfo (CCmdUI *) afx_msg void OnUpdatePixelXIndicator (CCmdUI *pCmdUI) afx_msg void OnUpdatePixelYIndicator (CCmdUI *pCmdUI) afx_msg void OnUpdateRatioIndicator (CCmdUI *pCmdUI)

Private Types typedef CZoomView SuperDefines the father class.

Private Methods void applyFilterAndShow (CFilter *pFilter)This function will apply a filter on current image and will refresh the DC.

void NotifyRanges ()Update scroll bar according to image properties.

BOOL IsMovable () constChecks wheter the scroll bars are activated.

Returns: True if either of the scroll bars are activated, else false.

Private Attributes BOOL m_bFitwhether to fit image to view.

BOOL m_bDitherwhether to use palette dithering.

BOOL m_bZoomingIs current view is in zoom mode.

BOOL m_bZoomLockIs the zoom ratio locked.

BOOL m_bMarqueeIs current view is in marquee mode.

HCURSOR m_curMoveHandle for move cursor icon.

HCURSOR m_curPointHandle for point cursor icon.

HCURSOR m_hZoomCursorHandle for zooming cursor icon.

CRect m_InvalidRectSmallest client rectangle which need updating.

CRect m_rcDestDestination client rectangle.

int m_nDocPosXCurrent cursor X position.

int m_nDocPosYCurrent cursor Y position.

BOOL m_bSlideshowModeIs viewer in slide show mode.

BOOL m_bRandomSlideShowIs viewer in random advancing mode.

UINT m_nSlideshowTimerID for slide show timer.

CPoint m_ptVpOrgCoordinates of upper left corner of image in client view.

Detailed Description

In this application, it will be a singleton, initialized whenever a user starts the program. It shows the actual image being hold in CImageViewerDoc. It can also manipulate an image file (ie: apply filters, rotate etc.)

Definition at line 20 of file ImageViewerView.h.

Member Function Documentation

BOOL CImageViewerView::OnPreparePrinting (CPrintInfo * pInfo) [protected, virtual]

If a file is being printed, this function invokes the Print dialog box, using the values in the CPrintInfo structure that pInfo points to; after the user has closed the dialog box, the function creates a printer device context based on settings the user specified in the dialog box and returns this device context through the pInfo parameter. This device context is used to print the document.

Parameters: pInfo Points to a CPrintInfo structure that describes the current print job.

Returns: Nonzero to begin printing; 0 if the print job has been canceled.

Definition at line 347 of file ImageViewerView.cpp.

348 {349 pInfo->SetMaxPage(1);350 // default preparation351 return DoPreparePrinting(pInfo);352 }

The documentation for this class was generated from the following files: ImageViewerView.h ImageViewerView.cpp

CIntensityDlg Class ReferenceThis dialog interfaces between the user's input and the intensity filter. #include <IntensityDlg.h>

Public Types enum { IDD = IDD_INTENSITY }

Public Methods CIntensityDlg (CWnd *pParent=NULL)

Public Attributes double m_Exponent double m_Intensity int m_Offset

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

Detailed Description

Applies the factor intensityFactor = 1.0 + csupp * pow((v-m_offset), m_exponent) with csupp = intensity/pow(255.0, m_exponent); The bitmap stays unchanged for intensity = 20, offset = 128, exponent = 1.

Definition at line 18 of file IntensityDlg.h.

The documentation for this class was generated from the following files: IntensityDlg.h IntensityDlg.cpp

CJPEGDecoder Class ReferenceJPEG file decoder. Uses the independent JPEG group's library to do the actual conversion. #include <JPEGDecoder.h>

Inheritance diagram for CJPEGDecoder:

Public Methods CJPEGDecoder ()Creates a decoder.

~CJPEGDecoder ()Destroys a decoder.

void SetFast (BOOL bFast)TRUE (the default) selects fast but sloppy decoding.

Static Public Methods void JNotification (j_common_ptr cinfo)callback for jpeglib's progress notification.

Protected Methods 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.

Private Methods void decodeGray (CBmp *pBmp, int w, int h, int *pDestBPP)Assumes IJPEG decoder is already set up.

void decodeRGB (CBmp *pBmp, int w, int h, int *pDestBPP)Assumes IJPEG decoder is already set up.

Private Attributes jpeg_decompress_struct cinfoIJPEG decoder state.

jpeg_error_mgr jerrCustom error manager.

BOOL m_bFastTRUE selects fast but sloppy decoding.

The documentation for this class was generated from the following files: JPEGDecoder.h JPEGDecoder.cpp

CJPEGEncoder Class ReferenceJPEG file encoder. Uses the independent JPEG group's library to do the actual conversion. #include <JPEGEncoder.h>

Inheritance diagram for CJPEGEncoder:

Public Methods 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.

Protected Methods void DoEncode (CBmp *pBmp, CDataSink *pDataSink)Sets up the jpeg library data source and error handler and calls the jpeg encoder.

Private Methods void encodeRGB (CBmp *pBmp, int iScanLines)Assumes IJPEG decoder is already set up.

Private Attributes jpeg_compress_struct * m_pcinfoIJPEG encoder state.

jpeg_error_mgr * m_pjerrCustom error manager.

int iQuality_ bool bOptimizeCoding_ int iSmoothingFactor_ unsigned int uiDensityX_ unsigned int uiDensityY_

The documentation for this class was generated from the following files: JPEGEncoder.h JPEGEncoder.cpp

CLightnessDlg Class ReferenceThis dialog interfaces between the user's input and the lightness filter. #include <LightnessDlg.h>

Public Types enum { IDD = IDD_LIGHTNESS }

Public Methods CLightnessDlg (CWnd *pParent=NULL)

Public Attributes int m_Lightness

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

Detailed Description

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

Definition at line 18 of file LightnessDlg.h.

The documentation for this class was generated from the following files: LightnessDlg.h LightnessDlg.cpp

CMainFrame Class ReferenceThe CMainFrame class provides the functionality of a Windows single document interface (SDI). #include <MainFrm.h>

Public Methods CMainFrame () void SetProgressInfo (UINT part)Sets the progress indicator status

Parameters: part Active progress info (in percents).

virtual ~CMainFrame ()

Protected Methods afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct) afx_msg void OnHelpInfo (HELPINFO *pHelpInfo) afx_msg void OnPaletteChanged (CWnd *pFocusWnd) afx_msg BOOL OnQueryNewPalette () afx_msg void OnActivate (UINT nState, CWnd *pWndOther, BOOL bMinimized) afx_msg void OnViewToolbar () afx_msg void OnUpdateViewToolbar (CCmdUI *pCmdUI) afx_msg void OnViewStatusbar () afx_msg void OnUpdateViewStatusbar (CCmdUI *pCmdUI) afx_msg void OnViewMenu () afx_msg void OnUpdateViewMenu (CCmdUI *pCmdUI) afx_msg void OnUpdatePanels (CCmdUI *pCmdUI)when there's no (active) view, this handler will get precedence.

Protected Attributes CCeCommandBar m_wndMenuBarMenu bar object.

CToolBar m_wndToolBarTool bar object.

CReBar m_wndReBarReBar bar object (enables bar manipulation).

CStatusBar m_wndStatusBarStatus bar object.

Detailed Description

The CMainFrame class provides the functionality of a Windows single document interface (SDI), along with members for managing the window. In addition, it handles the progress notification mechanism, and manages the bars (menu/tool/status).

Definition at line 20 of file MainFrm.h.

Member Function Documentation

void CMainFrame::OnHelpInfo (HELPINFO * pHelpInfo) [protected]m_wndReBar.AddBar(&m_wndDlgBar) ||

Definition at line 117 of file MainFrm.cpp.

118 {119 // TODO: implement help here120 MessageBox(_T("Help"));121 }

BOOL CMainFrame::OnQueryNewPalette () [protected]Big time: we're getting focus, so let's give the active view an opportunity to realize its palette.

Definition at line 158 of file MainFrm.cpp.

159 {160 // always realize the palette for the active view161 CView* pView = GetActiveView();162 ASSERT(pView != NULL);163 164 // just notify the target view165 return (BOOL) pView->SendMessage(WM_DOREALIZE, (WPARAM)pView->m_hWnd);166 }

The documentation for this class was generated from the following files: MainFrm.h MainFrm.cpp

CMemSource Class ReferenceThis is a class which takes a memory pointer as a source of picture data. #include <MemSource.h>

Inheritance diagram for CMemSource:

Public Methods CMemSource () virtual ~CMemSource () virtual int Open (unsigned char *pek, int size) virtual void Close () virtual BYTE * ReadNBytes (int n)This needs to be overridden in derived classes.

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!

Private Attributes BYTE * m_pCurPos

The documentation for this class was generated from the following files: MemSource.h MemSource.cpp

ContributionType Struct ReferenceContirbution information for a single pixel. #include <2PassScale.h>

Public Attributes double * WeightsNormalized weights of neighboring pixels.

int Left int RightBounds of source pixels window.

The documentation for this struct was generated from the following file: 2PassScale.h

COptionsPage1 Class ReferenceThis class implements the first page of ImageViewer options tabbed panes. This page represents the Viewer properties. #include <OptionsPage1.h>

Public Types enum { IDD = IDD_OPTIONS_PAGE1 }

Public Methods COptionsPage1 () ~COptionsPage1 ()

Public Attributes BOOL m_bViewAllImages BOOL m_bExitAfterDelete BOOL m_bViewFullFilePath BOOL m_bViewMenu BOOL m_bViewStatusBar BOOL m_bViewToolBar

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

The documentation for this class was generated from the following files: OptionsPage1.h OptionsPage1.cpp

COptionsPage2 Class ReferenceThis class implements the second page of ImageViewer options tabbed panes. This page represents the Slide Show properties. #include <OptionsPage2.h>

Public Types enum { IDD = IDD_OPTIONS_PAGE2 }

Public Methods COptionsPage2 () ~COptionsPage2 ()

Public Attributes CSliderCtrl m_ctrlDelaySlide CEdit m_ctrlDelayEdit UINT m_nDelay int m_iSlideShowSequence BOOL m_bSlideShowWrap CString m_strDelaySeconds

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) CString GetDelayString (UINT nDelay) const virtual BOOL OnInitDialog () afx_msg void OnChangeDelayEdit () afx_msg void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) int GetDelayPositionInArray ()Returns the (nearset) index of the m_nDelay in the delay array.

Protected Attributes int m_nConstDelay [37]The delay array, representing 37 fixed pre-determind delays.

The documentation for this class was generated from the following files: OptionsPage2.h OptionsPage2.cpp

COptionsPage3 Class ReferenceThis class implements the third page of ImageViewer options tabbed panes. This page represents the filing (as in "file") properties. #include <OptionsPage3.h>

Public Types enum { IDD = IDD_OPTIONS_PAGE3 } enum { Replace, Ask }

Public Methods COptionsPage3 () ~COptionsPage3 ()

Public Attributes CEdit m_ctrlSeparatorEdit CComboBox m_ctrlMoveCopyCombo CString m_strSeparator int m_iMoveCopyConfirm BOOL m_bNoConfirm BOOL m_bNoRecycleBin BOOL m_bSkipIdentical

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual BOOL OnInitDialog ()

The documentation for this class was generated from the following files: OptionsPage3.h OptionsPage3.cpp

CPalViewDlg Class ReferenceThis class implements a dialog that displays the current image palette. It contains a 16x16 color matrix, in which each element represents a single palette color. #include <PalViewDlg.h>

Public Types enum { IDD = IDD_PALETTE }

Public Methods CPalViewDlg (CWnd *pParent, CPixel32 *pPal)

Public Attributes CStatic m_PalFrameCtrl

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) afx_msg void OnPaint ()

Private Attributes CPixel32 * m_pPalThe active palette as a vector array.

The documentation for this class was generated from the following files: PalViewDlg.h PalViewDlg.cpp

CPCXDecoder Class ReferencePCX 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. #include <PCXDecoder.h>

Inheritance diagram for CPCXDecoder:

Public Methods CPCXDecoder ()Creates a decoder.

virtual ~CPCXDecoder ()Destroys a decoder.

Protected Methods 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.

Private Methods void PCX_PlanesToPixels (BYTE *pixels, BYTE *bitplanes, short bytesperline, short planes, short bitsperpixel) void PCX_UnpackPixels (BYTE *pixels, BYTE *bitplanes, short bytesperline, short planes, short bitsperpixel)

The documentation for this class was generated from the following files: PCXDecoder.h PCXDecoder.cpp

CPGMDecoder Class ReferencePortable Graymap file decoder. Delivers an 8 bpp grayscale image. #include <PGMDecoder.h>

Inheritance diagram for CPGMDecoder:

Public Methods CPGMDecoder ()Creates a decoder.

virtual ~CPGMDecoder ()Destroys a decoder.

Protected Methods 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.

Private Methods void readPgmHeader (PGMHEADER *pPgmHead, CDataSource *pDataSrc) int readASCIIDecimal (CDataSource *pDataSrc) void skipComment (CDataSource *pDataSrc) void skipPgmASCIISeparators (CDataSource *pDataSrc) BYTE * readASCIILine (CDataSource *pDataSrc) void setGrayPalette (CPixel32 **ppPal) void readImage (PGMHEADER *pPgmHead, CBmp *pBmp, CPixel32 **ppPal, int DestBPP, CDataSource *pDataSrc) void readData (PGMHEADER *pPgmHead, CBmp *pBmp, CPixel32 *pPal, int DestBPP, CDataSource *pDataSrc) void expandASCIILine (BYTE *pDest, int MaxGrayValue, int Width, int bpp, CDataSource *pDataSrc, CPixel32 *pPal, int DestBPP) void expandByteLine (BYTE *pDest, int MaxGrayValue, int Width, int bpp, CDataSource *pDataSrc, CPixel32 *pPal, int DestBPP) CPixel32 CPGMDecoder::readASCIIPixel32 (int MaxGrayValue, int bpp, CDataSource *pDataSrc, CPixel32 *pPal) BYTE CPGMDecoder::readASCIIPixel8 (int MaxGrayValue, int bpp, CDataSource *pDataSrc)

Private Attributes BYTE m_LastByte bool m_UseLastByte

The documentation for this class was generated from the following files: PGMDecoder.h PGMDecoder.cpp

CPicDecoder Class ReferenceCPicDecoder is an abstract base class. It defines common routines for all decoders. #include <PicDecoder.h>

Inheritance diagram for CPicDecoder:

Public Methods CPicDecoder ()Empty constructor. The actual initialization takes place in a derived class.

virtual ~CPicDecoder ()

Destructor. Frees memory allocated.

virtual void MakeBmpFromFile (CString pszFName, CBmp *pBmp, int BPPWanted=0, IProgressNotification *pProgNot=NULL)Decodes a picture in a file and stores the results in pBmp. Parameters:

BPPWanted 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 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 Public Methods 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.

void raiseError (int Code, char *pszErr) void Trace (int TraceLevel, const char *pszMessage)Called to output status messages to the current debug console.

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

void Expand1bpp (BYTE *pDest, BYTE *pSrc, int Width, CPixel32 *pPal) void Expand2bpp (BYTE *pDest, BYTE *pSrc, int Width, CPixel32 *pPal) void Expand4bpp (BYTE *pDest, BYTE *pSrc, int Width, CPixel32 *pPal) void Expand8bpp (BYTE *pDest, BYTE *pSrc, int Width, CPixel32 *pPal) BYTE ReadByte (CDataSource *pDataSrc) WORD ReadIWord (CDataSource *pDataSrc) WORD ReadMWord (CDataSource *pDataSrc) LONG ReadILong (CDataSource *pDataSrc) LONG ReadMLong (CDataSource *pDataSrc) void CalcDestBPP (int SrcBPP, int *DestBPP)

Static Private Attributes int m_TraceLevel = 00: Trace only errors. 1: Trace top-level calls. 2: Trace picture format info. 3: Trace misc. info.

char * m_pszTraceFName = NULLName of trace file. NULL if trace to MSVC debug console.

The documentation for this class was generated from the following files: PicDecoder.h PicDecoder.cpp

CPicEncoder Class ReferenceCPicEncoder 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. #include <PicEncoder.h>

Inheritance diagram for CPicEncoder:

Public Methods CPicEncoder ()Empty constructor. The actual initialization takes place in a derived class.

virtual ~CPicEncoder ()Destructor. Frees memory allocated.

virtual void MakeFileFromBmp (const CString, CBmp *)Encodes a bitmap to a file and stores.

virtual void SaveBmp (CBmp *, CDataSink *)Encodes a picture to a pre-existing data destination (sink).

void SetTraceConfig (int Level, char *pszFName) void Trace (int TraceLevel, const char *pszMessage)

Static Public Methods void raiseError (int Code, char *pszErr)This function is needed by callbacks outside of any object, so it's public and static. It should not be called from outside of the library.

Protected Methods virtual void DoEncode (CBmp *pBmp, CDataSink *pDataSrc)=0Implements the actual encoding process. Uses variables local to the object to retrieve and store the data. Implemented in derived classes.

The documentation for this class was generated from the following files: PicEncoder.h PicEncoder.cpp

CPictDecoder Class ReferenceThis class decodes macintosh PICT files with 1,2,4,8,16 and 32 bits per pixel as well as PICT/JPEG. #include <PictDecoder.h>

Inheritance diagram for CPictDecoder:

Public Methods CPictDecoder (CJPEGDecoder *pJPEGDecoder)Creates a decoder. A JPEG decoder is needed to decode PICT files containing JPEGs.

virtual ~CPictDecoder ()Destroys a decoder.

Protected Methods virtual void DoDecode (CBmp *pBmp, CPixel32 **ppPal, int *pDestBPP, CDataSource *pDataSrc)Does the actual decoding after a data source has been set up.

Private Methods void readHeader (CDataSource *pDataSrc, int &Version) void interpretOpcodes (CBmp *pBmp, CPixel32 **ppPal, int *pDestBPP, CDataSource *pDataSrc, int &Version) WORD readOpcode (int Version, CDataSource *pDataSrc) void clip (CDataSource *pDataSrc) void pixPat (CDataSource *pDataSrc) void skipPolyOrRegion (CDataSource *pDataSrc) void bitsRect (CDataSource *pDataSrc, CPixel32 **ppPal, CBmp *pBmp, int *pDestBPP) void bitsRegion (CDataSource *pDataSrc, CPixel32 **ppPal, CBmp *pBmp, int *pDestBPP) void opcode9a (CDataSource *pDataSrc, int *pDestBPP, CBmp *pBmp, CPixel32 **ppPal) void longComment (CDataSource *pDataSrc) void jpegOp (CDataSource *pDataSrc, CBmp *pBmp, int *pDestBPP) void createOutputBmp (MacpixMap PixMap, int DestBPP, CBmp *pBmp) void doBitmap (int rowBytes, BOOL bIsRegion, CPixel32 **ppPal, CBmp *pBmp, int *pDestBPP, CDataSource *pDataSrc) void doPixmap (int rowBytes, BOOL bIsRegion, CPixel32 **ppPal, CBmp *pBmp, int *pDestBPP, CDataSource *pDataSrc)

void unpack32bits (MacRect *pBounds, WORD rowBytes, int NumBitPlanes, CBmp *pBmp, CDataSource *pDataSrc) void unpack8bits (MacRect *pBounds, WORD rowBytes, CBmp *pBmp, CDataSource *pDataSrc, CPixel32 **ppPal, int DestBPP) void unpackbits (MacRect *pBounds, WORD rowBytes, int pixelSize, CBmp *pBmp, CDataSource *pDataSrc, CPixel32 **ppPal, int DestBPP) void skipBits (MacRect *pBounds, WORD rowBytes, int pixelSize, CDataSource *pDataSrc) void expandBuf (BYTE *pDestBuf, BYTE *pSrcBuf, int Width, int bpp, CPixel32 *pPal) void expandBuf8 (BYTE *pDestBuf, BYTE *pSrcBuf, int Width, int bpp) void readPixmap (MacpixMap *pPixMap, CDataSource *pDataSrc) CPixel32 * readColourTable (WORD *pNumColors, CDataSource *pDataSrc) void readRect (MacRect *pr, CDataSource *pDataSrc) void dumpRect (char *psz, MacRect *pr) void tracePixMapHeader (int Level, MacpixMap *pPixMap)

Private Attributes CJPEGDecoder * m_pJPEGDecoder

Detailed Description

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.

Definition at line 31 of file PictDecoder.h.

The documentation for this class was generated from the following files: PictDecoder.h PictDecoder.cpp

CPixel32 Class Reference32 bit pixel class. A pixel in this class contains 8 bits each of. #include <Pixel32.h>

Public Methods 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.

Private Attributes BYTE m_Data [4]

The documentation for this class was generated from the following file: Pixel32.h

CPNGDecoder Class ReferencePNG file decoder. Uses LibPng to do the actual decoding. #include <PNGDecoder.h>

Inheritance diagram for CPNGDecoder:

Public Methods CPNGDecoder ()Creates a decoder.

virtual ~CPNGDecoder ()Destroys a decoder.

Protected Methods 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.

Static Private Methods void CPNGDecoder::user_error_fn (png_structp png_ptr, png_const_charp error_msg) void CPNGDecoder::user_warning_fn (png_structp png_ptr, png_const_charp warning_msg)

Detailed Description

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.

Definition at line 28 of file PNGDecoder.h.

The documentation for this class was generated from the following files: PNGDecoder.h PNGDecoder.cpp

CPNGEncoder Class ReferencePNG file encoder. Uses LIBPNG to do the actual conversion. #include <PNGEncoder.h>

Inheritance diagram for CPNGEncoder:

Public Methods CPNGEncoder ()Creates an encoder.

virtual ~CPNGEncoder ()Destroys a encoder.

CDataSink * GetDataSink ()

Protected Methods virtual void DoEncode (CBmp *pBmp, CDataSink *pDataSnk)Sets up LIBPNG environment and calls LIBPNG to encode an image.

Private Attributes CBmp * m_pBmp CDataSink * m_pDataSnk

The documentation for this class was generated from the following files: PNGEncoder.h PNGEncoder.cpp

CPreviewFileDlg Class ReferenceThis dialog replaces the good old MFC's CFileDialog. It adds a preview pane for a chosen image in list. #include <PreviewFileDlg.h>

Public Methods CPreviewFileDlg (BOOL bOpenFileDialog, LPCTSTR lpszDefExt=NULL, LPCTSTR lpszFileName=NULL, DWORD dwFlags=OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter=NULL, CWnd *pParentWnd=NULL)

Protected Methods afx_msg void OnPreview () afx_msg BOOL OnQueryNewPalette () afx_msg void OnPaletteChanged (CWnd *pFocusWnd) afx_msg void OnSetFocus (CWnd *pOldWnd) virtual BOOL OnInitDialog () virtual void OnFileNameChange ()

Private Attributes BOOL m_bPreviewTrue to enable preview, else disable.

CDIBStatic m_DIBStaticCtrlThe preview image object.

The documentation for this class was generated from the following files: PreviewFileDlg.h PreviewFileDlg.cpp

CRenameFileDlg Class ReferenceThis class implements the file renaming dialog. #include <RenameFileDlg.h>

Public Types enum { IDD = IDD_RENAME_FILE }

Public Methods CRenameFileDlg (const CString &strOldFilename=_T(""), CWnd *pParent=NULL)

Public Attributes CString m_strNewFilename

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

The documentation for this class was generated from the following files: RenameFileDlg.h RenameFileDlg.cpp

CResourceSource Class ReferenceThis is a class which takes a windows resource as a source of picture data. #include <ResourceSource.h>

Inheritance diagram for CResourceSource:

Public Methods CResourceSource () virtual ~CResourceSource () virtual int Open (HINSTANCE lh_ResInst, int ResourceID, CString pResType="") virtual void Close () virtual BYTE * ReadNBytes (int n)This needs to be overridden in derived classes.

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!

Private Attributes HRSRC m_hRsrc HGLOBAL m_hGlobal BYTE * m_pCurPos

The documentation for this class was generated from the following files: ResourceSource.h ResourceSource.cpp

CRotateDlg Class ReferenceThis dialog interfaces between the user's input and the rotate filter. #include <RotateDlg.h>

Public Types enum { IDD = IDD_ROTATEFILTER }

Public Methods CRotateDlg (CWnd *pParent=NULL)

Public Attributes CEdit m_AngleEdit CSliderCtrl m_SliderCtrl double m_Angle

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) virtual BOOL OnNotify (WPARAM wParam, LPARAM lParam, LRESULT *pResult) virtual void OnOK () virtual BOOL OnInitDialog ()

The documentation for this class was generated from the following files: RotateDlg.h RotateDlg.cpp

CTextException Class ReferenceAn object of this class is thrown by other classes when an error occurs. #include <TextException.h>

Public Methods CTextException (int Code, const CString pszErr)Creates an exception.

CTextException (const CTextException &ex)Copy constructor.

virtual ~CTextException ()Destroys an exception.

virtual int GetCode () constReturns 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 unsigned short * () constThis operator allows the exception to be treated as a string whenever needed. The string contains the error message.

virtual operator const CString () constThis operator allows the exception to be treated as a string whenever needed. The string contains the error message.

Private Attributes int m_CodeError code number.

CString m_pszErrError string.

Detailed Description

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.

Definition at line 37 of file TextException.h.

The documentation for this class was generated from the following files: TextException.h TextException.cpp

CTGADecoder Class ReferenceTarga 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. #include <TGADecoder.h>

Inheritance diagram for CTGADecoder:

Public Methods CTGADecoder ()Creates a decoder.

virtual ~CTGADecoder ()Destroys a decoder.

Protected Methods 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.

Private Methods void readTgaHeader (TGAHEADER *pTgaHead, CDataSource *pDataSrc)Fills TGAHEADER structure with the information in the file.

void readPalette (int StartIndex, int Length, int EntrySize, CBmp *pBmp, CPixel32 **ppPal, int DestBPP, CDataSource *pDataSrc)Reads the TGA palette and creates a windows palette.

void setGrayPalette (CPixel32 **ppPal)Creates a standalone RGBA grayscale palette.

void readImage (TGAHEADER *pTgaHead, CBmp *pBmp, CPixel32 **ppPal, int DestBPP, CDataSource *pDataSrc)Determines compression type and calls readData.

void readData (TGAHEADER *pTgaHead, BOOL bCompressed, CBmp *pBmp, CPixel32 *pPal, int DestBPP, CDataSource *pDataSrc)Reads image data line-by-line.

void expandUncompressedLine (BYTE *pDest, int Width, BOOL bReversed, int bpp, CDataSource *pDataSrc, CPixel32 *pPal, int DestBPP)Decodes one line of uncompressed image data.

void expandCompressedLine (BYTE *pDest, int Width, BOOL bReversed, int bpp, CDataSource *pDataSrc, CPixel32 *pPal, int DestBPP)Decodes one line of compressed image data.

CPixel32 readPixel32 (int bpp, CDataSource *pDataSrc, CPixel32 *pPal)Reads one image pixel and returns it in RGBA format.

BYTE readPixel8 (int bpp, CDataSource *pDataSrc)Reads one image pixel and returns it in 8-bit format.

Member Function Documentation

void CTGADecoder::readData (TGAHEADER * pTgaHead, BOOL bCompressed, CBmp * pBmp, CPixel32 * pPal, int DestBPP, CDataSource * pDataSrc) [private]

Parameters: pTgaHead Pointer to TGA header structure

Definition at line 168 of file TGADecoder.cpp.

References expandUncompressedLine().

Referenced by readImage().

175 {176 int Width = pTgaHead->ImageWidth;177 int Height = pTgaHead->ImageHeight;178 int bpp = pTgaHead->PixelDepth;179 180 // Bits 4 & 5 of the Image Descriptor byte control the ordering of181 // the pixels.182 BOOL bXReversed = ((pTgaHead->ImagDesc & 16) == 16);183 BOOL bYReversed = ((pTgaHead->ImagDesc & 32) == 32);184 185 BYTE * pDest;186 pBmp->Lock(false, true);187 TRY188 {189 BYTE ** pLineArray = pBmp->GetLineArray();190 191 int y;

192 193 for (y=0; y < Height; y++)194 {195 if (bYReversed)196 pDest = pLineArray[y];197 else198 pDest = pLineArray[Height-y-1];199 200 if (!bCompressed)201 expandUncompressedLine (pDest, Width, bXReversed, bpp, pDataSrc, pPal, DestBPP);202 else203 expandCompressedLine (pDest, Width, bXReversed, bpp, pDataSrc, pPal, DestBPP);204 }205 pBmp->Unlock();206 }207 CATCH_ALL (pEx)208 {209 pBmp->Unlock();210 THROW_LAST();211 }212 END_CATCH_ALL213 }

void CTGADecoder::readImage (TGAHEADER * pTgaHead, CBmp * pBmp, CPixel32 ** ppPal, int DestBPP, CDataSource * pDataSrc) [private]

Parameters: pTgaHead Pointer to TGA header structure

Definition at line 135 of file TGADecoder.cpp.

References readData().Referenced by setGrayPalette().

141 {142 BOOL bCompressed;143 144 if (pTgaHead->ImageType == TGA_Mono ||145 pTgaHead->ImageType == TGA_RLEMono)146 setGrayPalette (ppPal);147 148 switch (pTgaHead->ImageType)149 {150 case TGA_Map:151 case TGA_RGB:152 case TGA_Mono:153 bCompressed = FALSE;154 break;155 case TGA_RLEMap:156 case TGA_RLERGB:157 case TGA_RLEMono:158 bCompressed = TRUE;159 break;160 default:161 raiseError (ERR_FORMAT_UNKNOWN, "Unknown TGA image type.");162 }163 readData (pTgaHead, bCompressed, pBmp, *ppPal, DestBPP, pDataSrc);164 }

void CTGADecoder::readPalette (int StartIndex, int Length, int EntrySize, CBmp * pBmp, CPixel32 ** ppPal, int DestBPP, CDataSource * pDataSrc) [private]

Parameters: StartIndex Index of first palette entry. Length Number of palette entries stored. EntrySize Size of palette entries in bits.

Definition at line 94 of file TGADecoder.cpp.

References setGrayPalette().

Referenced by readTgaHeader().

103 {104 int i;105 106 *ppPal = new CPixel32 [256];107 if (!(*ppPal))108 raiseError (ERR_NO_MEMORY, "Out of memory for palette.");109 110 for (i=StartIndex; i<StartIndex+Length; i++)111 {112 (*ppPal)[i] = readPixel32 (EntrySize, pDataSrc, *ppPal);113 }114 115 if (DestBPP == 8)116 pBmp->SetPalette ((CPixel32*)*ppPal);117 }

void CTGADecoder::readTgaHeader (TGAHEADER * pTgaHead, CDataSource * pDataSrc) [private]

Parameters: pTgaHead Pointer to TGA header structure

Definition at line 70 of file TGADecoder.cpp.

References readPalette().Referenced by DoDecode().

73 {74 // Read the TGA header (Version 1.0 and 2.0).75 pTgaHead->IdLength = ReadByte (pDataSrc);76 pTgaHead->CmapType = ReadByte (pDataSrc);77 pTgaHead->ImageType = ReadByte (pDataSrc);78 pTgaHead->CmapIndex = ReadIWord (pDataSrc);79 pTgaHead->CmapLength = ReadIWord (pDataSrc);80 pTgaHead->CmapEntrySize = ReadByte (pDataSrc);81 pTgaHead->X_Origin = ReadIWord (pDataSrc);82 pTgaHead->Y_Origin = ReadIWord (pDataSrc);83 pTgaHead->ImageWidth = ReadIWord (pDataSrc);84 pTgaHead->ImageHeight = ReadIWord (pDataSrc);85 pTgaHead->PixelDepth = ReadByte (pDataSrc);86 pTgaHead->ImagDesc = ReadByte (pDataSrc);87 88 // Skip image ID89 pDataSrc->Skip (pTgaHead->IdLength);90 }

The documentation for this class was generated from the following files: TGADecoder.h TGADecoder.cpp

CThresholdDlg Class ReferenceThis dialog interfaces between the user's input and the threshold filter. #include <ThresholdDlg.h>

Public Types enum { IDD = IDD_THRESHOLDFILTER }

Public Methods int GetMaxThreshold () int GetChannel () int GetMinThreshold () CThresholdDlg (CWnd *pParent=NULL)

Public Attributes int m_threshold_max int m_threshold_min int m_channel

Protected Methods virtual void DoDataExchange (CDataExchange *pDX) afx_msg void OnBlueRadio () afx_msg void OnGreenRadio () afx_msg void OnRedRadio () virtual void OnOK ()

The documentation for this class was generated from the following files: ThresholdDlg.h ThresholdDlg.cpp

CTIFFDecoder Class ReferenceTIFF file decoder. Uses LIBTIFF to do the actual conversion. Supports 1, 8 and 24 bits per pixel as output formats. #include <TIFFDecoder.h>

Inheritance diagram for CTIFFDecoder:

Public Methods CTIFFDecoder ()Creates a decoder.

virtual ~CTIFFDecoder ()Destroys a decoder.

Protected Methods virtual void DoDecode (CBmp *pBmp, CPixel32 **ppPal, int *pDestBPP, CDataSource *pDataSrc)Sets up LIBTIFF environment and calls LIBTIFF to decode an image.

virtual void DoTiffDecode (CBmp *pBmp, CPixel32 **ppPal, int *pDestBPP, CDataSource *pDataSrc, TIFF *tiff)

Private Methods void doHiColor (TIFF *tif, CBmp *pBmp, int *pDestBPP) void doLoColor (TIFF *tif, CBmp *pBmp, int *pDestBPP, CPixel32 **ppPal)

Static Private Methods void Win32WarningHandler (const char *module, const char *fmt, va_list ap)Callback from the TIFF library. Should be accessed only by the TIFF decoder and libtiff.

void Win32ErrorHandler (const char *module, const char *fmt, va_list ap)Callback from the TIFF library. Should be accessed only by the TIFF decoder and libtiff.

Static Private Attributes char m_szLastErr [256]Temporary storage for an error message. Used in the callbacks, so it's static.

Friends class _tiff_helper class CTIFFEncoder

The documentation for this class was generated from the following files: TIFFDecoder.h TIFFDecoder.cpp

CTIFFEncoder Class ReferenceTIFF file encoder. Uses LIBTIFF to do the actual conversion. #include <TIFFEncoder.h>

Inheritance diagram for CTIFFEncoder:

Public Methods CTIFFEncoder ()Creates an encoder.

virtual ~CTIFFEncoder ()Destroys a encoder.

Protected Methods 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.

The documentation for this class was generated from the following files: TIFFEncoder.h TIFFEncoder.cpp

CTIFFEncoderEx Class ReferenceCTIFFEncoder is provided in order to have greater compress/data control. #include <TIFFEncoderEx.h>

Inheritance diagram for CTIFFEncoderEx:

Public Methods 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 Methods virtual void DoEncode (CBmp *, CDataSink *=0)Sets up LIBTIFF environment and calls LIBTIFF to encode an image.

Private Attributes TIFF * m_TiffToken

The documentation for this class was generated from the following files: TIFFEncoderEx.h TIFFEncoderEx.cpp

CTimestampDlg Class ReferenceThis dialog implements the Change Timestamp feature of a given image filename. #include <TimestampDlg.h>

Public Types enum { IDD = IDD_TIMESTAMP }

Public Methods CTimestampDlg (CWnd *pParent=NULL)

Public Attributes int m_iChange

Protected Methods virtual void DoDataExchange (CDataExchange *pDX)

The documentation for this class was generated from the following files: TimestampDlg.h TimestampDlg.cpp

CVideoInvertFilter Class ReferenceThis filter inverts a given CBmp. Only works for 32 bpp bitmaps at the moment. #include <VideoInvertFilter.h>

Inheritance diagram for CVideoInvertFilter:

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

virtual double Filter (double dVal) CVideoInvertFilter () virtual ~CVideoInvertFilter ()

The documentation for this class was generated from the following files: VideoInvertFilter.h VideoInvertFilter.cpp

CWinBmp Class ReferenceThis is the windows version of CBmp. #include <WinBmp.h>

Inheritance diagram for CWinBmp:

Public Methods CWinBmp ()Creates an empty bitmap.

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.

void AlphaBlt (CWinBmp *pSrcBmp, int x, int y)Do a bitblt using the alpha channel of pSrcBmp. Restricted to 32 bpp. Legacy routine. Use the Blt classes instead.

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 Public Methods long GetMemNeeded (LONG width, LONG height, WORD BitsPerPixel)Returns memory needed by a bitmap with the specified attributes.

long GetBitsMemNeeded (LONG width, LONG height, WORD BitsPerPixel)Returns memory needed by bitmap bits.

int GetLineMemNeeded (LONG width, WORD BitsPerPixel)Returns memory needed by one line.

Protected Methods 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.

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.

Protected Attributes BITMAPINFOHEADER * m_pBMIPointer to picture format information.

BYTE * m_pBits

The actual bitmap data.

The documentation for this class was generated from the following files: WinBmp.h WinBmp.cpp

CZoomView Class ReferenceThis is the application zoom frame view object. It can handle various zooming procedures such as: zooming in, zooming out, box zooming etc. #include <zoomview.h>

Inheritance diagram for CZoomView:

Public Types enum ZoomMode_ { MODE_ZOOMOFF, MODE_ZOOMIN, MODE_ZOOMOUT }

Public Methods void SetZoomSizes (SIZE sizeTotal, const SIZE &sizePage=sizeDefault, const SIZE &sizeLine=sizeDefault)Set up the CZoomView class with the logical page size, and scrolling page/line units. This replaces CScrollView::SetScrollSizes.

void CenterOnLogicalPoint (CPoint ptCenter)Same as CScrollView::CenterOnPoint, but for logical coordinates.

CPoint GetLogicalCenterPoint (void)Get the center of screen in logical coordinates.

void SetZoomMode (ZoomMode_ zoomMode)Put the view into the specified zoom mode.

ZoomMode_ GetZoomMode ()Get the view's current zoom mode.

int DoZoomIn (CRect &rect)Zoom the view in on a rect.

int DoZoomIn (CPoint *point=NULL, double delta=1.25)Zoom the view in on a point by the specified scale factor.

int DoZoomOut (CPoint *point=NULL, double delta=1.25)Zoom the view out on a point by one scale factor.

int DoZoomFull () double GetZoomRatio () constGet current zoom ratio.

void SetZoomRatio (double r)Sets current zoom ratio.

virtual void NotifyZoom (void)Override this to get notified of zoom scale change.

void ViewDPtoLP (LPPOINT lpPoints, int nCount=1)Same as DPtoLP, but gets the Client DC for the view.

void ViewLPtoDP (LPPOINT lpPoints, int nCount=1)Same as LPtoDP, but gets the Client DC for the view.

void ClientToDevice (CPoint &point)Convert from Client coordinates to relative Device coordinates.

void NormalizeRect (CRect &rect)Normalize the rectangle.

void DrawBox (CDC &dc, CRect &rect, BOOL xor=TRUE)Draw a box.

Parameters: xor True when erasing is needed.

void DrawLine (CDC &dc, const int &x1, const int &y1, const int &x2, const int &y2, BOOL xor=TRUE)Draw a line.

Parameters: xor True when erasing is needed.

afx_msg void OnLButtonDown (UINT nFlags, CPoint point) afx_msg void OnLButtonUp (UINT nFlags, CPoint point) afx_msg void OnMouseMove (UINT nFlags, CPoint point) afx_msg void OnRButtonDown (UINT nFlags, CPoint point) afx_msg BOOL OnSetCursor (CWnd *pWnd, UINT nHitTest, UINT message)

Protected Methods CZoomView ()protected constructor used by dynamic creation.

virtual ~CZoomView () virtual void OnDraw (CDC *pDC)

virtual void OnPrepareDC (CDC *pDC, CPrintInfo *pInfo=NULL)Override of CScrollView for MM_ANISOTROPIC zoom mode.

void CalcBars (void)Update the scrollbars - uses logical units. Call when the Viewport changes size.

Protected Attributes BOOL m_bCapturedCapture the mouse for zooming in.

CRect m_ptDragRectZooming drag rectangle.

ZoomMode_ m_zoomModeCurrent zoom mode.

Private Methods void PersistRatio (const CSize &orig, CSize &dest, CPoint &remainder)Make a size maintain the given ratio (by shrinking if nescessary).

Private Attributes CSize m_origTotalDevOriginal total size in device units.

CSize m_origPageDevOriginal per page scroll size in device units.

CSize m_origLineDevOriginal per line scroll size in device units.

double m_zoomScaleZoom scale ratio.

HCURSOR m_hZoomCursorHandle for zooming cursor.

The documentation for this class was generated from the following files:

zoomview.h ZoomView.cpp

DIBINFO Struct ReferenceHolds DIB information. #include <DIBSectionLite.h>

Public Methods operator LPBITMAPINFO () operator LPBITMAPINFOHEADER () RGBQUAD * ColorTable ()

Public Attributes RGBQUAD arColors [255]Color table info - adds an extra 255 entries to palette.

The documentation for this struct was generated from the following file: DIBSectionLite.h

IProgressNotification Class ReferenceUsed to implement a progress indicator when opening image files. #include <IProgressNotification.h>

Inheritance diagram for IProgressNotification:

Public Methods virtual void OnProgress (double Part)=0Called during decoding as progress gets made.

The documentation for this class was generated from the following file: IProgressNotification.h

LineContribType Struct ReferenceContribution information for an entire line (row or column). #include <2PassScale.h>

Public Attributes ContributionType * ContribRowRow (or column) of contribution weights.

int WindowSizeFilter window size (of affecting source pixels).

int LineLengthLength of line (no. or rows / cols).

The documentation for this struct was generated from the following file: 2PassScale.h

OpDef Struct ReferenceTable of the first 200 or so PICT opcodes with size & description. Mostly stolen from pict2pbm. I hope they don't mind. #include <optable.h>

Public Attributes char * name int len char * description

The documentation for this struct was generated from the following file: optable.h

tagPCXHEADER Struct ReferencePCX Image File. #include <pcx.h>

Public Attributes char Manufactureralways 0X0A.

char Versionversion number.

char Encodingalways 1.

char BitsPerPixelcolor bits.

WORD Xmin WORD Yminimage origin.

WORD Xmax WORD Ymaximage dimensions.

WORD Hres WORD Vresresolution values.

BYTE ColorMap [16][3]color palette.

char Reserved char ColorPlanescolor planes.

WORD BytesPerLineline buffer size.

WORD PaletteTypegrey or color palette.

char Filter [58]

The documentation for this struct was generated from the following file: pcx.h

ImageViewer File Documentation

pgm.h File Reference

Compounds struct _PgmHeader

Defines #define PGM_MAXLINESIZE  80Maximum number of characters per line.

#define PGM_P2  0Definitions for image types.

#define PGM_P5  1

Typedefs typedef _PgmHeader PGMHEADER

Detailed Description Defines structures and constants present in PGM files.

Definition in file pgm.h.

pixeldefs.h File Reference< MS Windows ordering< GNU/Linux (at least).

Defines #define PIXEL_BGRA_ORDERWe have this pixel byte ordering.

#define RGBA_BLUE  0 #define RGBA_GREEN  1 #define RGBA_RED  2 #define RGBA_ALPHA  3

Detailed Description Define the pixel format for RGB-bitmaps. Change this if you change the order of the color components.

Definition in file pixeldefs.h.

qdraw.h File Reference

Compounds struct MacPattern struct MacpixMap struct MacPoint struct MacRect struct MacRGBColour

Detailed Description 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.

Definition in file qdraw.h.

tga.h File Reference

Compounds struct _TgaHeader

Defines #define TGA_Null  0Definitions for image types.

#define TGA_Map  1 #define TGA_RGB  2 #define TGA_Mono  3 #define TGA_RLEMap  9 #define TGA_RLERGB  10 #define TGA_RLEMono  11 #define TGA_CompMap  32 #define TGA_CompMap4  33

Typedefs typedef _TgaHeader TGAHEADER

Detailed Description Defines structures and constants present in TGA files.

Definition in file tga.h.

windefs.h File Reference

Compounds struct tagWINBITMAPFILEHEADER struct tagWINBITMAPINFO struct tagWINBITMAPINFOHEADER struct tagWINRGBQUAD

Defines #define BI_RGB  0L #define BI_RLE8  1L #define BI_RLE4  2L #define BI_BITFIELDS  3L

Typedefs typedef tagWINRGBQUAD WINRGBQUAD typedef tagWINBITMAPFILEHEADER WINBITMAPFILEHEADER typedef tagWINBITMAPINFOHEADER WINBITMAPINFOHEADER typedef tagWINBITMAPINFO WINBITMAPINFO

Detailed Description 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.

Definition in file windefs