FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Testing PNG reader
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Testing PNG reader
Posted: Tue May 18, 2010 04:43 AM
New features to PNG reader

now level transparences (alpha channel) is supported

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

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

Code
Code (fw): Select all Collapse
#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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Testing PNG reader
Posted: Tue May 18, 2010 04:48 AM
We can do test with BtnBmp class, replace inside Method LoadBitmap this part
Code (fw): Select all Collapse
   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


only for test, we used the image 1 from files
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Testing PNG reader
Posted: Wed May 19, 2010 02:11 AM
Hi Daniel,

Today i did test with your lib to test PNG file.

well, now we can use png without dll, more yet have a problem,

look for this:





Think that need new type of display a image file. only converte to hBitmap think that
problem with transparency will continue.

what you think about this ?

Thanks.
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Testing PNG reader
Posted: Wed May 19, 2010 03:40 AM

Lailton...

are you using the last test???

because the last test have 7 Button in buttonbar, check test source code ( hasalpha, level )

please download new .zip and .lib file

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Testing PNG reader
Posted: Wed May 19, 2010 04:37 AM

Perfect.

i tryed with old function.

thanks Daniel, Perfect job. :lol:

Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Testing PNG reader
Posted: Wed May 19, 2010 05:17 AM

Hello Daniel,

So we dont need freeimage.dll when using your lib? That's great!

Regards,
Frances

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Testing PNG reader
Posted: Wed May 19, 2010 10:26 AM
Frances

fraxzi wrote:So we dont need freeimage.dll when using your lib?


no need freeimage.dll
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Testing PNG reader
Posted: Thu May 20, 2010 02:49 AM
Daniel Garcia-Gil wrote:Frances

fraxzi wrote:So we dont need freeimage.dll when using your lib?


no need freeimage.dll




Dear Daniel,

Great! Very nice job.

my best regards,
Frances
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: Testing PNG reader
Posted: Thu May 20, 2010 02:08 PM
Hola

como se debería usar con BTNBMP

Code (fw): Select all Collapse
REDEFINE BTNBMP oBmp1 ID 4001 OF oDlg FILENAME "C:\FWH\bitmaps\hires\windows media player.png";
action .t.
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Testing PNG reader
Posted: Thu May 20, 2010 02:35 PM
Patricio Avalos Aguirre wrote:Hola

como se debería usar con BTNBMP

Code (fw): Select all Collapse
REDEFINE BTNBMP oBmp1 ID 4001 OF oDlg FILENAME "C:\FWH\bitmaps\hires\windows media player.png";
action .t.


tiene que alterar la classe btnbmp, en lo metodo LoadBitmap()

Code (fw): Select all Collapse
   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


Somiente esso e usar dela forma que tu estas hacendo en lo REDEFINE :-)
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: Testing PNG reader
Posted: Thu May 20, 2010 05:30 PM
Gracias funciona perfecto..

ahora en tu ejemplo tienes en comentario el // ::ReleaseDC()
en mi original clase está si que la deje de esta manera

Code (fw): Select all Collapse
   if ! Empty( cBmpFile1 )
      if File( cBmpFile1 )
         if Upper( Right( cBmpFile1, 3 ) ) == "PNG"
            ::hBitmap1  = FWOpenPngFile( cBmpFile1 )
            ::hPalette1 = 0
            ::HasAlpha( ::hBitmap1, BTN_UP )
         else
            ::cBmpFile1 = cBmpFile1
            aBmpPal     = PalBmpRead( ::GetDC(), cBmpFile1 )
            ::hBitmap1  = aBmpPal[ 1 ]
            ::hPalette1 = aBmpPal[ 2 ]
            ::HasAlpha( ::hBitmap1, BTN_UP )
            ::ReleaseDC()
        endif
      endif
   endif
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Testing PNG reader
Posted: Thu May 20, 2010 05:33 PM

Sem problemas,

somiente segui o que a foi passado pelo Daniel,
acredito que la deferença es devido la version de fivewin :)

:roll:

Posts: 65
Joined: Fri Feb 13, 2009 12:03 PM
Re: Testing PNG reader
Posted: Tue Aug 21, 2012 06:55 AM

Hi Daniel,

I tried to compile your code and encountered the following error:

Unresolved external '_HB_FUN_ISGDIOBJECT' referenced from Z:\obj\main.obj

I am using FWH 9.01 + BCC55 + xHB1.1

Thanks.
ryugarai27

Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: Testing PNG reader
Posted: Tue Aug 21, 2012 04:52 PM
Ryugarai,

Add to your prg

Code (fw): Select all Collapse
#pragma BEGINDUMP
 #include "windows.h"
 #include "hbapi.h"
 #ifdef __FLAT__
  BOOL IsGDIObject( HGDIOBJ hobj ){  return ( BOOL ) GetObjectType( hobj ); }
 #endif
 HB_FUNC( ISGDIOBJECT ){    hb_retl( IsGDIObject( ( HANDLE ) hb_parnl( 1 ) ) ); }
#pragma ENDDUMP
Regards,

Lailton Fernando Mariano
Posts: 65
Joined: Fri Feb 13, 2009 12:03 PM
Re: Testing PNG reader
Posted: Fri Aug 24, 2012 07:24 AM

Lailton,

Thanks!

ryugarai27

Continue the discussion