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