summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/image.cxx
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2007-06-06 13:11:14 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2007-06-06 13:11:14 +0000
commit87b37c9ac33d4b6aac21f48dad4803aacc73dcaf (patch)
treed5770d2cdf153ec7664b867449ed55ef65571de5 /vcl/source/gdi/image.cxx
parent8e675895afd2224f3f40c124358688ab9f845241 (diff)
INTEGRATION: CWS ka009 (1.24.34); FILE MERGED
2007/06/06 13:02:25 ka 1.24.34.5: resolved conflicts 2007/04/26 09:17:20 ka 1.24.34.4: reapplied patches due to new header structure / removed warnings 2006/10/19 09:34:44 ka 1.24.34.3: RESYNC: (1.24-1.26); FILE MERGED 2006/07/14 14:57:35 dr 1.24.34.2: #i66680# warningfree 2006/07/12 22:03:52 ka 1.24.34.1: #i66680#: added patch for optimized ImageList handling
Diffstat (limited to 'vcl/source/gdi/image.cxx')
-rw-r--r--vcl/source/gdi/image.cxx1032
1 files changed, 200 insertions, 832 deletions
diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx
index f3d9f800f97b..02585111a753 100644
--- a/vcl/source/gdi/image.cxx
+++ b/vcl/source/gdi/image.cxx
@@ -1,12 +1,13 @@
+#include <stdio.h>
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: image.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: rt $ $Date: 2007-04-26 09:29:11 $
+ * last change: $Author: ihi $ $Date: 2007-06-06 14:11:14 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -32,7 +33,6 @@
* MA 02111-1307 USA
*
************************************************************************/
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
@@ -79,8 +79,8 @@
#include <image.hxx>
#endif
-DBG_NAME( Image )
-DBG_NAME( ImageList )
+DBG_NAME( Image );
+DBG_NAME( ImageList );
#define IMAGE_FILE_VERSION 100
@@ -119,35 +119,32 @@ Image::Image( const ResId& rResId ) :
pResMgr->Increment( pResMgr->GetObjSize( (RSHEADER_TYPE*)pResMgr->GetClass() ) );
}
- if( nObjMask & RSC_IMAGE_MASKBITMAP )
+ if( !aBmpEx.IsEmpty() )
{
- if( !aBmpEx.IsEmpty() )
+ if( nObjMask & RSC_IMAGE_MASKBITMAP )
{
if( aBmpEx.GetTransparentType() == TRANSPARENT_NONE )
{
const Bitmap aMaskBitmap( ResId( (RSHEADER_TYPE*)pResMgr->GetClass(), *pResMgr ) );
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMaskBitmap );
}
- }
- pResMgr->Increment( pResMgr->GetObjSize( (RSHEADER_TYPE*)pResMgr->GetClass() ) );
- }
+ pResMgr->Increment( pResMgr->GetObjSize( (RSHEADER_TYPE*)pResMgr->GetClass() ) );
+ }
- if( nObjMask & RSC_IMAGE_MASKCOLOR )
- {
- if( ! aBmpEx.IsEmpty() )
+ if( nObjMask & RSC_IMAGE_MASKCOLOR )
{
if( aBmpEx.GetTransparentType() == TRANSPARENT_NONE )
{
const Color aMaskColor( ResId( (RSHEADER_TYPE*)pResMgr->GetClass(), *pResMgr ) );
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMaskColor );
}
+
+ pResMgr->Increment( pResMgr->GetObjSize( (RSHEADER_TYPE*)pResMgr->GetClass() ) );
}
- pResMgr->Increment( pResMgr->GetObjSize( (RSHEADER_TYPE*)pResMgr->GetClass() ) );
- }
- if( !aBmpEx.IsEmpty() )
ImplInit( aBmpEx );
+ }
}
}
@@ -268,10 +265,6 @@ Size Image::GetSizePixel() const
case IMAGETYPE_IMAGE:
aRet = static_cast< ImplImageData* >( mpImplData->mpData )->maBmpEx.GetSizePixel();
break;
-
- case IMAGETYPE_IMAGEREF:
- aRet = static_cast< ImplImageRefData* >( mpImplData->mpData )->mpImplData->maImageSize;
- break;
}
}
@@ -297,14 +290,6 @@ BitmapEx Image::GetBitmapEx() const
case IMAGETYPE_IMAGE:
aRet = static_cast< ImplImageData* >( mpImplData->mpData )->maBmpEx;
break;
-
- case IMAGETYPE_IMAGEREF:
- {
- ImplImageRefData* pData = static_cast< ImplImageRefData* >( mpImplData->mpData );
-
- aRet = pData->mpImplData->mpImageBitmap->GetBitmapEx( 1, &pData->mnIndex );
- }
- break;
}
}
@@ -449,10 +434,6 @@ BOOL Image::operator==( const Image& rImage ) const
bRet = static_cast< ImplImageData* >( rImage.mpImplData->mpData )->IsEqual( *static_cast< ImplImageData* >( mpImplData->mpData ) );
break;
- case IMAGETYPE_IMAGEREF:
- bRet = static_cast< ImplImageRefData* >( rImage.mpImplData->mpData )->IsEqual( *static_cast< ImplImageRefData* >( mpImplData->mpData ) );
- break;
-
default:
bRet = false;
break;
@@ -508,42 +489,19 @@ ImageList::ImageList( const ResId& rResId ) :
pResMgr->ReadLong();
}
- BitmapEx aBmpEx;
- sal_Int32 nCount = pResMgr->ReadLong();
- ::boost::scoped_array< USHORT > aIdArray( new USHORT[ nCount ] );
- ::std::vector< ::rtl::OUString > aImageNames( nCount );
- ::rtl::OUString aResMgrName( pResMgr->GetFileName() );
- ::rtl::OUString aUserImageName;
- sal_Int32 nPos = aResMgrName.lastIndexOf( '\\' );
+ sal_Int32 nCount = pResMgr->ReadLong();
+ ImplInit( static_cast< USHORT >( nCount ), Size() );
- // load file entry list
+ BitmapEx aEmpty;
for( sal_Int32 i = 0; i < nCount; ++i )
{
- aImageNames[ i ] = pResMgr->ReadString();
- aIdArray[ i ] = static_cast< USHORT >( pResMgr->ReadLong() );
- }
-
- if( -1 == nPos )
- nPos = aResMgrName.lastIndexOf( '/' );
-
- if( -1 != nPos++ )
- {
- const sal_Int32 nSecondPos = aResMgrName.lastIndexOf( '.' );
- aUserImageName = aResMgrName.copy( nPos, ( ( -1 != nSecondPos ) ? nSecondPos : aResMgrName.getLength() ) - nPos );
+ rtl::OUString aName = pResMgr->ReadString();
+ USHORT nId = static_cast< USHORT >( pResMgr->ReadLong() );
+ mpImplData->AddImage( aName, nId, aEmpty );
}
- aUserImageName += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rResId.GetId() ) );
- aUserImageName += ::rtl::OUString::valueOf( nCount );
-
- ::rtl::OUString aCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
- aUserImageName += aCurrentSymbolsStyle;
-
- ImplInitBitmapEx( aUserImageName, aImageNames, aCurrentSymbolsStyle, aBmpEx, spMaskColor.get() );
-
if( nObjMask & RSC_IMAGELIST_IDCOUNT )
pResMgr->ReadShort();
-
- ImplInit( aBmpEx, sal::static_int_cast<USHORT>(nCount), aIdArray.get(), NULL, 4 );
}
}
@@ -551,7 +509,7 @@ ImageList::ImageList( const ResId& rResId ) :
ImageList::ImageList( const ::std::vector< ::rtl::OUString >& rNameVector,
const ::rtl::OUString& rPrefix,
- const Color* pMaskColor ) :
+ const Color* ) :
mpImplData( NULL ),
mnInitSize( 1 ),
mnGrowSize( 4 )
@@ -560,22 +518,15 @@ ImageList::ImageList( const ::std::vector< ::rtl::OUString >& rNameVector,
DBG_CTOR( ImageList, NULL );
- BitmapEx aBmpEx;
- ::rtl::OUString aUserImageName( rPrefix );
- ::std::vector< ::rtl::OUString > aImageNames( rNameVector.size() );
- const lang::Locale& rLocale = Application::GetSettings().GetUILocale();
-
- for( sal_Int32 i = 0, nCount = rNameVector.size(); i < nCount; ++i )
- ( aImageNames[ i ] = rPrefix ) += rNameVector[ i ];
+ ImplInit( sal::static_int_cast< USHORT >( rNameVector.size() ), Size() );
- aUserImageName = ( ( aUserImageName += rLocale.Language ) += rLocale.Country ).replace( '/', '_' );
- aUserImageName += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rNameVector.size() ) );
-
- ::rtl::OUString aCurrentSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
- aUserImageName += aCurrentSymbolsStyle;
-
- ImplInitBitmapEx( aUserImageName, aImageNames, aCurrentSymbolsStyle, aBmpEx, pMaskColor );
- ImplInit( aBmpEx, static_cast< USHORT >( rNameVector.size() ), NULL, &rNameVector, 4 );
+ mpImplData->maPrefix = rPrefix;
+ for( sal_uInt32 i = 0; i < rNameVector.size(); ++i )
+ {
+// fprintf (stderr, "List %p [%d]: '%s'\n",
+// this, i, rtl::OUStringToOString( rNameVector[i], RTL_TEXTENCODING_UTF8 ).getStr() );
+ mpImplData->AddImage( rNameVector[ i ], static_cast< USHORT >( i ) + 1, BitmapEx() );
+ }
}
// -----------------------------------------------------------------------
@@ -593,250 +544,140 @@ ImageList::ImageList( const ImageList& rImageList ) :
// -----------------------------------------------------------------------
-ImageList::ImageList( const BitmapEx& rBitmapEx,
- USHORT nInit, USHORT* pIdAry, USHORT nGrow ) :
- mpImplData( NULL ),
- mnInitSize( nInit ),
- mnGrowSize( nGrow )
+ImageList::~ImageList()
{
- DBG_CTOR( ImageList, NULL );
+ DBG_DTOR( ImageList, NULL );
- ImplInit( rBitmapEx, nInit, pIdAry, NULL, nGrow );
+ if( mpImplData && ( 0 == --mpImplData->mnRefCount ) )
+ delete mpImplData;
}
-// -----------------------------------------------------------------------
-
-ImageList::ImageList( const BitmapEx& rBitmapEx,
- const ::std::vector< ::rtl::OUString >& rNameVector,
- USHORT nGrow ) :
- mpImplData( NULL ),
- mnInitSize( static_cast< USHORT >( rNameVector.size() ) ),
- mnGrowSize( nGrow )
+void ImageList::ImplInit( USHORT nItems, const Size &rSize )
{
- RTL_LOGFILE_CONTEXT( aLog, "vcl: ImageList::ImageList( const BitmapEx& ..." );
-
- DBG_CTOR( ImageList, NULL );
-
- ImplInit( rBitmapEx, static_cast< USHORT >( rNameVector.size() ), NULL, &rNameVector, nGrow );
+ mpImplData = new ImplImageList;
+ mpImplData->mnRefCount = 1;
+ mpImplData->maImages.reserve( nItems );
+ mpImplData->maImageSize = rSize;
}
// -----------------------------------------------------------------------
-ImageList::ImageList( const Bitmap& rBitmap,
- USHORT nInit, USHORT* pIdAry, USHORT nGrow ) :
- mpImplData( NULL ),
- mnInitSize( nInit ),
- mnGrowSize( nGrow )
+void ImageAryData::Load(const rtl::OUString &rPrefix)
{
- DBG_CTOR( ImageList, NULL );
-
- ImplInit( rBitmap, nInit, pIdAry, NULL, nGrow );
-}
-
-// -----------------------------------------------------------------------
-
-ImageList::ImageList( const Bitmap& rBitmap, const Bitmap& rMaskBmp,
- USHORT nInit, USHORT* pIdAry, USHORT nGrow ) :
- mpImplData( NULL ),
- mnInitSize( nInit ),
- mnGrowSize( nGrow )
-{
- DBG_CTOR( ImageList, NULL );
+ static ImplImageTreeSingletonRef aImageTree;
- const BitmapEx aBmpEx( rBitmap, rMaskBmp );
+ ::rtl::OUString aSymbolsStyle = Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
- ImplInit( aBmpEx, nInit, pIdAry, NULL, nGrow );
-}
+ BitmapEx aBmpEx;
-// -----------------------------------------------------------------------
+// fprintf (stderr, "Attempt load of '%s'\n",
+// rtl::OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ).getStr() );
-ImageList::ImageList( const Bitmap& rBitmap, const Color& rColor,
- USHORT nInit, USHORT* pIdAry, USHORT nGrow )
-{
- DBG_CTOR( ImageList, NULL );
-
- const BitmapEx aBmpEx( rBitmap, rColor );
-
- ImplInit( aBmpEx, nInit, pIdAry, NULL, nGrow );
+ rtl::OUString aFileName = rPrefix;
+ aFileName += maName;
+#ifdef DEBUG
+ bool bSuccess = aImageTree->loadImage( aFileName, aSymbolsStyle, maBitmapEx, true );
+ DBG_ASSERT (bSuccess, "ImageAryData::Failed to load image");
+#else
+ aImageTree->loadImage( aFileName, aSymbolsStyle, maBitmapEx, true );
+#endif
}
// -----------------------------------------------------------------------
-ImageList::~ImageList()
+void ImageList::ImplMakeUnique()
{
- DBG_DTOR( ImageList, NULL );
-
- if( mpImplData && ( 0 == --mpImplData->mnRefCount ) && ( 0 == mpImplData->mnIRefCount ) )
- delete mpImplData;
+ if( mpImplData && mpImplData->mnRefCount > 1 )
+ {
+ --mpImplData->mnRefCount;
+ mpImplData = new ImplImageList( *mpImplData ) ;
+ }
}
// -----------------------------------------------------------------------
-
-void ImageList::ImplInitBitmapEx( const ::rtl::OUString& rUserImageName,
- const ::std::vector< ::rtl::OUString >& rImageNames,
- const ::rtl::OUString& rSymbolsStyle,
- BitmapEx& rBmpEx,
- const Color* pMaskColor ) const
+// Rather a performance hazard:
+BitmapEx ImageList::GetAsHorizontalStrip() const
{
- static ImplImageTreeSingletonRef aImageTree;
-
- if( !aImageTree->loadImage( rUserImageName, rSymbolsStyle, rBmpEx ) )
+ Size aSize( mpImplData->maImageSize );
+ USHORT nCount = GetImageCount();
+ if( !nCount )
+ return BitmapEx();
+ aSize.Width() *= nCount;
+
+ // Load any stragglers
+ for (USHORT nIdx = 0; nIdx < nCount; nIdx++)
{
- BitmapEx aCurBmpEx;
- Size aItemSizePixel;
- bool bInit = false;
-
- for( sal_Int32 i = 0, nCount = rImageNames.size(); i < nCount; ++i )
- {
- if( aImageTree->loadImage( rImageNames[ i ], rSymbolsStyle, aCurBmpEx, true ) )
- {
- const Size aCurSizePixel( aCurBmpEx.GetSizePixel() );
-
- if( !bInit )
- {
- const Size aTotalSize( aCurSizePixel.Width() * nCount, aCurSizePixel.Height() );
- BYTE cTransparent = 255;
- const Bitmap aBmp( aTotalSize, 24 );
- const AlphaMask aAlphaMask( aTotalSize, &cTransparent );
-
- aItemSizePixel = aCurSizePixel;
- rBmpEx = BitmapEx( aBmp, aAlphaMask );
-
- bInit = true;
- }
-
-#ifdef DBG_UTIL
- if( ( aItemSizePixel.Width() < aCurSizePixel.Width() ) ||
- ( aItemSizePixel.Height() < aCurSizePixel.Height() ) )
- {
- ByteString aStr( "Differerent dimensions in ItemList images: " );
-
- aStr += ByteString( String( rImageNames[ i ] ), RTL_TEXTENCODING_ASCII_US );
- aStr += " is ";
- aStr += ByteString::CreateFromInt32( aCurSizePixel.Width() );
- aStr += "x";
- aStr += ByteString::CreateFromInt32( aCurSizePixel.Height() );
- aStr += " but needs to be ";
- aStr += ByteString::CreateFromInt32( aItemSizePixel.Width() );
- aStr += "x";
- aStr += ByteString::CreateFromInt32( aItemSizePixel.Height() );
-
- DBG_ERROR( aStr.GetBuffer() );
- }
-#endif
-
- const Rectangle aRectDst( Point( aItemSizePixel.Width() * i, 0 ), aItemSizePixel );
- const Rectangle aRectSrc( Point( 0, 0 ), aCurSizePixel );
-
- rBmpEx.CopyPixel( aRectDst, aRectSrc, &aCurBmpEx );
- }
-#ifdef DBG_UTIL
- else
- {
- ByteString aErrorStr( "ImageList::ImplInitBitmapEx(...): could not load image <" );
- DBG_ERROR( ( ( aErrorStr += ByteString( String( rImageNames[ i ] ), RTL_TEXTENCODING_ASCII_US ) ) += '>' ).GetBuffer() );
- }
-#endif
- }
+ ImageAryData *pData = mpImplData->maImages[ nIdx ];
+ if( pData->IsLoadable() )
+ pData->Load( mpImplData->maPrefix );
+ }
- if( !rBmpEx.IsEmpty() )
- {
- if( !rBmpEx.IsTransparent() && pMaskColor )
- rBmpEx = BitmapEx( rBmpEx.GetBitmap(), *pMaskColor );
+ BitmapEx aTempl = mpImplData->maImages[ 0 ]->maBitmapEx;
+ BitmapEx aResult;
+ Bitmap aPixels( aSize, aTempl.GetBitmap().GetBitCount() );
+ if( aTempl.IsAlpha() )
+ aResult = BitmapEx( aPixels, AlphaMask( aSize ) );
+ else if( aTempl.IsTransparent() )
+ aResult = BitmapEx( aPixels, Bitmap( aSize, aTempl.GetMask().GetBitCount() ) );
+ else
+ aResult = BitmapEx( aPixels );
- aImageTree->addUserImage( rUserImageName, rBmpEx );
- }
+ Rectangle aSrcRect( Point( 0, 0 ), mpImplData->maImageSize );
+ for (USHORT nIdx = 0; nIdx < nCount; nIdx++)
+ {
+ Rectangle aDestRect( Point( nIdx * mpImplData->maImageSize.Width(), 0 ),
+ mpImplData->maImageSize );
+ ImageAryData *pData = mpImplData->maImages[ nIdx ];
+ aResult.CopyPixel( aDestRect, aSrcRect, &pData->maBitmapEx);
}
+
+ return aResult;
}
// -----------------------------------------------------------------------
-void ImageList::ImplInit( const BitmapEx& rBitmapEx,
- USHORT nInit, const USHORT* pIdAry,
- const ::std::vector< ::rtl::OUString >* pNames,
- USHORT nGrow )
+void ImageList::InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
+ const std::vector< rtl::OUString > &rNameVector )
{
- RTL_LOGFILE_CONTEXT( aLog, "vcl: ImageList::ImplInit" );
-
- if( !nInit )
- {
- mpImplData = NULL;
- mnInitSize = 1;
- mnGrowSize = nGrow;
- }
- else
- {
- DBG_ASSERT( !nInit || rBitmapEx.GetSizePixel().Width(), "ImageList::ImageList(): nInitSize != 0 and BmpSize.Width() == 0" );
- DBG_ASSERT( (rBitmapEx.GetSizePixel().Width() % nInit) == 0, "ImageList::ImageList(): BmpSize % nInitSize != 0" );
-
- Size aBmpSize( rBitmapEx.GetSizePixel() );
+ USHORT nItems = sal::static_int_cast< USHORT >( rNameVector.size() );
- mpImplData = new ImplImageList;
- mnInitSize = nInit;
- mnGrowSize = nGrow;
+// fprintf (stderr, "InsertFromHorizontalStrip (1) [%d items]\n", nItems);
- mpImplData->mnRefCount = 1;
- mpImplData->mnIRefCount = 0;
- mpImplData->mnCount = nInit;
- mpImplData->mnRealCount = nInit;
- mpImplData->mnArySize = nInit;
- mpImplData->mpAry = new ImageAryData[nInit];
- mpImplData->maImageSize = Size( aBmpSize.Width() / nInit, aBmpSize.Height() );
-
- for( USHORT i = 0; i < nInit; i++ )
- {
- mpImplData->mpAry[ i ].mnId = pIdAry ? pIdAry[ i ] : ( i + 1 );
- mpImplData->mpAry[ i ].mnRefCount = 1;
+ if (!nItems)
+ return;
- if( pNames && ( i < pNames->size() ) )
- mpImplData->mpAry[ i ].maName = (*pNames)[ i ];
- }
+ Size aSize( rBitmapEx.GetSizePixel() );
+ DBG_ASSERT (rBitmapEx.GetSizePixel().Width() % nItems != 0,
+ "ImageList::InsertFromHorizontalStrip - very odd size");
+ aSize.Width() /= nItems;
+ ImplInit( nItems, aSize );
- mpImplData->mpImageBitmap = new ImplImageBmp;
- mpImplData->mpImageBitmap->Create( rBitmapEx,
- mpImplData->maImageSize.Width(),
- mpImplData->maImageSize.Height(),
- nInit );
+ for (USHORT nIdx = 0; nIdx < nItems; nIdx++)
+ {
+ BitmapEx aBitmap( rBitmapEx, Point( nIdx * aSize.Width(), 0 ), aSize );
+ mpImplData->AddImage( rNameVector[ nIdx ], nIdx + 1, aBitmap );
}
}
// -----------------------------------------------------------------------
-void ImageList::ImplMakeUnique()
+void ImageList::InsertFromHorizontalBitmap( const ResId& rResId,
+ USHORT nCount,
+ const Color *pMaskColor,
+ const Color *pSearchColors,
+ const Color *pReplaceColors,
+ ULONG nColorCount)
{
- if( mpImplData && mpImplData->mnRefCount > 1 )
- {
- ImplImageList* pNewData = new ImplImageList;
- USHORT i = 0, n = 0;
+// fprintf (stderr, "InsertFromHorizontalBitmap\n");
- --mpImplData->mnRefCount;
+ BitmapEx aBmpEx( rResId );
+ if (!aBmpEx.IsTransparent())
+ aBmpEx = BitmapEx( aBmpEx.GetBitmap(), *pMaskColor );
+ if (nColorCount)
+ aBmpEx.Replace( pSearchColors, pReplaceColors, nColorCount );
- pNewData->mnRefCount = 1;
- pNewData->mnIRefCount = 0;
- pNewData->mnCount = mpImplData->mnCount;
- pNewData->mnRealCount = mpImplData->mnRealCount;
- pNewData->mnArySize = mpImplData->mnArySize;
- pNewData->mpAry = new ImageAryData[ pNewData->mnArySize ];
- pNewData->maImageSize = mpImplData->maImageSize;
- pNewData->mpImageBitmap = new ImplImageBmp;
- pNewData->mpImageBitmap->Create( pNewData->maImageSize.Width(), pNewData->maImageSize.Height(), pNewData->mnArySize );
-
- while( i < mpImplData->mnArySize )
- {
- if( mpImplData->mpAry[i].mnId )
- {
- pNewData->mpAry[n].maName = mpImplData->mpAry[i].maName;
- pNewData->mpAry[n].mnId = mpImplData->mpAry[i].mnId;
- pNewData->mpAry[n].mnRefCount = 1;
- pNewData->mpImageBitmap->Replace( n, *mpImplData->mpImageBitmap, i );
- ++n;
- }
-
- ++i;
- }
-
- mpImplData = pNewData;
- }
+ std::vector< rtl::OUString > aNames( nCount );
+ InsertFromHorizontalStrip( aBmpEx, aNames );
}
// -----------------------------------------------------------------------
@@ -845,23 +686,11 @@ USHORT ImageList::ImplGetImageId( const ::rtl::OUString& rImageName ) const
{
DBG_CHKTHIS( ImageList, NULL );
- if( mpImplData && rImageName.getLength() )
- {
- USHORT nPos = 0, i = 0;
-
- while( i < mpImplData->mnArySize )
- {
- if( mpImplData->mpAry[i].maName == rImageName )
- return mpImplData->mpAry[i].mnId;
-
- if ( mpImplData->mpAry[i].mnId )
- ++nPos;
-
- ++i;
- }
- }
-
- return 0;
+ ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
+ if( pImg )
+ return pImg->mnId;
+ else
+ return 0;
}
// -----------------------------------------------------------------------
@@ -875,106 +704,10 @@ void ImageList::AddImage( USHORT nId, const Image& rImage )
DBG_ASSERT( rImage.mpImplData, "ImageList::AddImage(): Wrong Size" );
DBG_ASSERT( !mpImplData || (rImage.GetSizePixel() == mpImplData->maImageSize), "ImageList::AddImage(): Wrong Size" );
- bool bHasImage = ( rImage.mpImplData != 0 );
- ImageType eImageType = IMAGETYPE_BITMAP;
- Size aImageSize;
- USHORT nIndex;
-
- if( bHasImage )
- {
- eImageType = rImage.mpImplData->meType;
- aImageSize = rImage.GetSizePixel();
- }
- else
- {
- if( mpImplData )
- {
- eImageType = IMAGETYPE_BITMAP;
- aImageSize = mpImplData->maImageSize;
- }
- else
- return;
- }
-
if( !mpImplData )
- {
- mpImplData = new ImplImageList;
- mpImplData->mnRefCount = 1;
- mpImplData->mnIRefCount = 0;
- mpImplData->mnCount = 0;
- mpImplData->mnRealCount = 0;
- mpImplData->mnArySize = mnInitSize;
- mpImplData->mpAry = new ImageAryData[mnInitSize];
- mpImplData->maImageSize = aImageSize;
- mpImplData->mpImageBitmap = new ImplImageBmp;
- mpImplData->mpImageBitmap->Create( aImageSize.Width(), aImageSize.Height(), mnInitSize );
- }
- else
- ImplMakeUnique();
-
- if( mpImplData->mnRealCount == mpImplData->mnArySize )
- {
- ImageAryData* pOldAry = mpImplData->mpAry;
- USHORT nOldSize = mpImplData->mnArySize;
-
- mpImplData->mnArySize = sal::static_int_cast<USHORT>(mpImplData->mnArySize + mnGrowSize);
- mpImplData->mpAry = new ImageAryData[mpImplData->mnArySize];
-
- for( USHORT i = 0; i < nOldSize; ++i )
- mpImplData->mpAry[ i ] = pOldAry[ i ];
-
- mpImplData->mpImageBitmap->Expand( mnGrowSize );
- delete[] pOldAry;
- nIndex = mpImplData->mnRealCount;
- }
- else
- {
- nIndex = 0;
+ ImplInit( 0, rImage.GetSizePixel() );
- while( mpImplData->mpAry[nIndex].mnRefCount )
- ++nIndex;
- }
-
- switch( eImageType )
- {
- case IMAGETYPE_BITMAP:
- {
- if( !bHasImage )
- {
- const Bitmap aBmp( aImageSize, 1 );
- const BitmapEx aBmpEx( aBmp, Color( COL_BLACK ) );
-
- mpImplData->mpImageBitmap->Replace( nIndex, aBmpEx );
- }
- else
- mpImplData->mpImageBitmap->Replace( nIndex, *static_cast< Bitmap* >( rImage.mpImplData->mpData ) );
- }
- break;
-
- case IMAGETYPE_IMAGE:
- {
- ImplImageData* pData = static_cast< ImplImageData* >( rImage.mpImplData->mpData );
-
- if( pData->mpImageBitmap )
- mpImplData->mpImageBitmap->Replace( nIndex, *pData->mpImageBitmap, 0 );
- else
- mpImplData->mpImageBitmap->Replace( nIndex, pData->maBmpEx );
- }
- break;
-
- case IMAGETYPE_IMAGEREF:
- {
- ImplImageRefData* pData = static_cast< ImplImageRefData* >( rImage.mpImplData->mpData );
-
- mpImplData->mpImageBitmap->Replace( nIndex, *pData->mpImplData->mpImageBitmap, pData->mnIndex );
- }
- break;
- }
-
- ++mpImplData->mnCount;
- ++mpImplData->mnRealCount;
- mpImplData->mpAry[nIndex].mnId = nId;
- mpImplData->mpAry[nIndex].mnRefCount = 1;
+ mpImplData->AddImage( rtl::OUString(), nId, rImage.GetBitmapEx());
}
// -----------------------------------------------------------------------
@@ -983,101 +716,11 @@ void ImageList::AddImage( const ::rtl::OUString& rImageName, const Image& rImage
{
DBG_ASSERT( GetImagePos( rImageName ) == IMAGELIST_IMAGE_NOTFOUND, "ImageList::AddImage() - ImageName already exists" );
- USHORT i, nMax = 0;
-
- if( mpImplData )
- {
- for( i = 0; i < mpImplData->mnArySize; ++i )
- {
- if( mpImplData->mpAry[ i ].mnId > nMax )
- {
- nMax = mpImplData->mpAry[ i ].mnId;
- }
- }
- }
-
- if( nMax < USHRT_MAX )
- {
- AddImage( ++nMax, rImage );
-
- for( i = 0; i < mpImplData->mnArySize; ++i )
- {
- if( mpImplData->mpAry[ i ].mnId == nMax )
- {
- mpImplData->mpAry[ i ].maName = rImageName;
- break;
- }
- }
- }
- else
- {
- DBG_ERROR( "No free image id left" );
- }
-}
-
-// -----------------------------------------------------------------------
-
-void ImageList::CopyImage( USHORT nId, USHORT nCopyId )
-{
- DBG_CHKTHIS( ImageList, NULL );
- DBG_ASSERT( nId, "ImageList::CopyImage(): ImageId == 0" );
- DBG_ASSERT( GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND, "ImageList::CopyImage(): ImageId already exists" );
- DBG_ASSERT( GetImagePos( nCopyId ) != IMAGELIST_IMAGE_NOTFOUND, "ImageList::CopyImage(): Unknown nCopyId" );
-
- USHORT nIndex, nCopyIndex = 0;
-
- while( nCopyIndex < mpImplData->mnArySize )
- {
- if ( mpImplData->mpAry[nCopyIndex].mnId == nCopyId )
- break;
-
- ++nCopyIndex;
- }
-
- if( nCopyIndex < mpImplData->mnArySize )
- {
- ImplMakeUnique();
-
- if( mpImplData->mnRealCount == mpImplData->mnArySize )
- {
- ImageAryData* pOldAry = mpImplData->mpAry;
- USHORT nOldSize = mpImplData->mnArySize;
-
- mpImplData->mnArySize = sal::static_int_cast<USHORT>(mpImplData->mnArySize + mnGrowSize);
- mpImplData->mpAry = new ImageAryData[mpImplData->mnArySize];
-
- for( USHORT i = 0; i < nOldSize; ++i )
- mpImplData->mpAry[ i ] = pOldAry[ i ];
-
- mpImplData->mpImageBitmap->Expand( mnGrowSize );
- delete[] pOldAry;
- nIndex = mpImplData->mnRealCount;
- }
- else
- {
- nIndex = 0;
-
- while( mpImplData->mpAry[nIndex].mnRefCount )
- nIndex++;
- }
-
- mpImplData->mpImageBitmap->Replace( nIndex, *mpImplData->mpImageBitmap, nCopyIndex );
-
- ++mpImplData->mnCount;
- ++mpImplData->mnRealCount;
- mpImplData->mpAry[nIndex].mnId = nId;
- mpImplData->mpAry[nIndex].mnRefCount = 1;
- }
-}
-
-// -----------------------------------------------------------------------
-
-void ImageList::CopyImage( const ::rtl::OUString& rImageName, const ::rtl::OUString& rCopyName )
-{
- const USHORT nId1 = ImplGetImageId( rImageName ), nId2 = ImplGetImageId( rCopyName );
+ if( !mpImplData )
+ ImplInit( 0, rImage.GetSizePixel() );
- if( nId1 && nId2 )
- CopyImage( nId1, nId2 );
+ mpImplData->AddImage( rImageName, GetImageCount() + 1,
+ rImage.GetBitmapEx() );
}
// -----------------------------------------------------------------------
@@ -1110,31 +753,13 @@ void ImageList::ReplaceImage( USHORT nId, USHORT nReplaceId )
DBG_ASSERT( GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND, "ImageList::ReplaceImage(): Unknown nId" );
DBG_ASSERT( GetImagePos( nReplaceId ) != IMAGELIST_IMAGE_NOTFOUND, "ImageList::ReplaceImage(): Unknown nReplaceId" );
- USHORT nPos1 = 0, nPos2 = 0;
-
- while( nPos1 < mpImplData->mnArySize )
+ ULONG nPosDest = GetImagePos( nId );
+ ULONG nPosSrc = GetImagePos( nReplaceId );
+ if( nPosDest != IMAGELIST_IMAGE_NOTFOUND &&
+ nPosSrc != IMAGELIST_IMAGE_NOTFOUND )
{
- if ( mpImplData->mpAry[nPos1].mnId == nId )
- break;
-
- ++nPos1;
- }
-
- if( nPos1 < mpImplData->mnArySize )
- {
- while( nPos2 < mpImplData->mnArySize )
- {
- if( mpImplData->mpAry[nPos2].mnId == nReplaceId )
- break;
-
- ++nPos2;
- }
-
- if( nPos2 < mpImplData->mnArySize )
- {
- ImplMakeUnique();
- mpImplData->mpImageBitmap->Replace( nPos1, nPos2 );
- }
+ ImplMakeUnique();
+ mpImplData->maImages[nPosDest] = mpImplData->maImages[nPosSrc];
}
}
@@ -1154,29 +779,12 @@ void ImageList::RemoveImage( USHORT nId )
{
DBG_CHKTHIS( ImageList, NULL );
- if( mpImplData )
+ for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); ++i )
{
- USHORT i = 0;
-
- ImplMakeUnique();
-
- while( i < mpImplData->mnArySize )
- {
- if( mpImplData->mpAry[i].mnId == nId )
- break;
-
- ++i;
- }
-
- if( i < mpImplData->mnArySize )
+ if( mpImplData->maImages[ i ]->mnId == nId )
{
- --mpImplData->mpAry[i].mnRefCount;
- mpImplData->mpAry[i].mnId = 0;
-
- if( !mpImplData->mpAry[i].mnRefCount )
- --mpImplData->mnRealCount;
-
- --mpImplData->mnCount;
+ mpImplData->RemoveImage( static_cast< USHORT >( i ) );
+ break;
}
}
}
@@ -1197,49 +805,50 @@ Image ImageList::GetImage( USHORT nId ) const
{
DBG_CHKTHIS( ImageList, NULL );
- Image aImage;
+// fprintf (stderr, "GetImage %d\n", nId);
+
+ Image aRet;
if( mpImplData )
{
- USHORT i = 0;
-
- while( i < mpImplData->mnArySize )
+ std::vector<ImageAryData *>::iterator aIter;
+ for( aIter = mpImplData->maImages.begin();
+ aIter != mpImplData->maImages.end(); aIter++)
{
- if( mpImplData->mpAry[i].mnId == nId )
- break;
-
- ++i;
- }
-
- if( i < mpImplData->mnArySize )
- {
- ImplImageRefData* mpData = new ImplImageRefData;
-
- ++mpImplData->mnIRefCount;
- ++mpImplData->mpAry[i].mnRefCount;
- mpData->mpImplData = mpImplData;
- mpData->mnIndex = i;
+ if ((*aIter)->mnId == nId)
+ {
+ if( (*aIter)->IsLoadable() )
+ (*aIter)->Load( mpImplData->maPrefix );
- aImage.mpImplData = new ImplImage;
- aImage.mpImplData->mnRefCount = 1;
- aImage.mpImplData->meType = IMAGETYPE_IMAGEREF;
- aImage.mpImplData->mpData = mpData;
+ aRet = Image( (*aIter)->maBitmapEx );
+ }
}
}
- return aImage;
+ return aRet;
}
// -----------------------------------------------------------------------
Image ImageList::GetImage( const ::rtl::OUString& rImageName ) const
{
- const USHORT nId = ImplGetImageId( rImageName );
+// fprintf (stderr, "GetImage '%s'\n",
+// rtl::OUStringToOString( rImageName, RTL_TEXTENCODING_UTF8 ).getStr() );
- if( nId )
- return GetImage( nId );
- else
- return Image();
+ if( mpImplData )
+ {
+ ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
+
+ if( pImg )
+ {
+ if( pImg->IsLoadable() )
+ pImg->Load( mpImplData->maPrefix );
+ return Image( pImg->maBitmapEx );
+ }
+ }
+// fprintf (stderr, "no such image\n");
+
+ return Image();
}
// -----------------------------------------------------------------------
@@ -1260,7 +869,7 @@ USHORT ImageList::GetImageCount() const
{
DBG_CHKTHIS( ImageList, NULL );
- return( mpImplData ? mpImplData->mnCount : 0 );
+ return mpImplData ? static_cast< USHORT >( mpImplData->maImages.size() ) : 0;
}
// -----------------------------------------------------------------------
@@ -1271,23 +880,21 @@ USHORT ImageList::GetImagePos( USHORT nId ) const
if( mpImplData && nId )
{
- USHORT nPos = 0, i = 0;
-
- while( i < mpImplData->mnArySize )
+ for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); ++i )
{
- if( mpImplData->mpAry[i].mnId == nId )
- return nPos;
-
- if ( mpImplData->mpAry[i].mnId )
- ++nPos;
-
- ++i;
+ if (mpImplData->maImages[ i ]->mnId == nId)
+ return static_cast< USHORT >( i );
}
}
return IMAGELIST_IMAGE_NOTFOUND;
}
+bool ImageList::HasImageAtPos( USHORT nId ) const
+{
+ return GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND;
+}
+
// -----------------------------------------------------------------------
USHORT ImageList::GetImagePos( const ::rtl::OUString& rImageName ) const
@@ -1296,17 +903,10 @@ USHORT ImageList::GetImagePos( const ::rtl::OUString& rImageName ) const
if( mpImplData && rImageName.getLength() )
{
- USHORT nPos = 0, i = 0;
-
- while( i < mpImplData->mnArySize )
+ for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ )
{
- if( mpImplData->mpAry[i].maName == rImageName )
- return nPos;
-
- if ( mpImplData->mpAry[i].mnId )
- ++nPos;
-
- ++i;
+ if (mpImplData->maImages[i]->maName == rImageName)
+ return static_cast< USHORT >( i );
}
}
@@ -1319,21 +919,8 @@ USHORT ImageList::GetImageId( USHORT nPos ) const
{
DBG_CHKTHIS( ImageList, NULL );
- if( mpImplData )
- {
- USHORT nRealPos = 0, i = 0;
-
- while( i < mpImplData->mnArySize )
- {
- if( (nPos == nRealPos) && (mpImplData->mpAry[i].mnId) )
- return mpImplData->mpAry[i].mnId;
-
- if ( mpImplData->mpAry[i].mnId )
- ++nRealPos;
-
- ++i;
- }
- }
+ if( mpImplData && (nPos < GetImageCount()) )
+ return mpImplData->maImages[ nPos ]->mnId;
return 0;
}
@@ -1350,11 +937,8 @@ void ImageList::GetImageIds( ::std::vector< USHORT >& rIds ) const
if( mpImplData )
{
- for( USHORT i = 0; i < mpImplData->mnArySize; ++i )
- {
- if( mpImplData->mpAry[ i ].mnId )
- rIds.push_back( mpImplData->mpAry[ i ].mnId );
- }
+ for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ )
+ rIds.push_back( mpImplData->maImages[i]->mnId );
}
}
@@ -1364,21 +948,8 @@ void ImageList::GetImageIds( ::std::vector< USHORT >& rIds ) const
{
DBG_CHKTHIS( ImageList, NULL );
- if( mpImplData )
- {
- USHORT nRealPos = 0, i = 0;
-
- while( i < mpImplData->mnArySize )
- {
- if( (nPos == nRealPos) && (mpImplData->mpAry[i].mnId) )
- return mpImplData->mpAry[i].maName;
-
- if ( mpImplData->mpAry[i].mnId )
- ++nRealPos;
-
- ++i;
- }
- }
+ if( mpImplData && (nPos < GetImageCount()) )
+ return mpImplData->maImages[ nPos ]->maName;
return ::rtl::OUString();
}
@@ -1395,11 +966,8 @@ void ImageList::GetImageNames( ::std::vector< ::rtl::OUString >& rNames ) const
if( mpImplData )
{
- for( USHORT i = 0; i < mpImplData->mnArySize; ++i )
- {
- if( mpImplData->mpAry[ i ].mnId )
- rNames.push_back( mpImplData->mpAry[ i ].maName );
- }
+ for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ )
+ rNames.push_back( mpImplData->maImages[ i ]->maName );
}
}
@@ -1412,92 +980,25 @@ Size ImageList::GetImageSize() const
Size aRet;
if( mpImplData )
- aRet = mpImplData->maImageSize;
-
- return aRet;
-}
-
-// -----------------------------------------------------------------------
-
-BitmapEx ImageList::GetBitmapEx() const
-{
- DBG_CHKTHIS( ImageList, NULL );
-
- BitmapEx aRet;
-
- if( mpImplData )
{
- USHORT* pPosAry = new USHORT[ mpImplData->mnCount ];
- USHORT nPosCount = 0;
+ aRet = mpImplData->maImageSize;
- for( USHORT i = 0; i < mpImplData->mnArySize; i++ )
+ // force load of 1st image to see - uncommon case.
+ if( aRet.Width() == 0 && aRet.Height() == 0 &&
+ !mpImplData->maImages.empty() )
{
- if( mpImplData->mpAry[i].mnId )
- {
- pPosAry[ nPosCount ] = i;
- ++nPosCount;
- }
+ Image aTmp = GetImage( mpImplData->maImages[ 0 ]->mnId );
+ aRet = mpImplData->maImageSize = aTmp.GetSizePixel();
}
-
- aRet = mpImplData->mpImageBitmap->GetBitmapEx( nPosCount, pPosAry );
- delete[] pPosAry;
}
+// fprintf (stderr, "GetImageSize returns %d, %d\n",
+// aRet.Width(), aRet.Height());
return aRet;
}
// -----------------------------------------------------------------------
-ImageList ImageList::GetColorTransformedImageList( ImageColorTransform eColorTransform ) const
-{
- DBG_CHKTHIS( ImageList, NULL );
-
- ImageList aRet;
-
- if( IMAGECOLORTRANSFORM_HIGHCONTRAST == eColorTransform )
- {
- Color* pSrcColors = NULL;
- Color* pDstColors = NULL;
- ULONG nColorCount = 0;
-
- aRet = *this;
- aRet.ImplMakeUnique();
-
- Image::GetColorTransformArrays( eColorTransform, pSrcColors, pDstColors, nColorCount );
-
- if( nColorCount && pSrcColors && pDstColors && mpImplData )
- aRet.mpImplData->mpImageBitmap->ReplaceColors( pSrcColors, pDstColors, nColorCount );
-
- delete[] pSrcColors;
- delete[] pDstColors;
- }
- else if( IMAGECOLORTRANSFORM_MONOCHROME_BLACK == eColorTransform ||
- IMAGECOLORTRANSFORM_MONOCHROME_WHITE == eColorTransform )
- {
- aRet = *this;
- aRet.ImplMakeUnique();
- aRet.mpImplData->mpImageBitmap->ColorTransform( ( BmpColorMode )( eColorTransform ) );
- }
-
- if( !aRet.GetImageCount() )
- aRet = *this;
-
- return aRet;
-}
-
-// -----------------------------------------------------------------------
-
-void ImageList::Invert()
-{
- ImageList aNew( *this );
- aNew.ImplMakeUnique();
- aNew.mpImplData->mpImageBitmap->Invert();
-
- *this = aNew;
-}
-
-// -----------------------------------------------------------------------
-
ImageList& ImageList::operator=( const ImageList& rImageList )
{
DBG_CHKTHIS( ImageList, NULL );
@@ -1506,12 +1007,10 @@ ImageList& ImageList::operator=( const ImageList& rImageList )
if( rImageList.mpImplData )
++rImageList.mpImplData->mnRefCount;
- if( mpImplData && ( 0 == --mpImplData->mnRefCount ) && ( 0 == mpImplData->mnIRefCount ) )
+ if( mpImplData && ( 0 == --mpImplData->mnRefCount ) )
delete mpImplData;
mpImplData = rImageList.mpImplData;
- mnInitSize = rImageList.mnInitSize;
- mnGrowSize = rImageList.mnGrowSize;
return *this;
}
@@ -1529,140 +1028,9 @@ BOOL ImageList::operator==( const ImageList& rImageList ) const
bRet = true;
else if( !rImageList.mpImplData || !mpImplData )
bRet = false;
- else if( ( rImageList.mpImplData->mnCount == mpImplData->mnCount ) &&
- ( rImageList.mpImplData->maImageSize == mpImplData->maImageSize ) )
- {
- bRet = true;
- }
+ else if( rImageList.GetImageCount() == GetImageCount() &&
+ rImageList.mpImplData->maImageSize == mpImplData->maImageSize )
+ bRet = true; // strange semantic
return bRet;
}
-
-// -----------------------------------------------------------------------
-
-SvStream& operator>>( SvStream& rIStream, ImageList& rImageList )
-{
- DBG_CHKOBJ( &rImageList, ImageList, NULL );
-
- if( rImageList.mpImplData )
- {
- --rImageList.mpImplData->mnRefCount;
-
- if( ( 0 == rImageList.mpImplData->mnRefCount ) && ( 0 == rImageList.mpImplData->mnIRefCount ) )
- delete rImageList.mpImplData;
- }
-
- rImageList.mpImplData = NULL;
-
- USHORT nVersion;
- Size aImageSize;
- BOOL bImageList;
-
- rIStream >> nVersion >> rImageList.mnInitSize >> rImageList.mnGrowSize >> bImageList;
-
- if( bImageList )
- {
- BitmapEx aBmpEx;
- Bitmap aBmp;
- BYTE bMaskOrAlpha, bMaskColor;
-
- rIStream >> aImageSize.Width() >> aImageSize.Height();
-
- rImageList.mpImplData = new ImplImageList;
- rImageList.mpImplData->mnRefCount = 1;
- rImageList.mpImplData->mnIRefCount= 0;
- rImageList.mpImplData->mnCount = rImageList.mnInitSize;
- rImageList.mpImplData->mnRealCount = rImageList.mnInitSize;
- rImageList.mpImplData->mnArySize = rImageList.mnInitSize;
- rImageList.mpImplData->mpAry = new ImageAryData[ rImageList.mnInitSize ];
- rImageList.mpImplData->maImageSize = aImageSize;
-
- for( USHORT i = 0; i < rImageList.mnInitSize; ++i )
- {
- rIStream >> rImageList.mpImplData->mpAry[i].mnId;
- rImageList.mpImplData->mpAry[i].mnRefCount = 1;
- }
-
- rIStream >> aBmp >> bMaskOrAlpha;
-
- if( bMaskOrAlpha )
- {
- Bitmap aMaskOrAlpha;
-
- rIStream >> aMaskOrAlpha;
-
- if( aMaskOrAlpha.GetBitCount() == 8 && aMaskOrAlpha.HasGreyPalette() )
- aBmpEx = BitmapEx( aBmp, AlphaMask( aMaskOrAlpha ) );
- else
- aBmpEx = BitmapEx( aBmp, aMaskOrAlpha );
- }
-
- rIStream >> bMaskColor;
-
- if( bMaskColor )
- {
- Color aMaskColor;
-
- rIStream >> aMaskColor;
-
- if( !aBmpEx.IsAlpha() && !aBmpEx.IsTransparent() )
- aBmpEx = BitmapEx( aBmp, aMaskColor );
- }
-
- rImageList.mpImplData->mpImageBitmap = new ImplImageBmp;
- rImageList.mpImplData->mpImageBitmap->Create( aBmpEx, aImageSize.Width(), aImageSize.Height(), rImageList.mnInitSize );
- }
-
- return rIStream;
-}
-
-// -----------------------------------------------------------------------
-
-SvStream& operator<<( SvStream& rOStream, const ImageList& rImageList )
-{
- DBG_CHKOBJ( &rImageList, ImageList, NULL );
-
- USHORT nVersion = IMAGE_FILE_VERSION;
- BOOL bImageList = rImageList.mpImplData ? true : false;
-
- rOStream << nVersion;
-
- if ( !bImageList || !rImageList.mpImplData->mnCount )
- rOStream << rImageList.mnInitSize << rImageList.mnGrowSize << ( bImageList = FALSE );
- else
- {
- rOStream << rImageList.mpImplData->mnCount;
- rOStream << rImageList.mnGrowSize;
- rOStream << bImageList;
- rOStream << rImageList.mpImplData->maImageSize.Width();
- rOStream << rImageList.mpImplData->maImageSize.Height();
-
- USHORT* mpPosAry = new USHORT[rImageList.mpImplData->mnCount];
- USHORT nPosCount = 0;
-
- for( USHORT i = 0; i < rImageList.mpImplData->mnArySize; ++i )
- {
- if( rImageList.mpImplData->mpAry[i].mnId )
- {
- rOStream << rImageList.mpImplData->mpAry[i].mnId;
- mpPosAry[ nPosCount++ ] = i;
- }
- }
-
- BitmapEx aBmpEx( rImageList.mpImplData->mpImageBitmap->GetBitmapEx( nPosCount, mpPosAry ) );
- const BOOL bMaskOrAlpha = aBmpEx.IsAlpha() || aBmpEx.IsTransparent();
- const BOOL bMaskColor = false;
-
- rOStream << aBmpEx.GetBitmap() << bMaskOrAlpha;
-
- if( bMaskOrAlpha )
- rOStream << ( aBmpEx.IsAlpha() ? aBmpEx.GetAlpha().ImplGetBitmap() : aBmpEx.GetMask() );
-
- // BitmapEx doesn't have internal mask colors anymore
- rOStream << bMaskColor;
-
- delete[] mpPosAry;
- }
-
- return rOStream;
-}