Index: vcl/inc/image.h =================================================================== RCS file: /cvs/gsl/vcl/inc/image.h,v retrieving revision 1.3 diff -u -p -u -r1.3 image.h --- vcl/inc/image.h 22 Aug 2002 13:54:19 -0000 1.3 +++ vcl/inc/image.h 15 Sep 2003 13:52:49 -0000 @@ -85,6 +85,7 @@ class ImplImageBmp Bitmap aBmp; Bitmap aMask; Bitmap aDisa; + Bitmap aDisaMask; Bitmap aBmpDisp; Bitmap aMaskDisp; Bitmap aDisaDisp; Index: vcl/source/gdi/impimage.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/gdi/impimage.cxx,v retrieving revision 1.10 diff -u -p -u -r1.10 impimage.cxx --- vcl/source/gdi/impimage.cxx 22 Aug 2002 13:57:18 -0000 1.10 +++ vcl/source/gdi/impimage.cxx 25 Sep 2003 08:48:08 -0000 @@ -193,8 +193,10 @@ void ImplImageBmp::Expand( USHORT nGrowS aBmp.Expand( nDX, 0UL ); aMask.Expand( nDX, 0UL ); - if( !!aDisa ) + if( !!aDisa ) { aDisa.Expand( nDX, 0UL ); + aDisaMask.Expand( nDX, 0UL ); + } memset( pNewAry, 0, nSize ); memcpy( pNewAry, pInfoAry, nOldSize ); @@ -218,8 +220,10 @@ void ImplImageBmp::Replace( USHORT nPos, { aMask.CopyPixel( aDstRect, aSrcRect ); - if( !!aDisa ) + if( !!aDisa ) { aDisa.CopyPixel( aDstRect, aSrcRect ); + aDisaMask.CopyPixel( aDstRect, aSrcRect ); + } } pInfoAry[ nPos ] = pInfoAry[ nSrcPos ]; @@ -241,8 +245,10 @@ void ImplImageBmp::Replace( USHORT nPos, { aMask.CopyPixel( aDstRect, aSrcRect, &rImageBmp.aMask ); - if( !!aDisa ) + if( !!aDisa ) { aDisa.CopyPixel( aDstRect, aSrcRect, &rImageBmp.aDisa ); + aDisaMask.CopyPixel( aDstRect, aSrcRect, &rImageBmp.aDisa ); + } } pInfoAry[ nPos ] = rImageBmp.pInfoAry[ nSrcPos ]; @@ -299,7 +305,10 @@ void ImplImageBmp::ReplaceColors( const ClearCaches(); if( !aDisa.IsEmpty() ) + { aDisa.SetEmpty(); + aDisaMask.SetEmpty(); + } aBmp.Replace( pSrcColors, pDstColors, nColorCount ); } @@ -395,7 +404,9 @@ BOOL ImplImageBmp::HasMaskBitmap() const Bitmap ImplImageBmp::GetMaskBitmap( USHORT nPosCount, USHORT* pPosAry ) const { - Bitmap aNewMask( Size( nPosCount * aSize.Width(), aSize.Height() ), aMask.GetBitCount() ); + Bitmap aNewMask( Size( nPosCount * aSize.Width(), aSize.Height() ), + aMask.GetBitCount(), + aMask.GetBitCount() > 1 ? &Bitmap::GetGreyPalette( 256 ) : NULL ); for( USHORT i = 0; i < nPosCount; i++ ) { @@ -482,7 +493,11 @@ void ImplImageBmp::Draw( USHORT nPos, Ou if( !aDisa ) { - aDisa = Bitmap( aBmpEx.GetSizePixel(), 1 ); + aDisa = Bitmap( aBmpEx.GetSizePixel(), aBmpEx.GetBitCount() ); + if( aBmpEx.GetMask().GetBitCount() == 1 ) + aDisaMask = Bitmap( aBmpEx.GetSizePixel(), 1 ); + else + aDisaMask = Bitmap( aBmpEx.GetSizePixel(), 8, &Bitmap::GetGreyPalette( 256 ) ); ImplUpdateDisaBmp( DISA_ALL ); #ifndef REMOTE_APPSERVER aDisaDisp = aDisa.CreateDisplayBitmap( pOutDev ); @@ -494,10 +509,18 @@ void ImplImageBmp::Draw( USHORT nPos, Ou if( !aDisaDisp && !!aDisa ) aDisaDisp = aDisa.CreateDisplayBitmap( pOutDev ); - pOutDev->DrawMask( aOutPos1, aOutSize, aPos, aSize, - aDisaDisp, rSettings.GetLightColor() ); - pOutDev->DrawMask( aOutPos, aOutSize, aPos, aSize, - aDisaDisp, rSettings.GetShadowColor() ); + if (aDisaDisp.GetBitCount() == 1) + { // A mask + pOutDev->DrawMask( aOutPos1, aOutSize, aPos, aSize, + aDisaDisp, rSettings.GetLightColor() ); + pOutDev->DrawMask( aOutPos, aOutSize, aPos, aSize, + aDisaDisp, rSettings.GetShadowColor() ); + } + else + { + BitmapEx tBmpEx( aDisa, aDisaMask ); + pOutDev->DrawBitmapEx( aOutPos, aOutSize, aPos, aSize, tBmpEx ); + } } else { @@ -505,9 +528,10 @@ void ImplImageBmp::Draw( USHORT nPos, Ou if( nStyle & ( IMAGE_DRAW_COLORTRANSFORM | IMAGE_DRAW_HIGHLIGHT | IMAGE_DRAW_DEACTIVE | IMAGE_DRAW_SEMITRANSPARENT ) ) { + Bitmap aTmpBmp( aBmp ), aTmpMsk( aMask ); const Rectangle aCropRect( aPos, aSize ); - + aTmpBmp.Crop( aCropRect ); aTmpMsk.Crop( aCropRect ); @@ -607,11 +631,8 @@ void ImplImageBmp::Draw( USHORT nPos, Ou aTmpMsk.Convert( BMP_CONVERSION_8BIT_GREYS ); aTmpMsk.Adjust( 50 ); } - - aTmpBmpEx = BitmapEx( aTmpBmp, AlphaMask( aTmpMsk ) ); } - else - aTmpBmpEx = BitmapEx( aTmpBmp, aTmpMsk ); + aTmpBmpEx = BitmapEx( aTmpBmp, aTmpMsk ); pOutDev->DrawBitmapEx( aOutPos, aTmpBmpEx ); bDrawn = TRUE; @@ -651,6 +672,7 @@ void ImplImageBmp::ImplUpdateDisaBmp( US BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); BitmapReadAccess* pMsk = aMask.AcquireReadAccess(); BitmapWriteAccess* pDis = aDisa.AcquireWriteAccess(); + BitmapWriteAccess* pDisMask = aDisaMask.AcquireWriteAccess(); if( pAcc && pMsk && pDis ) { @@ -741,22 +763,52 @@ void ImplImageBmp::ImplUpdateDisaBmp( US } } } - else - { + else if (pAcc->GetBitCount() == 32) + { + for( long nX = nCurLeft; nX < nCurRight; nX++ ) + { for( long nY = nTop; nY < nBottom; nY++ ) { - for( long nX = nCurLeft; nX < nCurRight; nX++ ) - { - if( ( aMskWhite == pMsk->GetPixel( nY, nX ) ) || - ( aAccWhite == pAcc->GetPixel( nY, nX ) ) ) + BitmapColor col = pAcc->GetPixel( nY, nX ); + + if ((nY + nX) % 2 == 0) { - pDis->SetPixel( nY, nX, aDisWhite ); + unsigned char i; + i = ( col.GetRed() * 0.3 + // magic numbers from gdk-pixbuf + col.GetGreen() * 0.59 + + col.GetBlue () * 0.11 ); + + col.SetRed (i / 2 + 127); + col.SetGreen (i / 2 + 127); + col.SetBlue (i / 2 + 127); } else { - pDis->SetPixel( nY, nX, aDisBlack ); - ++nBlackCount; +#define GT_ZERO(c) (((c) >= 0) ? c : 0) + col.SetRed (GT_ZERO (( col.GetRed ()) * 0.7)); + col.SetGreen (GT_ZERO (( col.GetGreen ()) * 0.7)); + col.SetBlue (GT_ZERO (( col.GetBlue ()) * 0.7)); +#undef GT_ZERO } + pDis->SetPixel( nY, nX, col ); + // The way the mask is polarised is most strange + BYTE nAlpha = 255 - (BYTE)pMsk->GetPixel( nY, nX ); + pDisMask->SetPixel( nY, nX, BitmapColor( 255 - (nAlpha / 2) ) ); + } + } + nBlackCount = nBlackThreshold; + } + else + { + for( long nY = nTop; nY < nBottom; nY++ ) + { + for( long nX = nCurLeft; nX < nCurRight; nX++ ) + { + if( ( aMskWhite == pMsk->GetPixel( nY, nX ) ) && + ( aAccWhite != pAcc->GetPixel( nY, nX ) ) ) + pDis->SetPixel( nY, nX, aDisBlack ); + else + pDis->SetPixel( nY, nX, aDisWhite ); } } } @@ -784,6 +836,7 @@ void ImplImageBmp::ImplUpdateDisaBmp( US aBmp.ReleaseAccess( pAcc ); aMask.ReleaseAccess( pMsk ); aDisa.ReleaseAccess( pDis ); + aDisa.ReleaseAccess( pDisMask ); } // -----------------------------------------------------------------------