summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/bitmap.cxx
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2003-04-24 13:56:22 +0000
committerRüdiger Timm <rt@openoffice.org>2003-04-24 13:56:22 +0000
commit6494495f2c4c970e5fc9e2a5a881ceb494de835a (patch)
treeda112ab747f28a4fb2b303d0bbe817cc284ed2df /vcl/source/gdi/bitmap.cxx
parent3088337ad40ee8f67ecfc7cc40fa84a5f7763836 (diff)
INTEGRATION: CWS draw9 (1.6.6); FILE MERGED
2003/04/09 10:52:26 thb 1.6.6.1: #107169# Optimited printing of masked and alpha bitmaps, which are now drawn directly on white backgrounds
Diffstat (limited to 'vcl/source/gdi/bitmap.cxx')
-rw-r--r--vcl/source/gdi/bitmap.cxx42
1 files changed, 40 insertions, 2 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 5651cb70b5f1..64d7a8bdf620 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmap.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: hr $ $Date: 2003-03-27 17:57:55 $
+ * last change: $Author: rt $ $Date: 2003-04-24 14:56:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1929,6 +1929,44 @@ BOOL Bitmap::CombineSimple( const Bitmap& rMask, BmpCombine eCombine )
return bRet;
}
+// ------------------------------------------------------------------
+
+BOOL Bitmap::Blend( const AlphaMask& rAlpha, const Color& rBackgroundColor )
+{
+ // TODO: Have a look at OutputDevice::ImplDrawAlpha() for some
+ // optimizations. Might even consolidate the code here and there.
+
+ // convert to a truecolor bitmap, if we're a paletted one. There's
+ // room for tradeoff decision here, maybe later for an overload (or a flag)
+ if( GetBitCount() <= 8 )
+ Convert( BMP_CONVERSION_24BIT );
+
+ BitmapReadAccess* pAlphaAcc = const_cast<AlphaMask&>(rAlpha).AcquireReadAccess();
+ BitmapWriteAccess* pAcc = AcquireWriteAccess();
+ BOOL bRet = FALSE;
+
+ if( pAlphaAcc && pAcc )
+ {
+ const long nWidth = Min( pAlphaAcc->Width(), pAcc->Width() );
+ const long nHeight = Min( pAlphaAcc->Height(), pAcc->Height() );
+
+ for( long nY = 0L; nY < nHeight; ++nY )
+ for( long nX = 0L; nX < nWidth; ++nX )
+ pAcc->SetPixel( nY, nX,
+ pAcc->GetPixel( nY, nX ).Merge( rBackgroundColor,
+ 255 - pAlphaAcc->GetPixel( nY, nX ) ) );
+
+ bRet = TRUE;
+ }
+
+ const_cast<AlphaMask&>(rAlpha).ReleaseAccess( pAlphaAcc );
+ ReleaseAccess( pAcc );
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------
+
BOOL Bitmap::MakeMono( BYTE cThreshold )
{
return ImplMakeMono( cThreshold );