Wrapper class for loading and displaying PNG images. More...
#include <PngImage.h>
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. |
Wrapper class for loading and displaying PNG images.
Definition at line 35 of file PngImage.h.
PngImage::PngImage | ( | LPCTSTR | lpFilename, | |
bool | bForce8Bit = true | |||
) |
File loading constructor.
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.
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().
const BYTE* PngImage::GetBits | ( | ) | const [inline] |
Returns the image data array.
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.
Definition at line 84 of file PngImage.h.
References m_nBitsPerPixel.
Referenced by DrawImage().
int PngImage::GetHeight | ( | ) | const [inline] |
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.
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.
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.
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 |
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.
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 |
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.
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 |
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.
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.
hDC | Handle to DC to use when creating the compatible bitmap |
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().