Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

There is no API for working with PNG images in the main library itself (ProfUISDLL and ProfUISLIB projects in the Prof-UIS workspace). However, there is another library that comes with Prof-UIS and provides this functionality: ProfSkin (ProfSkinDLL and ProfSkinLIB projects). Please note there are two third-party libraries that are used in ProfSkin, LibPng and Zlib, which are free for any use.

You can load a PNG from a file or a resource using the CExtSkinBitmap class implemented in ProfSkin. After the image is loaded, you can use it wherever you want in your application. For example, you can use it for initializing any of the following properties of a CExtCmdIcon object:

CExtBitmap m_bmpNormal;
CExtBitmap m_bmpDisabled;
CExtBitmap m_bmpHover;
CExtBitmap m_bmpPressed;

The following steps illustrate how you can load PNG images:

1) Include ProfSkin.h in your StdAfx.h file:

#include <Prof-UIS.h>
#include <../ProfSkin/ProfSkin>

2) Compile both LibPNG and ZLib.

3) Compile ProfSkin.

4) Here is sample code for loading two PNG images.

CExtSkinBitmap _bmpTmp;

// Load PNG from resources:
LPCTSTR strPngResourceSection = _T("PNG");
HINSTANCE hInst = ::AfxFindResourceHandle( strPngImageResourceID, strPngResourceSection );
ASSERT( hInst );
HRSRC hRsrc = ::FindResourceHandle( hInst, strPngImageResourceID, strPngResourceSection );
ASSERT( hRsrc );
VERIFY( _bmpTmp.LoadPNG_Resource( hInst, hRsrc ) );
pSomeRibbonNode1->m_iconBig = _bmpTmp;

// Load PNG from file:
VERIFY( _bmpTmp.LoadPNG_File( _T("C:\Folder\picture.png") ) );
pSomeRibbonNode2->m_iconBig = _bmpTmp;