Png From resource

Png From resource

Postby lailton.webmaster » Wed Sep 23, 2009 1: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: Select all  Expand view

// 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 ?
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Png From resource

Postby Daniel Garcia-Gil » Wed Sep 23, 2009 2:04 am

Lailton...

TBitmap class not support PNG image, you should use TImage Class
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Png From resource

Postby lailton.webmaster » Wed Sep 23, 2009 2: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
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Png From resource

Postby Daniel Garcia-Gil » Wed Sep 23, 2009 7:18 am

User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Png From resource

Postby lailton.webmaster » Wed Sep 23, 2009 1:32 pm

Code: Select all  Expand view
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.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Png From resource

Postby lailton.webmaster » Wed Sep 23, 2009 1: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
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Png From resource

Postby Daniel Garcia-Gil » Wed Sep 23, 2009 2: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
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests