PngImage Class Reference

Wrapper class for loading and displaying PNG images. More...

#include <PngImage.h>

List of all members.

Public Member Functions

 PngImage ()
 Default constructor.
 PngImage (LPCTSTR lpFilename, bool bForce8Bit=true)
 File loading constructor.
 PngImage (UINT uResourceID, bool bForce8Bit=true, HMODULE hModule=NULL, LPCTSTR lpType=_T("PNG"))
 Resource loading constructor.
 ~PngImage ()
 Destructor: cleans up.
const BYTE * GetBits () const
 Returns the image data array.
int GetWidth () const
 Returns the image width.
int GetHeight () const
 Returns the image height.
int GetBitsPerPixel () const
 Returns the number of color bits per pixel.
int GetWidthInBytes () const
 Returns the number of full bytes in each image line.
bool LoadFromFile (LPCTSTR lpFilename, bool bForce8Bit=true, bool bLeaveGray=false)
 Loads a PNG image from a file.
bool LoadFromResource (UINT uResourceID, bool bForce8Bit=true, HMODULE hModule=NULL, LPCTSTR lpType=_T("PNG"), bool bLeaveGray=false)
 Loads a PNG image from a resource.
bool LoadFromBuffer (const char *pBuffer, DWORD dwLen, bool bForce8Bit=true, bool bLeaveGray=false)
 Loads a PNG image from a buffer.
void clear ()
 cleans the loaded image
HBITMAP ToBitmap (HDC hDC)
 Returns a GDI bitmap containing the same image.

Static Protected Member Functions

static void PNGAPI StaticRead (png_structp pPng, png_bytep pBuffer, png_size_t nSize)
 PNG reader callback function.

Protected Attributes

int m_nWidth
 Width of the image (pixels).
int m_nHeight
 Height of the image (lines).
BYTE * m_pData
 Pointer to the image data.
int m_nBitsPerPixel
 Number of color bits per pixel.
int m_nBytesPerRow
 Number of full bytes per image line.

Detailed Description

Wrapper class for loading and displaying PNG images.

Definition at line 35 of file PngImage.h.


Constructor & Destructor Documentation

PngImage::PngImage ( LPCTSTR  lpFilename,
bool  bForce8Bit = true 
)

File loading constructor.

Parameters:
lpFilename Name of file to load
bForce8Bit true to force the image to be loaded as 8-bit color image

Definition at line 46 of file PngImage.cpp.

References LoadFromFile().

PngImage::PngImage ( UINT  uResourceID,
bool  bForce8Bit = true,
HMODULE  hModule = NULL,
LPCTSTR  lpType = _T("PNG") 
)

Resource loading constructor.

Parameters:
uResourceID ID of PNG image resource
bForce8Bit true to force the image to be loaded as 8-bit color image
hModule Handle of module that the resource belongs to
lpType Type of resource

Definition at line 58 of file PngImage.cpp.

References LoadFromResource().


Member Function Documentation

const BYTE* PngImage::GetBits (  )  const [inline]

Returns the image data array.

Returns:
Pointer to the image data

Definition at line 69 of file PngImage.h.

References m_pData.

Referenced by DrawImage().

int PngImage::GetBitsPerPixel (  )  const [inline]

Returns the number of color bits per pixel.

Returns:
The number of color bits per pixel

Definition at line 84 of file PngImage.h.

References m_nBitsPerPixel.

Referenced by DrawImage().

int PngImage::GetHeight (  )  const [inline]

Returns the image height.

Returns:
The image height

Definition at line 79 of file PngImage.h.

References m_nHeight.

Referenced by DrawImage(), OEMSendPage(), and CCLicenseLocationWnd::ProcessMessage().

int PngImage::GetWidth (  )  const [inline]

Returns the image width.

Returns:
The image width

Definition at line 74 of file PngImage.h.

References m_nWidth.

Referenced by DrawImage(), OEMSendPage(), and CCLicenseLocationWnd::ProcessMessage().

int PngImage::GetWidthInBytes (  )  const [inline]

Returns the number of full bytes in each image line.

Returns:
The number of full bytes in each image line

Definition at line 89 of file PngImage.h.

References m_nBytesPerRow.

Referenced by DrawImage().

bool PngImage::LoadFromBuffer ( const char *  pBuffer,
DWORD  dwLen,
bool  bForce8Bit = true,
bool  bLeaveGray = false 
)

Loads a PNG image from a buffer.

Parameters:
pBuffer Pointer to the image data
dwLen Size of the image data
bForce8Bit true to force the image to be loaded as 8-bit color image
bLeaveGray false to force loading the image in color, true to leave as grayscale if was so
Returns:
true if loaded successfully, false if failed

Definition at line 196 of file PngImage.cpp.

References clear(), m_nBitsPerPixel, m_nBytesPerRow, m_nHeight, m_nWidth, m_pData, and StaticRead().

Referenced by LoadFromFile(), and LoadFromResource().

bool PngImage::LoadFromFile ( LPCTSTR  lpFilename,
bool  bForce8Bit = true,
bool  bLeaveGray = false 
)

Loads a PNG image from a file.

Parameters:
lpFilename Name of file to load
bForce8Bit true to force the image to be loaded as 8-bit color image
bLeaveGray false to force loading the image in color, true to leave as grayscale if was so
Returns:
true if loaded successfully, false if failed

Definition at line 70 of file PngImage.cpp.

References LoadFromBuffer().

Referenced by PngImage().

bool PngImage::LoadFromResource ( UINT  uResourceID,
bool  bForce8Bit = true,
HMODULE  hModule = NULL,
LPCTSTR  lpType = _T("PNG"),
bool  bLeaveGray = false 
)

Loads a PNG image from a resource.

Parameters:
uResourceID ID of PNG image resource
bForce8Bit true to force the image to be loaded as 8-bit color image
hModule Handle of module that the resource belongs to
lpType Type of resource
bLeaveGray false to force loading the image in color, true to leave as grayscale if was so
Returns:
true if loaded successfully, false if failed

Definition at line 122 of file PngImage.cpp.

References LoadFromBuffer().

Referenced by OEMSendPage(), PngImage(), CCLicenseLocationWnd::ProcessMessage(), and CCLicensePropPage::UpdateLicenseControls().

void PNGAPI PngImage::StaticRead ( png_structp  pPng,
png_bytep  pBuffer,
png_size_t  nSize 
) [static, protected]

PNG reader callback function.

Parameters:
pPng Pointer to PNG data buffer
pBuffer Pointer to the buffer to fill
nSize Size of the buffer to fill

Definition at line 172 of file PngImage.cpp.

References PngReadInfo::dwLen, and PngReadInfo::pBuffer.

Referenced by LoadFromBuffer().

HBITMAP PngImage::ToBitmap ( HDC  hDC  ) 

Returns a GDI bitmap containing the same image.

Parameters:
hDC Handle to DC to use when creating the compatible bitmap
Returns:
Handle to the created bitmap, or NULL if failed

Definition at line 326 of file PngImage.cpp.

References m_nBitsPerPixel, m_nHeight, m_nWidth, and m_pData.

Referenced by CCLicenseLocationWnd::ProcessMessage(), and CCLicensePropPage::UpdateLicenseControls().


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

Generated on Mon Jun 18 12:40:44 2012 for CC PDF Converter by doxygen 1.6.1