summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-03-05 09:13:55 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-03-05 09:19:04 +0000
commit159b5088ee303f7adf6a4c0e5e72b32c37f9f910 (patch)
tree66c57f19be7f94792a93b5d5cb1d7a57ffebb82b
parent4f56b20b567fd6fc0b3c428c8e3811eae7f2e679 (diff)
Resolves: fdo#31306 some icons don't get grayed when disabled
some of our menu icons are not RGBA, but our fade-out code only handled images with an alpha channel, so we need to extend it for bitmaps with alpha channel icons
-rw-r--r--vcl/source/gdi/outdev2.cxx54
1 files changed, 52 insertions, 2 deletions
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx
index 6d8987e43c14..d6553ab70edf 100644
--- a/vcl/source/gdi/outdev2.cxx
+++ b/vcl/source/gdi/outdev2.cxx
@@ -1162,6 +1162,44 @@ void OutputDevice::ImplDrawMask( const Point& rDestPt, const Size& rDestSize,
}
}
+namespace
+{
+ BitmapEx makeDisabledBitmap(const Bitmap &rBitmap)
+ {
+ const Size aTotalSize( rBitmap.GetSizePixel() );
+ Bitmap aGrey( aTotalSize, 8, &Bitmap::GetGreyPalette( 256 ) );
+ AlphaMask aGreyAlphaMask( aTotalSize );
+ BitmapReadAccess* pBmp = const_cast<Bitmap&>(rBitmap).AcquireReadAccess();
+ BitmapWriteAccess* pGrey = aGrey.AcquireWriteAccess();
+ BitmapWriteAccess* pGreyAlphaMask = aGreyAlphaMask.AcquireWriteAccess();
+
+ if( pBmp && pGrey && pGreyAlphaMask )
+ {
+ BitmapColor aGreyVal( 0 );
+ BitmapColor aGreyAlphaMaskVal( 0 );
+ const int nLeft = 0, nRight = aTotalSize.Width();
+ const int nTop = 0, nBottom = nTop + aTotalSize.Height();
+
+ for( int nY = nTop; nY < nBottom; ++nY )
+ {
+ for( int nX = nLeft; nX < nRight; ++nX )
+ {
+ aGreyVal.SetIndex( pBmp->GetLuminance( nY, nX ) );
+ pGrey->SetPixel( nY, nX, aGreyVal );
+
+ aGreyAlphaMaskVal.SetIndex( static_cast< sal_uInt8 >( 128ul ) );
+ pGreyAlphaMask->SetPixel( nY, nX, aGreyAlphaMaskVal );
+ }
+ }
+ }
+
+ const_cast<Bitmap&>(rBitmap).ReleaseAccess( pBmp );
+ aGrey.ReleaseAccess( pGrey );
+ aGreyAlphaMask.ReleaseAccess( pGreyAlphaMask );
+ return BitmapEx( aGrey, aGreyAlphaMask );
+ }
+}
+
// ------------------------------------------------------------------
void OutputDevice::DrawImage( const Point& rPos, const Image& rImage, sal_uInt16 nStyle )
@@ -1174,7 +1212,13 @@ void OutputDevice::DrawImage( const Point& rPos, const Image& rImage, sal_uInt16
switch( rImage.mpImplData->meType )
{
case IMAGETYPE_BITMAP:
- DrawBitmap( rPos, *static_cast< Bitmap* >( rImage.mpImplData->mpData ) );
+ {
+ const Bitmap &rBitmap = *static_cast< Bitmap* >( rImage.mpImplData->mpData );
+ if( nStyle & IMAGE_DRAW_DISABLE )
+ DrawBitmapEx( rPos, makeDisabledBitmap(rBitmap) );
+ else
+ DrawBitmap( rPos, rBitmap );
+ }
break;
case IMAGETYPE_IMAGE:
@@ -1210,7 +1254,13 @@ void OutputDevice::DrawImage( const Point& rPos, const Size& rSize,
switch( rImage.mpImplData->meType )
{
case IMAGETYPE_BITMAP:
- DrawBitmap( rPos, rSize, *static_cast< Bitmap* >( rImage.mpImplData->mpData ) );
+ {
+ const Bitmap &rBitmap = *static_cast< Bitmap* >( rImage.mpImplData->mpData );
+ if( nStyle & IMAGE_DRAW_DISABLE )
+ DrawBitmapEx( rPos, rSize, makeDisabledBitmap(rBitmap) );
+ else
+ DrawBitmap( rPos, rSize, rBitmap );
+ }
break;
case IMAGETYPE_IMAGE: