Probando PNG Reader

Probando PNG Reader

Postby Daniel Garcia-Gil » Tue May 18, 2010 4:44 am

Nueva caracteristica de la funcion para leer archivos PNG

now level transparences (alpha channel) estan soportados

para Harbour http://www.sitasoft.net/fivewin/lib/harbour/fwpngh.lib
para xHarbour http://www.sitasoft.net/fivewin/lib/xharbour/fwpngx.lib

samples
para Harbour http://www.sitasoft.net/fivewin/samples/tpngh.rar
para xHarbour http://www.sitasoft.net/fivewin/samples/tpngx.rar

Codigo
Code: Select all  Expand view

#include "FiveWin.ch"

STATIC oWnd, oBmp

FUNCTION Main()
   local oBar
   local cFile := ""
   local lSetAlpha := .t.
   

   DEFINE WINDOW oWnd FROM 0,0 TO 20,50 TITLE "Test READING PNG IMAGE"
   
   define buttonbar oBar of oWnd size 48,48
   define button prompt "File" of oBar action( LoadPng( oBmp ), oBmp:HasAlpha(), oBmp:Refresh() ) CENTER
   define button prompt "transp ON" of oBar action( oBmp:lTransparent := .T., oBmp:refresh() ) CENTER
   define button prompt "transp OFF" of oBar action( oBmp:lTransparent := .F., oBmp:refresh() ) CENTER
   define button prompt "Adjust ON" of oBar action( oBmp:lStretch := .T., oBmp:refresh() ) CENTER
   define button prompt "Adjust OFF" of oBar action( oBmp:lStretch := .F., oBmp:refresh() ) CENTER
   define button prompt "HasAlpha" of oBar action( MsgInfo( oBmp:HasAlpha() ) ) CENTER
   define button prompt "level" of oBar action( oBmp:nAlphaLevel += 50, oBmp:refresh() ) CENTER
      @ 0,0 BITMAP oBmp FILENAME cFile OF oWnd ;
         PIXEL SCROLL
      WndCenter(oWnd:hWnd)


   ACTIVATE WINDOW oWnd ;
      ON PAINT ( oBmp:aDjClient(), oBmp:ScrollAdjust() ) ;
      ON RESIZE ( oBmp:aDjClient(), oBmp:ScrollAdjust() )

RETURN ( nil )

function LoadPng( oBmp )
   
   local cFile := cGetFile( "*.png","Select File" )
   local hPng
   
   if !Empty( cFile  )
      hPng = FWOpenPngFile( cFile )
      if IsGdiObject( hPng )
         if IsGdiObject( oBmp:hBitmap )
            DeleteObject( oBmp:hBitmap )
         endif
         oBmp:hBitmap = hPng
         oBmp:Refresh()
      endif
   endif
   
return nil
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Probando PNG Reader

Postby Daniel Garcia-Gil » Tue May 18, 2010 4:46 am

Se puede hacer pruebas con la clase BtnBmp, sustituyendo en el Method LoadBitmap esta porcion de codigo
Code: Select all  Expand view

   if ! Empty( cBmpFile1 )
      if File( cBmpFile1 )
         if Upper( Right( cBmpFile1, 3 ) ) == "PNG"
            ::hBitmap1  = FWOpenPngFile( cBmpFile1 )
            ::hPalette1 = 0
         else
            ::cBmpFile1 = cBmpFile1
            aBmpPal     = PalBmpRead( ::GetDC(), cBmpFile1 )
            ::hBitmap1  = aBmpPal[ 1 ]
            ::hPalette1 = aBmpPal[ 2 ]
         endif
         ::HasAlpha( ::hBitmap1, BTN_UP )
//         ::ReleaseDC()
      endif
   endif


solo para pruebas, se usa la imagen Nro 1 desde archivo
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Probando PNG Reader

Postby softruz » Tue May 18, 2010 4:20 pm

Muy bueno, pero al compilar con Harbour me dan los siguientes errores:

Error: Unresolved external '_crc32' referenced from Z:\SOFTWARE\HARBOUR\FUE\FWPNGH.LIB|PNG
Error: Unresolved external '_inflateReset' referenced from Z:\SOFTWARE\HARBOUR\FUE\FWPNGH.LIB|PNG
Error: Unresolved external '_inflateInit_' referenced from Z:\SOFTWARE\HARBOUR\FUE\FWPNGH.LIB|PNGREAD
Error: Unresolved external '_inflate' referenced from Z:\SOFTWARE\HARBOUR\FUE\FWPNGH.LIB|PNGRUTIL
Error: Unresolved external '_inflateEnd' referenced from Z:\SOFTWARE\HARBOUR\FUE\FWPNGH.LIB|PNGREAD
Error: Unresolved external '_HB_FUN_ISGDIOBJECT' referenced from Z:\SOFTWARE\HARBOUR\FUE\CTBMSIGP.OBJ

¿Por que puede ser ?
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Probando PNG Reader

Postby Daniel Garcia-Gil » Tue May 18, 2010 7:18 pm

Softruz


debes enlazar para xharbour zlib.lib y para Harbour hbzlib.lib, disculpa olvide mencionarlo

para resolver IsGdiObject()

coloca esto

Code: Select all  Expand view
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>

HB_FUNC( ISGDIOBJECT )
{
    hb_retl( IsGDIObject( ( HANDLE ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMP
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Probando PNG Reader

Postby softruz » Wed May 19, 2010 7:26 am

Gracias, tenemos el hbzlib.lib para Harbour.

Un Saludo.
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: Probando PNG Reader

Postby Francisco Horta » Wed Nov 23, 2011 4:53 pm

Daniel
Gracias por tu apoyo, revise el ejemplo y no pude adaptarlo a la ribbon, para leer .png asi utilizo la ribbon

@ 5, 5 ADD BUTTON ::oBoton PROMPT "Punto de Venta" BITMAP ::cDirBmps+"pdv48.BMP" ;
GROUP ::oGrupo SIZE 80,90 ROUND ROUNDSIZE 2 BORDER

intente hacerle asi pero no encuentra las variables:

::oBoton:hBitmap := Loadpng(::cDirBmps+"pdv48.png")
::oBoton:cBitmap := Loadpng(::cDirBmps+"pdv48.png")

a ver si me echas la mano para poner .png en los botones,
gracias como siempre por tu apoyo
saludos
paco
____________________
Paco
Francisco Horta
 
Posts: 845
Joined: Sun Oct 09, 2005 5:36 pm
Location: la laguna, mexico.


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests