/** * @file XTPGraphicBitmapPng.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPGRAPHICBITMAPPNG_H__) # define __XTPGRAPHICBITMAPPNG_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPGraphicBitmapPng is a CBitmap derived class used to load .PNG * files from files and resources. */ class _XTP_EXT_CLASS CXTPGraphicBitmapPng : public CBitmap { struct CCallback; public: /** * @brief * Default constructor. */ CXTPGraphicBitmapPng(); public: /** * @brief * Call this method to load a .PNG file. * @param lpszFileName A string value that contains the name of a file * to be loaded. * @return * TRUE if successful, otherwise 0. */ BOOL LoadFromFile(LPCTSTR lpszFileName); /** * @brief * Call this member function to load a .PNG file from a specified * resource. * @param hModule Module instance to load. * @param hRes Resource handle. * @return * TRUE if successful, otherwise 0. */ BOOL LoadFromResource(HMODULE hModule, HRSRC hRes); /** * @brief * Call this method to load a .PNG file. * @param pFile Pointer to the CFile to be loaded. * @return * TRUE if successful, otherwise 0. */ BOOL LoadFromFile(CFile* pFile); /** * @brief * Determines if the loaded .PNG file has alpha layer. * @return * TRUE if the .PNG file has alpha layer. */ BOOL IsAlpha() const; private: HBITMAP ConvertToBitmap(BYTE* pbImage, CSize szImage, int cImgChannels) const; protected: BOOL m_bAlpha; /**< TRUE if the .PNG file has alpha layer. */ }; /** @cond */ AFX_INLINE BOOL CXTPGraphicBitmapPng::IsAlpha() const { return m_bAlpha; } /** @endcond */ /** * @brief * Possible ZLib compression levels. * @see * ZLibCompressWithLevel */ enum XTPZlibCompressionLevel { xtpZLibNoCompression = 0, /**< No compression. */ xtpZLibBestSpeed = 1, /**< Best speed. */ xtpZLibBestCompression = 9, /**< Best compression. */ xtpZLibDefaultCompression = -1 /**< Default compression. */ }; /** * @brief * Compresses a source buffer into a target buffer using the ZLib library. * @param dest Pointer to the target buffer. * @param destLen Size of the target buffer; must be at least 0.1% larger * than source_size plus 12 bytes. * @param source Pointer to the source buffer. * @param sourceLen Size of the source buffer. * @param level Optional compression level; one of the XTPZlibCompressionLevel * constants. * @return * The actual size of the compressed buffer, or 0 if an error occurred. * @see * XTPZlibCompressionLevel */ _XTP_EXT_CLASS int AFX_CDECL ZLibCompress(BYTE* dest, ULONG* destLen, const BYTE* source, ULONG sourceLen, XTPZlibCompressionLevel level = xtpZLibDefaultCompression); /** * @brief * Used before a ZLibCompress call to allocate the destination buffer. * @param sourceLen Size of the source buffer. * @return * An upper bound on the compressed size after ZLibCompress on sourceLen bytes. */ _XTP_EXT_CLASS ULONG AFX_CDECL ZLibCompressBound(ULONG sourceLen); /** * @brief * Decompresses a source buffer into a target buffer, using the ZLib library. * @param dest Pointer to the target buffer. * @param destLen Size of the target buffer; must be at least 0.1% larger * than source_size plus 12 bytes. * @param source Pointer to the source buffer. * @param sourceLen Size of the source buffer. * @return * The actual size of the uncompressed buffer, or 0 if an error occurred. */ _XTP_EXT_CLASS int AFX_CDECL ZLibUncompress(BYTE* dest, ULONG* destLen, const BYTE* source, ULONG sourceLen); # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // #if !defined(__XTPGRAPHICBITMAPPNG_H__) /** @endcond */