Kaydet (Commit) a5cdf286 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS iconupdate300u1 (1.24.26); FILE MERGED

2008/05/30 14:34:23 ka 1.24.26.2: using AlphaMasks instead of B/W masks
2008/05/29 16:50:27 ka 1.24.26.1: #i80705#: using alpha blending/greyscaling to display disabled icons
üst 6f3e2350
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite * OpenOffice.org - a multi-platform office productivity suite
* *
* $RCSfile: impimage.cxx,v $ * $RCSfile: impimage.cxx,v $
* $Revision: 1.24 $ * $Revision: 1.25 $
* *
* This file is part of OpenOffice.org. * This file is part of OpenOffice.org.
* *
...@@ -219,7 +219,7 @@ void ImplImageBmp::Create( long nItemWidth, long nItemHeight, USHORT nInitSize ) ...@@ -219,7 +219,7 @@ void ImplImageBmp::Create( long nItemWidth, long nItemHeight, USHORT nInitSize )
const Size aTotalSize( nInitSize * nItemWidth, nItemHeight ); const Size aTotalSize( nInitSize * nItemWidth, nItemHeight );
maBmpEx = Bitmap( aTotalSize, 24 ); maBmpEx = Bitmap( aTotalSize, 24 );
maDisabledBmp.SetEmpty(); maDisabledBmpEx.SetEmpty();
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -237,7 +237,7 @@ void ImplImageBmp::Create( long nItemWidth, long nItemHeight, USHORT nInitSize ) ...@@ -237,7 +237,7 @@ void ImplImageBmp::Create( long nItemWidth, long nItemHeight, USHORT nInitSize )
void ImplImageBmp::Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight, USHORT nInitSize ) void ImplImageBmp::Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight, USHORT nInitSize )
{ {
maBmpEx = rBmpEx; maBmpEx = rBmpEx;
maDisabledBmp.SetEmpty(); maDisabledBmpEx.SetEmpty();
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -262,8 +262,8 @@ void ImplImageBmp::Expand( USHORT nGrowSize ) ...@@ -262,8 +262,8 @@ void ImplImageBmp::Expand( USHORT nGrowSize )
maBmpEx.Expand( nDX, 0UL ); maBmpEx.Expand( nDX, 0UL );
if( !maDisabledBmp.IsEmpty() ) if( !maDisabledBmpEx.IsEmpty() )
maDisabledBmp.Expand( nDX, 0UL ); maDisabledBmpEx.Expand( nDX, 0UL );
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -294,8 +294,8 @@ void ImplImageBmp::Replace( USHORT nPos, USHORT nSrcPos ) ...@@ -294,8 +294,8 @@ void ImplImageBmp::Replace( USHORT nPos, USHORT nSrcPos )
maBmpEx.CopyPixel( aDstRect, aSrcRect ); maBmpEx.CopyPixel( aDstRect, aSrcRect );
if( !maDisabledBmp.IsEmpty() ) if( !maDisabledBmpEx.IsEmpty() )
maDisabledBmp.CopyPixel( aDstRect, aSrcRect ); maDisabledBmpEx.CopyPixel( aDstRect, aSrcRect );
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -313,7 +313,7 @@ void ImplImageBmp::Replace( USHORT nPos, const ImplImageBmp& rImageBmp, USHORT n ...@@ -313,7 +313,7 @@ void ImplImageBmp::Replace( USHORT nPos, const ImplImageBmp& rImageBmp, USHORT n
maBmpEx.CopyPixel( aDstRect, aSrcRect, &rImageBmp.maBmpEx ); maBmpEx.CopyPixel( aDstRect, aSrcRect, &rImageBmp.maBmpEx );
ImplUpdateDisabledBmp( nPos ); ImplUpdateDisabledBmpEx( nPos );
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -330,7 +330,7 @@ void ImplImageBmp::Replace( USHORT nPos, const BitmapEx& rBmpEx ) ...@@ -330,7 +330,7 @@ void ImplImageBmp::Replace( USHORT nPos, const BitmapEx& rBmpEx )
maBmpEx.CopyPixel( aDstRect, aSrcRect, &rBmpEx ); maBmpEx.CopyPixel( aDstRect, aSrcRect, &rBmpEx );
ImplUpdateDisabledBmp( nPos ); ImplUpdateDisabledBmpEx( nPos );
delete mpDisplayBmp; delete mpDisplayBmp;
mpDisplayBmp = NULL; mpDisplayBmp = NULL;
...@@ -401,13 +401,8 @@ void ImplImageBmp::Draw( USHORT nPos, OutputDevice* pOutDev, ...@@ -401,13 +401,8 @@ void ImplImageBmp::Draw( USHORT nPos, OutputDevice* pOutDev,
if( nStyle & IMAGE_DRAW_DISABLE ) if( nStyle & IMAGE_DRAW_DISABLE )
{ {
const Point aOutPos1( rPos.X() + 1, rPos.Y() + 1 ); ImplUpdateDisabledBmpEx( nPos);
const StyleSettings& rSettings = pOutDev->GetSettings().GetStyleSettings(); pOutDev->DrawBitmapEx( rPos, aOutSize, aSrcPos, maSize, maDisabledBmpEx );
ImplUpdateDisabledBmp( -1 );
pOutDev->DrawMask( aOutPos1, aOutSize, aSrcPos, maSize, maDisabledBmp, rSettings.GetLightColor() );
pOutDev->DrawMask( rPos, aOutSize, aSrcPos, maSize, maDisabledBmp, rSettings.GetShadowColor() );
} }
else else
{ {
...@@ -588,160 +583,55 @@ pOutDev ...@@ -588,160 +583,55 @@ pOutDev
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void ImplImageBmp::ImplUpdateDisabledBmp( int nPos ) void ImplImageBmp::ImplUpdateDisabledBmpEx( int nPos )
{ {
if( ( nPos >= 0 && !maDisabledBmp.IsEmpty() ) || const Size aTotalSize( maBmpEx.GetSizePixel() );
( nPos < 0 && maDisabledBmp.IsEmpty() ) )
{
Bitmap aBmp( maBmpEx.GetBitmap() );
Bitmap aMask;
if( maBmpEx.IsTransparent() ) if( maDisabledBmpEx.IsEmpty() )
aMask = maBmpEx.GetMask();
else
{ {
aMask = aBmp; Bitmap aGrey( aTotalSize, 8, &Bitmap::GetGreyPalette( 256 ) );
aMask.Convert( BMP_CONVERSION_1BIT_THRESHOLD ); AlphaMask aGreyAlphaMask( aTotalSize );
}
if( maDisabledBmp.IsEmpty() ) maDisabledBmpEx = BitmapEx( aGrey, aGreyAlphaMask );
maDisabledBmp = Bitmap( aBmp.GetSizePixel(), 1 ); nPos = -1;
BitmapReadAccess* pAcc = aBmp.AcquireReadAccess();
BitmapReadAccess* pMsk = aMask.AcquireReadAccess();
BitmapWriteAccess* pDis = maDisabledBmp.AcquireWriteAccess();
if( pAcc && pMsk && pDis )
{
const Color aWhite( COL_WHITE );
const Color aBlack( COL_BLACK );
const BitmapColor aAccWhite( pAcc->GetBestMatchingColor( aWhite ) );
const BitmapColor aMskWhite( pMsk->GetBestMatchingColor( aWhite ) );
const BitmapColor aDisWhite( pDis->GetBestMatchingColor( aWhite ) );
const BitmapColor aDisBlack( pDis->GetBestMatchingColor( aBlack ) );
long nLeft, nTop, nRight, nBottom;
long nCurLeft, nCurRight;
const long nBlackThreshold = FRound( maSize.Width() * maSize.Height() * 0.10 );
if( nPos >= 0 )
{
const Point aPos( nPos * maSize.Width(), 0 );
nLeft = aPos.X();
nTop = 0;
nRight = nLeft + maSize.Width();
nBottom = nTop + maSize.Height();
}
else
{
nLeft = nTop = 0L;
nRight = pDis->Width();
nBottom = pDis->Height();
} }
nCurLeft = nLeft; Bitmap aBmp( maBmpEx.GetBitmap() );
nCurRight = nCurLeft + maSize.Width(); BitmapReadAccess* pBmp( aBmp.AcquireReadAccess() );
AlphaMask aBmpAlphaMask( maBmpEx.GetAlpha() );
while( nCurLeft < nRight ) BitmapReadAccess* pBmpAlphaMask( aBmpAlphaMask.AcquireReadAccess() );
{ Bitmap aGrey( maDisabledBmpEx.GetBitmap() );
sal_Int32 nBlackCount = 0; BitmapWriteAccess* pGrey( aGrey.AcquireWriteAccess() );
AlphaMask aGreyAlphaMask( maDisabledBmpEx.GetAlpha() );
if( pAcc->GetScanlineFormat() == BMP_FORMAT_4BIT_MSN_PAL && BitmapWriteAccess* pGreyAlphaMask( aGreyAlphaMask.AcquireWriteAccess() );
pMsk->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL )
{
// optimized version
const BYTE cAccTest = aAccWhite.GetIndex();
const BYTE cMskTest = aMskWhite.GetIndex();
for( long nY = nTop; nY < nBottom; nY++ ) if( pBmp && pBmpAlphaMask && pGrey && pGreyAlphaMask )
{ {
Scanline pAccScan = pAcc->GetScanline( nY ); BitmapColor aGreyVal( 0 );
Scanline pMskScan = pMsk->GetScanline( nY ); BitmapColor aGreyAlphaMaskVal( 0 );
const Point aPos( ( nPos < 0 ) ? 0 : ( nPos * maSize.Width() ), 0 );
const int nLeft = aPos.X(), nRight = nLeft + ( ( nPos < 0 ) ? aTotalSize.Width() : maSize.Width() );
const int nTop = aPos.Y(), nBottom = nTop + maSize.Height();
for( long nX = nCurLeft; nX < nCurRight; nX++ ) for( int nY = nTop; nY < nBottom; ++nY )
{
if( ( cMskTest == ( pMskScan[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 ) ) ||
( cAccTest == ( ( pAccScan[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f ) ) )
{
pDis->SetPixel( nY, nX, aDisWhite );
}
else
{
pDis->SetPixel( nY, nX, aDisBlack );
++nBlackCount;
}
}
}
}
else if( pAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL &&
pMsk->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL )
{ {
// optimized version for( int nX = nLeft; nX < nRight; ++nX )
const BYTE cAccTest = aAccWhite.GetIndex();
const BYTE cMskTest = aMskWhite.GetIndex();
for( long nY = nTop; nY < nBottom; nY++ )
{ {
Scanline pAccScan = pAcc->GetScanline( nY ); aGreyVal.SetIndex( pBmp->GetLuminance( nY, nX ) );
Scanline pMskScan = pMsk->GetScanline( nY ); pGrey->SetPixel( nY, nX, aGreyVal );
for( long nX = nCurLeft; nX < nCurRight; nX++ ) const BitmapColor aBmpAlphaMaskVal( pBmpAlphaMask->GetPixel( nY, nX ) );
{
if( ( cMskTest == ( pMskScan[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 ) ) ||
( cAccTest == pAccScan[ nX ] ) )
{
pDis->SetPixel( nY, nX, aDisWhite );
}
else
{
pDis->SetPixel( nY, nX, aDisBlack );
++nBlackCount;
}
}
}
}
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, aDisWhite );
}
else
{
pDis->SetPixel( nY, nX, aDisBlack );
++nBlackCount;
}
}
}
}
if( nBlackCount < nBlackThreshold ) aGreyAlphaMaskVal.SetIndex( static_cast< sal_uInt8 >( ::std::min( aBmpAlphaMaskVal.GetIndex() + 178ul, 255ul ) ) );
{ pGreyAlphaMask->SetPixel( nY, nX, aGreyAlphaMaskVal );
// emergency solution if paint bitmap is mostly white
for( long nY = nTop; nY < nBottom; nY++ )
{
for( long nX = nCurLeft; nX < nCurRight; nX++ )
{
if( aMskWhite == pMsk->GetPixel( nY, nX ) )
pDis->SetPixel( nY, nX, aDisWhite );
else
pDis->SetPixel( nY, nX, aDisBlack );
} }
} }
} }
nCurLeft += maSize.Width(); aBmp.ReleaseAccess( pBmp );
nCurRight += maSize.Width(); aBmpAlphaMask.ReleaseAccess( pBmpAlphaMask );
} aGrey.ReleaseAccess( pGrey );
} aGreyAlphaMask.ReleaseAccess( pGreyAlphaMask );
aBmp.ReleaseAccess( pAcc ); maDisabledBmpEx = BitmapEx( aGrey, aGreyAlphaMask );
aMask.ReleaseAccess( pMsk );
maDisabledBmp.ReleaseAccess( pDis );
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment