Mejora en Tbitmap
Posted: Mon Apr 29, 2013 7:31 am
Para poder usar los archivos Png desde fichero en la clase tbitmap .
- Code: Select all Expand view
METHOD LoadImage( cResName, cBmpFile ) CLASS TBitmap
local lChanged := .f.
local hBmpOld := ::hBitmap
local hPalOld := ::hPalette
local aBmpPal
DEFAULT cResName := ::cResName, cBmpFile := ::cBmpFile
if ! Empty( cResName )
aBmpPal = PalBmpLoad( cResName )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
lChanged := .t.
cBmpFile := nil
elseif File( cBmpFile )
IF upper(right(cBmpFile,3))="PNG"
pausa(cBmpfile)
::hBitmap = FWOpenPngFile( cBmpFile )
::hPalette = 0
else
aBmpPal = PalBmpRead( ::GetDC(), AllTrim( cBmpFile ) )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
::ReleaseDC()
lChanged := .t.
cResName := nil
endif
endif
if lChanged
::cResName = cResName
::cBmpFile = cBmpFile
if ! Empty( hBmpOld )
PalBmpFree( hBmpOld, hPalOld )
endif
PalBmpNew( ::hWnd, ::hBitmap, ::hPalette )
endif
::HasAlpha()
return lChanged