summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2006-08-22 12:51:19 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2006-08-22 12:51:19 +0000
commitae41e0988e75955a27b6d67bd32a0ccc1cbceaf9 (patch)
treed24f3e7932e5fb41ffac99cda1a139be99547a5f /vcl
parent12e331514deaf93b58c78242d53f9a0963038dc6 (diff)
INTEGRATION: CWS impress104 (1.17.20); FILE MERGED
2006/08/14 09:50:09 sj 1.17.20.1: #139449# creating bitmask for transparent graphics if possible (instead of using always alphabitmap)
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pngread.cxx37
1 files changed, 33 insertions, 4 deletions
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 9e16b8467df8..92f85fb24425 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: pngread.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: ihi $ $Date: 2006-08-01 09:27:51 $
+ * last change: $Author: ihi $ $Date: 2006-08-22 13:51:19 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -689,8 +689,37 @@ void PNGReaderImpl::ImplReadTransparent()
rtl_copyMemory( mpTransTab, &(*maDataIter), mnChunkLen );
maDataIter += mnChunkLen;
- mpAlphaMask = new AlphaMask( Size( mnWidth, mnHeight ) );
- mpMaskAcc = mpAlphaMask->AcquireWriteAccess();
+ const BYTE* pCurr = mpTransTab;
+ const BYTE* const pEnd = mpTransTab+mnChunkLen;
+ sal_Int32 nNumFF = 0, nNum00 = 0;
+ while( pCurr != pEnd )
+ {
+ if( *pCurr == 0 )
+ ++nNum00;
+ else if( *pCurr == 0xFF )
+ ++nNumFF;
+ ++pCurr;
+ }
+
+ if( nNumFF + nNum00 == mnChunkLen )
+ {
+ mpMaskBmp = new Bitmap( Size( mnWidth, mnHeight ), 1 );
+ mpMaskAcc = mpMaskBmp->AcquireWriteAccess();
+
+ const Color aWhite( COL_WHITE );
+ if ( !mpMaskAcc->GetBestPaletteIndex( aWhite ) )
+ {
+ BYTE* pPtr = mpTransTab;
+ while( pPtr != pEnd )
+ *pPtr++ ^= 0xff;
+ }
+ }
+ else
+ {
+ mpAlphaMask = new AlphaMask( Size( mnWidth, mnHeight ) );
+ mpMaskAcc = mpAlphaMask->AcquireWriteAccess();
+ }
+
if ( mpMaskAcc )
mbTransparent = sal_True;
}