summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2004-05-21 13:37:52 +0000
committerRüdiger Timm <rt@openoffice.org>2004-05-21 13:37:52 +0000
commite8f6cf2ae4ccab40db406399b45a1ee3dc6279f5 (patch)
tree44f83745ca85207e16854e807119686788fed04e /vcl/source
parent6458f2cb3d8193c7f5e7f168c726e780d6ca9476 (diff)
INTEGRATION: CWS bmpres01 (1.8.34); FILE MERGED
2004/05/03 08:08:36 ka 1.8.34.9: added additional short reading to satisfy bitmap respource structure 2004/04/27 13:28:03 ka 1.8.34.8: using new image resource structure 2004/04/21 14:25:36 ka 1.8.34.7: added support for external compressed image tree 2004/04/15 11:48:58 ka 1.8.34.6: added support for MONOCHROME_BLACK AND ..._WHITE images/bitmaps 2004/03/03 15:51:11 ka 1.8.34.5: cleanup 2004/03/03 15:43:19 ka 1.8.34.4: cleanup 2004/02/13 13:06:12 ka 1.8.34.3: #i22149#: support for alpha masks (cleanup) 2004/02/12 11:42:07 ka 1.8.34.2: #i22149# support for alpha masks 2004/02/03 14:49:16 ka 1.8.34.1: added support for transparent resource bitmaps from local file system
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/bitmapex.cxx82
1 files changed, 76 insertions, 6 deletions
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index b455bbec9f5f..ac9b78f2b2de 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmapex.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: vg $ $Date: 2004-01-06 13:29:58 $
+ * last change: $Author: rt $ $Date: 2004-05-21 14:37:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,9 @@
*
************************************************************************/
+#include <hash_map>
+#include <ctype.h>
+
#ifndef _RTL_CRC_H_
#include <rtl/crc.h>
#endif
@@ -77,9 +80,21 @@
#ifndef _SV_ALPHA_HXX
#include <alpha.hxx>
#endif
+#ifndef _SV_IMAGE_H
+#include <image.h>
+#endif
#ifndef _SV_BITMAPEX_HXX
#include <bitmapex.hxx>
#endif
+#ifndef _SV_PNGREAD_HXX
+#include <pngread.hxx>
+#endif
+#ifndef _SV_IMPIMAGETREE_H
+#include <impimagetree.hxx>
+#endif
+#ifndef _SV_RC_H
+#include <tools/rc.h>
+#endif
// ------------
// - BitmapEx -
@@ -105,6 +120,30 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx ) :
// ------------------------------------------------------------------
+BitmapEx::BitmapEx( const ResId& rResId ) :
+ eTransparent( TRANSPARENT_NONE ),
+ bAlpha ( FALSE )
+{
+ static ImplImageTreeSingletonRef aImageTree;
+ ResMgr* pResMgr = NULL;
+
+ ResMgr::GetResourceSkipHeader( rResId.SetRT( RSC_BITMAP ), &pResMgr );
+ pResMgr->ReadShort();
+ pResMgr->ReadShort();
+
+ const String aFileName( pResMgr->ReadString() );
+
+ if( !aImageTree->loadImage( aFileName, *this ) )
+ {
+#ifdef DBG_UTIL
+ ByteString aErrorStr( "BitmapEx::BitmapEx( const ResId& rResId ): could not load image <" );
+ DBG_ERROR( ( aErrorStr += ByteString( aFileName, RTL_TEXTENCODING_ASCII_US ) ) += '>' );
+#endif
+ }
+}
+
+// ------------------------------------------------------------------
+
BitmapEx::BitmapEx( const Bitmap& rBmp ) :
aBitmap ( rBmp ),
aBitmapSize ( aBitmap.GetSizePixel() ),
@@ -161,6 +200,8 @@ BitmapEx::~BitmapEx()
// ------------------------------------------------------------------
+// ------------------------------------------------------------------
+
BitmapEx& BitmapEx::operator=( const BitmapEx& rBitmapEx )
{
if( &rBitmapEx != this )
@@ -274,9 +315,25 @@ Bitmap BitmapEx::GetBitmap( const Color* pTransReplaceColor ) const
BitmapEx BitmapEx::GetColorTransformedBitmapEx( BmpColorMode eColorMode ) const
{
- BitmapEx aRet( *this );
+ BitmapEx aRet;
- aRet.aBitmap = aBitmap.GetColorTransformedBitmap( eColorMode );
+ if( BMP_COLOR_HIGHCONTRAST == eColorMode )
+ {
+ aRet = *this;
+ aRet.aBitmap = aBitmap.GetColorTransformedBitmap( eColorMode );
+ }
+ else if( BMP_COLOR_MONOCHROME_BLACK == eColorMode ||
+ BMP_COLOR_MONOCHROME_WHITE == eColorMode )
+ {
+ aRet = *this;
+ aRet.aBitmap = aRet.aBitmap.GetColorTransformedBitmap( eColorMode );
+
+ if( !aRet.aMask.IsEmpty() )
+ {
+ aRet.aMask.CombineSimple( aRet.aBitmap, BMP_COMBINE_OR );
+ aRet.aBitmap.Erase( ( BMP_COLOR_MONOCHROME_BLACK == eColorMode ) ? COL_BLACK : COL_WHITE );
+ }
+ }
return aRet;
}
@@ -557,7 +614,7 @@ BOOL BitmapEx::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc,
}
else
{
- sal_uInt8 cBlack = 0;
+ sal_uInt8 cBlack = 0;
AlphaMask* pAlpha = new AlphaMask( GetSizePixel(), &cBlack );
aMask = pAlpha->ImplGetBitmap();
@@ -584,6 +641,20 @@ BOOL BitmapEx::CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc,
aMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->aMask );
}
}
+ else if( IsAlpha() )
+ {
+ sal_uInt8 cBlack = 0;
+ const AlphaMask aAlphaSrc( pBmpExSrc->GetSizePixel(), &cBlack );
+
+ aMask.CopyPixel( rRectDst, rRectSrc, &aAlphaSrc.ImplGetBitmap() );
+ }
+ else if( IsTransparent() )
+ {
+ Bitmap aMaskSrc( pBmpExSrc->GetSizePixel(), 1 );
+
+ aMaskSrc.Erase( Color( COL_BLACK ) );
+ aMask.CopyPixel( rRectDst, rRectSrc, &aMaskSrc );
+ }
}
}
}
@@ -765,4 +836,3 @@ SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx )
return rIStm;
}
-