Testing PNG reader

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

Testing PNG reader

Post by Daniel Garcia-Gil »

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


#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
 
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Testing PNG reader

Post by Daniel Garcia-Gil »

We can do test with BtnBmp class, replace inside Method LoadBitmap this part

Code: Select all | Expand


   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
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
lailton.webmaster
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Testing PNG reader

Post by lailton.webmaster »

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.
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Testing PNG reader

Post by Daniel Garcia-Gil »

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
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
lailton.webmaster
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Testing PNG reader

Post by lailton.webmaster »

Perfect.

i tryed with old function.

thanks Daniel, Perfect job. :lol:
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: Testing PNG reader

Post by fraxzi »

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
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Testing PNG reader

Post by Daniel Garcia-Gil »

Frances

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


no need freeimage.dll
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: Testing PNG reader

Post by fraxzi »

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
Patricio Avalos Aguirre
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile
Contact:

Re: Testing PNG reader

Post by Patricio Avalos Aguirre »

Hola

como se debería usar con BTNBMP

Code: Select all | Expand

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

Re: Testing PNG reader

Post by lailton.webmaster »

Patricio Avalos Aguirre wrote:Hola

como se debería usar con BTNBMP

Code: Select all | Expand

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


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

Re: Testing PNG reader

Post by Patricio Avalos Aguirre »

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

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

Re: Testing PNG reader

Post by lailton.webmaster »

Sem problemas,

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

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

Re: Testing PNG reader

Post by ryugarai27 »

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
Lailton
Posts: 169
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Has thanked: 2 times
Been thanked: 6 times
Contact:

Re: Testing PNG reader

Post by Lailton »

Ryugarai,

Add to your prg

Code: Select all | Expand

#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
ryugarai27
Posts: 65
Joined: Fri Feb 13, 2009 12:03 pm
Location: Manila, Philippines
Contact:

Re: Testing PNG reader

Post by ryugarai27 »

Lailton,

Thanks!

ryugarai27
Post Reply