Testing PNG reader

Testing PNG reader

Postby Daniel Garcia-Gil » Tue May 18, 2010 4: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: 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: Testing PNG reader

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

We can do test with BtnBmp class, replace inside Method LoadBitmap this part
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


only for test, we used the image 1 from files
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Testing PNG reader

Postby lailton.webmaster » Wed May 19, 2010 2: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:

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

Re: Testing PNG reader

Postby Daniel Garcia-Gil » Wed May 19, 2010 3: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
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Testing PNG reader

Postby lailton.webmaster » Wed May 19, 2010 4:37 am

Perfect.

i tryed with old function.

thanks Daniel, Perfect job. :lol:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Testing PNG reader

Postby fraxzi » Wed May 19, 2010 5: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Testing PNG reader

Postby Daniel Garcia-Gil » Wed May 19, 2010 10:26 am

Frances

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


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

Re: Testing PNG reader

Postby fraxzi » Thu May 20, 2010 2: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Testing PNG reader

Postby Patricio Avalos Aguirre » Thu May 20, 2010 2:08 pm

Hola

como se debería usar con BTNBMP

Code: Select all  Expand view
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
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: Testing PNG reader

Postby lailton.webmaster » Thu May 20, 2010 2:35 pm

Patricio Avalos Aguirre wrote:Hola

como se debería usar con BTNBMP

Code: Select all  Expand view
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: 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


Somiente esso e usar dela forma que tu estas hacendo en lo REDEFINE :D
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Testing PNG reader

Postby Patricio Avalos Aguirre » Thu May 20, 2010 5: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: Select all  Expand view
  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
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: Testing PNG reader

Postby lailton.webmaster » Thu May 20, 2010 5: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:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Testing PNG reader

Postby ryugarai27 » Tue Aug 21, 2012 6: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
User avatar
ryugarai27
 
Posts: 65
Joined: Fri Feb 13, 2009 12:03 pm
Location: Manila, Philippines

Re: Testing PNG reader

Postby Lailton » Tue Aug 21, 2012 4:52 pm

Ryugarai,

Add to your prg

Code: Select all  Expand view
#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
User avatar
Lailton
 
Posts: 153
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil

Re: Testing PNG reader

Postby ryugarai27 » Fri Aug 24, 2012 7:24 am

Lailton,

Thanks!

ryugarai27
User avatar
ryugarai27
 
Posts: 65
Joined: Fri Feb 13, 2009 12:03 pm
Location: Manila, Philippines


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 24 guests