FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Png From resource
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Png From resource
Posted: Wed Sep 23, 2009 01:05 AM
How use png from resource ?
Como utilizar resources PNG de um resource ?

yo posso hacer una dialog transparent and add um PNG file ?
Sample: ( isso nao funciona... )
Code (fw): Select all Collapse
// Moving a window, with the mouse, without a caption

#include "FiveWin.ch"

function Main()

   local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand, oBmp

   DEFINE CURSOR oCrsHand HAND

   DEFINE BITMAP oBmp FILENAME "test.png"

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR "W/R"

   oWnd:bLClicked := { | nRow, nCol | nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand }
      
   oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
                                         oWnd:nLeft + nCol - nColPos,,, .T. ),) }   

   oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }

   oWnd:SetSize( 221, 221 )
   oWnd:Center()

   ACTIVATE WINDOW oWnd ;
      ON INIT  SetTransparent( oWnd ) ; 
      ON PAINT PaintTransparent( hDC, oBmp:hBitmap, 0, 0 ) ;
      ON RIGHT CLICK oWnd:End()

   oBmp:End()

return nil

#define LWA_COLORKEY  1 
#define GWL_EXSTYLE   -20 
#define WS_EX_LAYERED 524288 

STATIC FUNCTION SETTRANSPARENT( oDlg ) 

   SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, NOR( GETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) ) 

   SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, CLR_RED,, LWA_COLORKEY ) 

RETURN NIL

function PaintTransparent( hDC, hBitmap, nRow, nCol )

   local hBmpOld := SelectObject( hDC, hBitmap )
   local nZeroZeroClr := GetPixel( hDC, 0, 0 )
   local nOldClr 

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
             nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr )          

return nil


yo posso utilizar PNG in CLASS TBitmap ?
ou yo necessito utilizar Image ?
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 02:04 AM

Lailton...

TBitmap class not support PNG image, you should use TImage Class

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 02:30 AM

Daniel,

How use png from resource ?

can help ?

i see here in forum a tropic about it, more i try and no Work !

you can help me with this ?

Thanks

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 07:18 AM
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 01:32 PM
Code (fw): Select all Collapse
Daniel,

How use png from resource ?

can help ? 

i see here in forum a tropic about it, more i try and no Work !

you can help me with this ?

Thanks


DAniel it´s no work.

dont have file image.h

and using image.h from download website show me very much erros when try compile.
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 01:47 PM

Borland Resource Compiler Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation. All rights reserved.

Fatal error Input and output file names are the same.
d:\bcc55\BIN\ilink32 @makefile.lnk
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'FreeImage_OpenMemory' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_GetFileTypeFromMemory' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_LoadFromMemory' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_CloseMemory' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_GetInfo' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_GetBits' referenced from C:\PNG\OBJ\DEMO.OBJ
Error: Unresolved external 'FreeImage_GetInfoHeader' referenced from C:\PNG\OBJ\DEMO.OBJ

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Png From resource
Posted: Wed Sep 23, 2009 02:28 PM
Lailton...

Your problem isn't the .H file, download it from http://freeimage.sourceforge.net/download.html
you need load freeimage.dll from C or implib the DLL to LIB and join at project

implib freeimage.lib freeimage.dll

pd: i think that freeimage no work properly with PNG image

Continue the discussion