convert PNG to BMP from code
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Hello all
wrapper function from LibPng to convert PNG Image to BMP image from code...
we can read PNG image and show like bitmap image, the level transparences ( alpha channel) is not support![Sad :(](./images/smilies/icon_sad.gif)
(this is only for test)
for Harbour:
Link: hbzlib.lib
LIB: http://www.sitasoft.net/fivewin/lib/harbour/fwpngh.lib
sample: http://www.sitasoft.net/fivewin/samples/tpngh.rar
for xHarbour:
Link: zlib.lib
LIB: http://www.sitasoft.net/fivewin/lib/xharbour/fwpngx.lib
sample: http://www.sitasoft.net/fivewin/samples/tpngx.rar
code sample
there are some difference between H - xH, i think is library zlib in both compilers...
wrapper function from LibPng to convert PNG Image to BMP image from code...
we can read PNG image and show like bitmap image, the level transparences ( alpha channel) is not support
![Sad :(](./images/smilies/icon_sad.gif)
(this is only for test)
for Harbour:
Link: hbzlib.lib
LIB: http://www.sitasoft.net/fivewin/lib/harbour/fwpngh.lib
sample: http://www.sitasoft.net/fivewin/samples/tpngh.rar
for xHarbour:
Link: zlib.lib
LIB: http://www.sitasoft.net/fivewin/lib/xharbour/fwpngx.lib
sample: http://www.sitasoft.net/fivewin/samples/tpngx.rar
code sample
- 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 ) ) 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
@ 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
there are some difference between H - xH, i think is library zlib in both compilers...