![]() |
Load PNG From resource with CodeJock |
Post Reply ![]() |
Author | |
barobax ![]() Senior Member ![]() Joined: 07 May 2008 Status: Offline Points: 117 |
![]() ![]() ![]() ![]() ![]() Posted: 20 April 2009 at 7:55am |
Hi,
which class can load a PNG file from dll resources and make HBITMAP for resource ?!? I tried CXTPImageManager and CXTPImageIcon and CXTPImageIconHandle but I can't load my resource. I have HINSTANCE handle and when I try to load PNG file with handle The HBITMAP is NULL. please help me, Thanks, Best Regards. |
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 931 |
![]() ![]() ![]() ![]() ![]() |
After we moved to V12 we had problems getting bitmaps. We had to create a CXTPImageManagerIconHandle and call CopyHandle. The input was the CXTPImageManagerIconHandle
CXTPImageManagerIconHandle IconCopy;
IconCopy.CopyHandle(IconHandle);
We could then get the HBITMAP. However, with png files, the returned bitmap was rendered with a black background and I could not find a way to control that. So we then used the CXTPImageManagerIconHandle and createded a compatible DC and drew into the DC. It went something like this: CDC *pDCSrc = GetDC(); if(pDCSrc){ HDC hDCMem = CreateCompatibleDC( NULL );HBITMAP hBmpOld = 0; HBRUSH hBrush = CreateSolidBrush( Background ); // create a bitmap that will be used after the // icon is drawnhbm = CreateCompatibleBitmap( pDCSrc->m_hDC, nWidth, nWidth ); hBmpOld = (HBITMAP)SelectObject( hDCMem, hbm ); CPoint pt; pt.x = pt.y = 0; HBRUSH hBrushOld = (HBRUSH)SelectObject( hDCMem, hBrush ); HPEN hPenOld = (HPEN)SelectObject(hDCMem,GetStockObject(NULL_PEN)); Rectangle( hDCMem, 0, 0, nWidth+1, nWidth+1 ); CSize szIcon; szIcon.cx = szIcon.cy = nWidth; bool bDrawComposited = false;CDC* tmpDC; tmpDC = CDC::FromHandle( hDCMem ); IconHandle.Draw( tmpDC, pt, szIcon, bDrawComposited ); SelectObject( hDCMem, hBrushOld ); SelectObject( hDCMem, hPenOld ); SelectObject( hDCMem, hBmpOld ); DeleteObject( hBrush ); DeleteDC( hDCMem ); DeleteDC( pDCSrc->m_hDC); |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |