00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _PNGIMAGE_H_
00028 #define _PNGIMAGE_H_
00029
00030 #include <png.h>
00031
00035 class PngImage
00036 {
00037 public:
00038
00040 PngImage();
00042 PngImage(LPCTSTR lpFilename, bool bForce8Bit = true);
00044 PngImage(UINT uResourceID, bool bForce8Bit = true, HMODULE hModule = NULL, LPCTSTR lpType = _T("PNG"));
00048 ~PngImage() {clear();};
00049
00050 protected:
00051
00053 int m_nWidth;
00055 int m_nHeight;
00057 BYTE* m_pData;
00059 int m_nBitsPerPixel;
00061 int m_nBytesPerRow;
00062
00063 public:
00064
00069 const BYTE* GetBits() const {return m_pData;};
00074 int GetWidth() const {return m_nWidth;};
00079 int GetHeight() const {return m_nHeight;};
00084 int GetBitsPerPixel() const {return m_nBitsPerPixel;};
00089 int GetWidthInBytes() const {return m_nBytesPerRow;};
00090
00091 public:
00093 bool LoadFromFile(LPCTSTR lpFilename, bool bForce8Bit = true, bool bLeaveGray = false);
00095 bool LoadFromResource(UINT uResourceID, bool bForce8Bit = true, HMODULE hModule = NULL, LPCTSTR lpType = _T("PNG"), bool bLeaveGray = false);
00097 bool LoadFromBuffer(const char* pBuffer, DWORD dwLen, bool bForce8Bit = true, bool bLeaveGray = false);
00098
00100 void clear();
00101
00103 HBITMAP ToBitmap(HDC hDC);
00104
00105 protected:
00107 static void PNGAPI StaticRead(png_structp pPng, png_bytep pBuffer, png_size_t nSize);
00108 };
00109
00110 #endif //#define _PNGIMAGE_H_