vamos por partes :
Faltaria inicializar ::hAlphaLevel = 255 en el Redefine de la clase pero creo que seria mejor iniciarlo en : DATA hAlphaLevel INIT 255 y podrímos quitar las inicializaciones en new() y en define .
el metodo paint :
- Code: Select all Expand view
METHOD Paint() CLASS TBitmap
local aInfo := ::DispBegin(), hBmpOld, nZeroZeroClr, nOldClr
local nAlphaLevel // , hBitmap ya no es necesario
if IsAppThemed() .and. Empty( ::oBrush:hBitmap ) .and. ::lTransparent
if ::oWnd:ClassName() == "TDIALOG"
DrawPBack( ::hWnd, ::hDC )
else
FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
endif
else
#ifdef __CLIPPER__
SetBrushOrgEx( ::hDC, 8 - ::nLeft() % 8, 8 - ::nTop() % 8 )
#else
SetBrushOrgEx( ::hDC, nBmpWidth( ::oBrush:hBitmap ) - ::nLeft, nBmpHeight( ::oBrush:hBitmap ) - ::nTop )
#endif
FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
endif
if Empty( ::hBitmap ) .and. ! Empty( ::cBmpFile )
::LoadBmp( ::cBmpFile )
endif
if ! Empty( ::hBitmap )
if ::lStretch
if SetAlpha() .and. ::lHasAlpha
ABPaint( ::hDC, ::nX, ::nY,::hBitmap, ::nAlphaLevel(),::Super:nWidth(), ::Super:nHeight() ) // nuevo
else
if ! ::lTransparent
PalBmpDraw( ::hDC, ::nX, ::nY, ::hBitmap, ::hPalette,;
::Super:nWidth(), ::Super:nHeight(),, ::lTransparent, ::nClrPane )
else
hBmpOld = SelectObject( ::hDC, ::hBitmap )
nZeroZeroClr = GetPixel( ::hDC, 0, 0 )
SelectObject( ::hDC, hBmpOld )
nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
TransBmp( ::hBitmap, ::nWidth(), ::nHeight(), nZeroZeroClr, ::hDC,;
::nY, ::nX, ::Super:nWidth(), ::Super:nHeight() )
SetBkColor( ::hDC, nOldClr )
endif
endif
else
if ::nZoom > 0
if SetAlpha() .and. ::lHasAlpha
ABPaint( ::hDC, ::nX, ::nY, ::hBitmap, ::nAlphaLevel(), ::nWidth, ::nHeight ) // nuevo
else
if ! ::lTransparent
PalBmpDraw( ::hDC, ::nX, ::nY, ::hBitmap, ::hPalette,;
::nWidth(), ::nHeight(),, ::lTransparent, ::nClrPane )
else
hBmpOld = SelectObject( ::hDC, ::hBitmap )
nZeroZeroClr = GetPixel( ::hDC, 0, 0 )
SelectObject( ::hDC, hBmpOld )
nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
TransBmp( ::hBitmap, ::nWidth(), ::nHeight(), nZeroZeroClr, ::hDC,;
::nY, ::nX, ::nWidth(), ::nHeight() )
SetBkColor( ::hDC, nOldClr )
endif
endif
endif
endif
endif
/* ya no se necesita
if hBitmap != nil
DeleteObject( hBitmap )
endif
*/
if ::bPainted != nil
Eval( ::bPainted, ::hDC )
endif
::DispEnd( aInfo )
return nil
el metodo loadimage ()
- Code: Select all Expand view
METHOD LoadImage( cResName, cBmpFile ) CLASS TBitmap
local lChanged := .f.
local hBmpOld := ::hBitmap
local hPalOld := ::hPalette
local aBmpPal
local cSrc // nuevo
DEFAULT cResName := ::cResName, cBmpFile := ::cBmpFile
/* a sustituir todo este bloque
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"
// ::hBitmap = FWOpenPngFile( cBmpFile )
::hBitmap = ::ReadPalBmpEx( cBmpFile )
::hPalette = 0
else
aBmpPal = PalBmpRead( ::GetDC(), AllTrim( cBmpFile ) )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
::ReleaseDC()
lChanged = .T.
cResName = nil
endif
endif
*/
// codigo nuevo
if ! Empty( cSrc := IfNil( cResName, cBmpFile ) )
aBmpPal := ::ReadPalBmpEx( cSrc )
::hBitmap := aBmpPal[ 1 ]
::hPalette := aBmpPal[ 2 ]
::cBmpFile := If( aBmpPal[ 7 ], nil, aBmpPal[ 6 ] )
::cResName := If( aBmpPal[ 7 ], aBmpPal[ 6 ], nil )
lChanged = .T.
endif
// fin codigo nuevo
if lChanged
::cResName = cResName
::cBmpFile = cBmpFile
if ! Empty( hBmpOld )
PalBmpFree( hBmpOld, hPalOld )
endif
endif
::HasAlpha()
return lChanged
en METHOD Define ....
- Code: Select all Expand view
.................
::lScroll = .f.
::lUnicode = FW_SetUnicode()
// ::hAlphaLevel = 255 inicializado en la DATA
/* bloque a suprimir
if ! Empty( cResName )
aBmpPal = PalBmpLoad( cResName )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
cBmpFile = nil
endif
if cBmpFile != nil
cBmpFile = AllTrim( cBmpFile )
endif
if ! Empty( cBmpFile ) .and. File( cBmpFile )
::cBmpFile = cBmpFile
aBmpPal = PalBmpRead( If( oWnd != nil, oWnd:GetDC(), 0 ), cBmpFile )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
If( oWnd != nil, oWnd:ReleaseDC(),)
endif
*/
::LoadImage( cResName, If( cBmpFile != nil, AllTrim( cBmpFile ), nil ) ) // codigo nuevo y ya usado en el redefine ..
if ! Empty( hBitmap )
::hBitmap = hBitmap
endif
................
en redefine
- Code: Select all Expand view
.......
::lTransparent = lTransparent
::lUnicode = FW_SetUnicode()
::LoadImage( cResName, If( cBmpFile != nil, AllTrim( cBmpFile ), nil ) )
// ::hAlphaLevel = 255 ya asigando en la DATA
// codigo creo que faltante .
if ! Empty( cBmpFile )
::cBmpFile = cBmpFile
endif
::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
......