![]()  | 
 
How i can render PNG image | 
 
    Post Reply  
   | 
  
| Author | |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: How i can render PNG imagePosted: 18 June 2007 at 10:51pm  | 
 
| 
   
    
   I wonder if any body can help to use codejock for loading and rendering PNG images from ressource and from external file.
 
   
  I try diffrent function from codejock but no help,,  
I excepet to show me the best why to draw a PNG image (storred  
internally in my exe, or storred in extern dll file), and where i must store my PNG image( where in the ressource under "PNG" or under "Bitmap" Group). sorry for my bad english,,, and thanks 
    | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 19 June 2007 at 1:26am | 
 
| 
   
    
   Hello,
 
   
  Try this 
CXTPGraphicBitmapPng bitmap; 
bitmap.LoadFromResource(hModule, hRes); 
or load bitmaps/draw using CXTPImageManager collection 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 19 June 2007 at 11:28pm | 
 
| 
   
    
   Thank's "oleg"...
 
   
  I will try with CXTPGraphicBitmapPng. 
An other question: where my PNG image suppos to be in my resource file, I mean  like icons it must be under ICON group & bitmap image must be under BITAMP group in my resource and so on (where PNG image must be). I try to set it under PNG group but it doesn't wok. 
thank's for your help... 
    | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 20 June 2007 at 1:25am | 
 
| 
   
    
   Yes, you need PNG group. 
 
   
  check Samples\CommandBars\ActionsSample  sample. It uses png for toolbar icons: 
Here part of code from sources: 
hModule = AfxFindResourceHandle(lpszResource, _T("PNG")); 
 BOOL bPngBitmap = IsPngBitmapResource(hModule, lpszResource); 
if (bPngBitmap) { CXTPGraphicBitmapPng bmpIcons;   HRSRC hResource = ::FindResource(hModule, lpszResource, _T("PNG")); 
  if (!bmpIcons.LoadFromResource(hModule, hResource)) 
return NULL;   if (lbAlphaBitmap) 
{ *lbAlphaBitmap = bmpIcons.IsAlpha(); }   return (HBITMAP)bmpIcons.Detach(); 
   }  | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 20 June 2007 at 8:00pm | 
 
| 
   
    Thank's again oleg... 
I have used this code and it works for load PNG image from file or from resource 
---- Load PNG from local file 
BOOL bAlpha=0; 
HBITMAP hb = CXTPImageManagerIcon::LoadBitmapFromFile (pszFilePng, &bAlpha);  
---- Load PNG from resource 
BOOL bAlpha = FALSE; 
hb = CXTPImageManagerIcon::LoadBitmapFromResource(_T("IDB_PNG_IMAGE"),&bAlpha ); 
LPCTSTR lpszResource = MAKEINTRESOURCE(IDB_PNG_IMAGE); 
HMODULE hModule = AfxFindResourceHandle( lpszResource, _T("PNG") ); 
BOOL bPngBitmap = CXTPImageManagerIcon::IsPngBitmapResource(hModule, lpszResource); 
if (bPngBitmap) 
{ 
      CXTPGraphicBitmapPng bmpIcons; 
      HRSRC hResource = ::FindResource(hModule, lpszResource, _T("PNG")); 
       if (!bmpIcons.LoadFromResource(hModule, hResource)) 
             TRACE0("Can't Load"); 
 BOOL lbAlphaBitmap = bmpIcons.IsAlpha(); 
 hb = (HBITMAP)bmpIcons.Detach(); 
} 
Thanks to oleg 
---- Also I found a post and I verified it and it work,, thanks to  danpetitt  
The Problem is the look of my render; it doesn't draw the transparency in the right way 
This my PNG render. 
This windows XP Picture and Fax preview render 
n  I used to render my image this code 
void CChildView::OnPaint() 
{ 
      CPaintDC pdc(this); // device context for painting 
      CXTMemDC dc(&pdc, CRect(0,0,0,0)); // I used this to reduce filcker 
CXTPImageManagerIcon::DrawAlphaBitmap(&dc, hb, CPoint(50,50), CSize(256,256), 0, CSize(256,256) ); 
} 
    | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 June 2007 at 1:26am | 
 
| 
   
    
   Hi,
 
   
  Attach project with all bitmaps/png here or in issue track. 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 June 2007 at 11:36am | 
 
| 
   
    Hi oleg .... since I can't upload my project, I have created a simple one that demonstrate the problem 
this is the link 
the project was create with VS2005 
the file "ChildView.cpp" have my routine to load and draw the PNG image. 
you can check my code, and I hope to figureout where I am wrong... 
Thank's to you for help. 
 | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 June 2007 at 3:03pm | 
 
| 
   
    
   Right. You also need premultiply bitmap if it has alpha layer:
 
   
  RSRC hResource = ::FindResource(hModule, lpszResource, _T("PNG")); CXTPGraphicBitmapPng mBitmapPng; if (!mBitmapPng.LoadFromResource(hModule, hResource)) TRACE0("\nCan't Load PNG from resource\n"); mBitmap.Attach(CXTPImageManagerIcon::PreMultiplyAlphaBitmap(mBitmapPng)); CXTPImageManagerIcon::DrawAlphaBitmap( &dc, mBitmap, CPoint(50,50), CSize(256,256), 0, CSize(256,256) ); | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 June 2007 at 3:31pm | 
 
| 
   
    
   Thank's oleg ....
 
   
  I try it and it work... 
 | 
 |
![]()  | 
 |
    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  |