1 Index: vcl/source/gdi/impbmp.cxx
2 ===================================================================
3 RCS file: /cvs/oo/gsl/vcl/source/gdi/impbmp.cxx,v
4 retrieving revision 1.1.1.1
5 diff -u -r1.1.1.1 impbmp.cxx
6 --- vcl/source/gdi/impbmp.cxx 2000/09/18 17:05:37 1.1.1.1
7 +++ vcl/source/gdi/impbmp.cxx 2002/11/05 20:13:01
10 nBitCount = mpSalBitmap->GetBitCount();
12 - return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : 24 );
13 + return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : ( nBitCount <= 24 ) ? 24 : 32 );
16 // -----------------------------------------------------------------------
17 Index: vcl/unx/source/gdi/salbmp.cxx
18 ===================================================================
19 RCS file: /cvs/oo/gsl/vcl/unx/source/gdi/salbmp.cxx,v
20 retrieving revision 1.8
21 diff -u -r1.8 salbmp.cxx
22 --- vcl/unx/source/gdi/salbmp.cxx 2001/09/11 15:52:22 1.8
23 +++ vcl/unx/source/gdi/salbmp.cxx 2002/11/05 20:13:05
26 BitmapBuffer* SalBitmap::ImplCreateDIB( const Size& rSize, USHORT nBitCount, const BitmapPalette& rPal )
28 - DBG_ASSERT( nBitCount == 1 || nBitCount == 4 || nBitCount == 8 || nBitCount == 24, "Unsupported BitCount!" );
29 + DBG_ASSERT( nBitCount == 1 || nBitCount == 4 || nBitCount == 8 || nBitCount == 24 || nBitCount == 32, "Unsupported BitCount!" );
34 case( 1 ): pDIB->mnFormat |= BMP_FORMAT_1BIT_MSB_PAL; break;
35 case( 4 ): pDIB->mnFormat |= BMP_FORMAT_4BIT_MSN_PAL; break;
36 case( 8 ): pDIB->mnFormat |= BMP_FORMAT_8BIT_PAL; break;
37 + case( 24 ): pDIB->mnFormat |= BMP_FORMAT_24BIT_TC_BGR; break;
40 - pDIB->mnFormat |= BMP_FORMAT_24BIT_TC_BGR;
41 + pDIB->mnFormat |= BMP_FORMAT_32BIT_TC_BGRA;
47 else if( nBitCount <= 8 )
50 + else if ( nBitCount <= 24)
57 Index: svtools/bmpmaker/bmpcore.cxx
58 ===================================================================
59 RCS file: /cvs/util/svtools/bmpmaker/bmpcore.cxx,v
60 retrieving revision 1.12
61 diff -u -p -u -r1.12 bmpcore.cxx
62 --- svtools/bmpmaker/bmpcore.cxx 24 Apr 2003 13:01:46 -0000 1.12
63 +++ svtools/bmpmaker/bmpcore.cxx 26 Sep 2003 10:58:13 -0000
64 @@ -107,7 +107,8 @@ void BmpCreator::ImplCreate( SvStream& r
65 const ::std::vector< DirEntry >& rInDirs,
68 - const LangInfo& rLang )
69 + const LangInfo& rLang,
70 + const Color& rMaskColor)
72 const sal_uInt32 nOldPos = pSRS->Tell();
73 const char* pCollectFile = getenv( "BMP_COLLECT_FILE" );
74 @@ -215,7 +216,7 @@ void BmpCreator::ImplCreate( SvStream& r
75 SvFileStream aIStm( aFileName, STREAM_READ );
80 if( pCollectStm && !aBmp.IsEmpty() )
82 const ByteString aCollectString( aFileName, RTL_TEXTENCODING_ASCII_US );
83 @@ -237,6 +238,26 @@ void BmpCreator::ImplCreate( SvStream& r
87 + if (aBmp.GetBitCount () != 32)
89 + aBmp.Convert (BMP_CONVERSION_32BIT);
91 + BitmapWriteAccess *pUpd = aBmp.AcquireWriteAccess();
93 + for( long nY = 0; nY < aSize.Height(); nY++ ) {
94 + for( long nX = 0; nX < aSize.Width(); nX++ ) {
96 + aCol = pUpd->GetPixel( nY, nX );
97 + if( aCol == rMaskColor )
98 + pUpd->SetAlpha( nY, nX, 0 );
100 + pUpd->SetAlpha( nY, nX, 255 );
104 + aBmp.ReleaseAccess( pUpd );
107 if( aTotalBmp.IsEmpty() )
109 // first bitmap determines metrics of total bitmap
110 @@ -267,6 +286,15 @@ void BmpCreator::ImplCreate( SvStream& r
111 aBmp.Convert( BMP_CONVERSION_24BIT );
113 aTotalBmp.CopyPixel( aDst, aSrc, &aBmp );
115 + BitmapReadAccess *pSrc = aBmp.AcquireWriteAccess();
116 + BitmapWriteAccess *pDst = aTotalBmp.AcquireWriteAccess();
117 + for( long nY = 0; nY < aSize.Height(); nY++ )
118 + for( long nX = 0; nX < aSize.Width(); nX++ )
119 + pDst->SetAlpha( nY, nX + aDst.Left(), pSrc->GetAlpha( nY, nX ) );
120 + aTotalBmp.ReleaseAccess( pDst );
121 + aBmp.ReleaseAccess( pSrc );
123 aValidBmpBitVector[ n ] = true;
126 @@ -335,6 +363,13 @@ void BmpCreator::ImplCreate( SvStream& r
128 // -----------------------------------------------------------------------------
130 +static sal_Int32 GetColorVal( const ByteString &rLine )
132 + ByteString aVal( rLine.GetToken( 1, '=' ) );
133 + aVal.EraseLeadingChars();
134 + return aVal.ToInt32() / 256;
137 void BmpCreator::Create( const String& rSRSName,
138 const ::std::vector< String >& rInDirs,
139 const String& rOutName,
140 @@ -395,6 +430,8 @@ void BmpCreator::Create( const String& r
142 const String aName( aText.GetToken( 1, '"' ) );
149 @@ -405,6 +442,13 @@ void BmpCreator::Create( const String& r
153 + if( aByteText.Search( "Red" ) != STRING_NOTFOUND )
154 + aMaskColor.SetRed( GetColorVal( aByteText ) );
155 + if( aByteText.Search( "Green" ) != STRING_NOTFOUND )
156 + aMaskColor.SetGreen( GetColorVal( aByteText ) );
157 + if( aByteText.Search( "Blue" ) != STRING_NOTFOUND )
158 + aMaskColor.SetBlue( GetColorVal( aByteText ) );
160 if (!pSRS->ReadLine(aByteText))
163 @@ -415,7 +459,7 @@ void BmpCreator::Create( const String& r
167 - ImplCreate( *pSRS, aInDirs, aOutDir, aName, rLang );
168 + ImplCreate( *pSRS, aInDirs, aOutDir, aName, rLang, aMaskColor );
170 else if( ( rLang.mnLangNum != 49 ) && !bLangDep )
173 Index: vcl/source/gdi/bitmap.cxx
174 ===================================================================
175 RCS file: /cvs/gsl/vcl/source/gdi/bitmap.cxx,v
176 retrieving revision 1.7
177 diff -u -p -u -r1.7 bitmap.cxx
178 --- vcl/source/gdi/bitmap.cxx 24 Apr 2003 14:56:22 -0000 1.7
179 +++ vcl/source/gdi/bitmap.cxx 12 Sep 2003 14:18:51 -0000
180 @@ -980,7 +984,9 @@ BOOL Bitmap::CopyPixel( const Rectangle&
182 long nNextIndex = 0L;
184 - if( ( nSrcBitCount == 24 ) && ( nDstBitCount < 24 ) )
185 + if (nSrcBitCount == 32 && nDstBitCount < 32)
186 + Convert (BMP_CONVERSION_32BIT);
187 + else if( ( nSrcBitCount == 24 ) && ( nDstBitCount < 24 ) )
188 Convert( BMP_CONVERSION_24BIT );
189 else if( ( nSrcBitCount == 8 ) && ( nDstBitCount < 8 ) )
191 @@ -1772,20 +1778,58 @@ Bitmap Bitmap::CreateDisplayBitmap( Outp
193 // ------------------------------------------------------------------
195 +static BYTE doSaturate( BYTE c, BYTE i)
197 + int v = 1.2 * c - 0.2 * i;
206 Bitmap Bitmap::GetColorTransformedBitmap( BmpColorMode eColorMode ) const
208 Bitmap aRet( *this );
209 - Color* pSrcColors = NULL;
210 - Color* pDstColors = NULL;
211 - ULONG nColorCount = 0;
213 - Image::GetColorTransformArrays( (ImageColorTransform) eColorMode, pSrcColors, pDstColors, nColorCount );
215 - if( nColorCount && pSrcColors && pDstColors )
216 - aRet.Replace( pSrcColors, pDstColors, nColorCount );
217 + if (eColorMode == BMP_COLOR_HIGHCONTRAST && GetBitCount() >= 24) {
219 - delete[] pSrcColors;
220 - delete[] pDstColors;
221 + // Yet another special case for icons
222 + BitmapReadAccess* pAcc = AcquireReadAccess();
223 + BitmapWriteAccess* pDis = aRet.AcquireWriteAccess();
225 + Size aSize = GetSizePixel();
227 + for( long nY = 0; nY < aSize.Height(); nY++ ) {
228 + for( long nX = 0; nX < aSize.Width(); nX++ ) {
229 + BitmapColor col = pAcc->GetPixel( nY, nX );
230 + BYTE i = ( col.GetRed() * 0.3 + // magic numbers from gdk-pixbuf
231 + col.GetGreen() * 0.59 +
232 + col.GetBlue () * 0.11 );
233 + col.SetRed (doSaturate ( col.GetRed(), i ) );
234 + col.SetGreen (doSaturate ( col.GetGreen(), i ) );
235 + col.SetBlue (doSaturate ( col.GetBlue(), i ) );
236 + pDis->SetPixel( nY, nX, col );
240 + aRet.ReleaseAccess( pDis );
241 + ReleaseAccess( pAcc );
244 + Color* pSrcColors = NULL;
245 + Color* pDstColors = NULL;
246 + ULONG nColorCount = 0;
248 + Image::GetColorTransformArrays( (ImageColorTransform) eColorMode, pSrcColors, pDstColors, nColorCount );
250 + if( nColorCount && pSrcColors && pDstColors )
251 + aRet.Replace( pSrcColors, pDstColors, nColorCount );
253 + delete[] pSrcColors;
254 + delete[] pDstColors;
259 Index: vcl/inc/bitmap.hxx
260 ===================================================================
261 RCS file: /cvs/gsl/vcl/inc/bitmap.hxx,v
262 retrieving revision 1.8
263 diff -u -p -u -r1.8 bitmap.hxx
264 --- vcl/inc/bitmap.hxx 24 Apr 2003 14:56:11 -0000 1.8
265 +++ vcl/inc/bitmap.hxx 13 Sep 2003 10:30:56 -0000
266 @@ -125,7 +125,8 @@ enum BmpConversion
267 BMP_CONVERSION_24BIT = 7,
268 BMP_CONVERSION_4BIT_TRANS = 8,
269 BMP_CONVERSION_8BIT_TRANS = 9,
270 - BMP_CONVERSION_GHOSTED = 10
271 + BMP_CONVERSION_GHOSTED = 10,
272 + BMP_CONVERSION_32BIT = 11
275 // ------------------------------------------------------------------------
276 @@ -389,6 +390,7 @@ public:
277 ULONG GetChecksum() const;
279 Bitmap CreateDisplayBitmap( OutputDevice* pDisplay );
280 + Bitmap GetAlphaMask() const;
281 Bitmap GetColorTransformedBitmap( BmpColorMode eColorMode ) const;
283 static const BitmapPalette& GetGreyPalette( USHORT nEntries );
284 Index: svtools/bmpmaker/bmpcore.hxx
285 ===================================================================
286 RCS file: /cvs/util/svtools/bmpmaker/bmpcore.hxx,v
287 retrieving revision 1.3
288 diff -u -p -u -r1.3 bmpcore.hxx
289 --- svtools/bmpmaker/bmpcore.hxx 30 Oct 2002 16:27:55 -0000 1.3
290 +++ svtools/bmpmaker/bmpcore.hxx 13 Sep 2003 11:10:27 -0000
291 @@ -112,7 +112,8 @@ private:
292 const ::std::vector< DirEntry >& rInDirs,
293 const DirEntry& rOut,
295 - const LangInfo& rLang );
296 + const LangInfo& rLang,
297 + const Color& rMaskColor );
301 Index: vcl/inc/bmpacc.hxx
302 ===================================================================
303 RCS file: /cvs/gsl/vcl/inc/bmpacc.hxx,v
304 retrieving revision 1.3
305 diff -u -p -u -r1.3 bmpacc.hxx
306 --- vcl/inc/bmpacc.hxx 28 Jun 2001 13:08:49 -0000 1.3
307 +++ vcl/inc/bmpacc.hxx 24 Sep 2003 16:36:25 -0000
308 @@ -203,6 +203,7 @@ public:
309 inline BitmapColor GetPixel( long nY, long nX ) const;
310 inline BitmapColor GetColor( long nY, long nX ) const;
311 inline BYTE GetLuminance( long nY, long nX ) const;
312 + inline BYTE GetAlpha( long nY, long nX ) const;
315 // ---------------------
316 @@ -235,6 +236,7 @@ public:
317 inline void SetPaletteColor( USHORT nColor, const BitmapColor& rBitmapColor );
319 inline void SetPixel( long nY, long nX, const BitmapColor& rBitmapColor );
320 + inline void SetAlpha( long nY, long nX, const BYTE nAlpha );
322 inline void SetLineColor( const BitmapColor& rColor );
323 inline const BitmapColor& GetLineColor() const;
324 @@ -455,6 +457,16 @@ inline BYTE BitmapReadAccess::GetLuminan
326 // ------------------------------------------------------------------
328 +inline BYTE BitmapReadAccess::GetAlpha( long nY, long nX ) const
330 + if( maBitmap.GetBitCount() != 32 )
333 + return mpScanBuf[ nY ] [ ( nX << 2 ) + 3 ];
336 +// ------------------------------------------------------------------
338 inline BitmapWriteAccess::BitmapWriteAccess( Bitmap& rBitmap ) :
339 BitmapReadAccess( rBitmap, TRUE ),
340 maLineColor ( 0, 0, 0 ),
341 @@ -541,6 +553,12 @@ inline void BitmapWriteAccess::SetPixel(
342 BMP_ASSERT( nX < mpBuffer->mnWidth, "x-coordinate out of range!" );
343 BMP_ASSERT( nY < mpBuffer->mnHeight, "y-coordinate out of range!" );
344 mFncSetPixel( mpScanBuf[ nY ], nX, rBitmapColor, maColorMask );
347 +inline void BitmapWriteAccess::SetAlpha( long nY, long nX, const BYTE nAlpha )
349 + if( maBitmap.GetBitCount() == 32 )
350 + mpScanBuf[ nY ] [ ( nX << 2 ) + 3 ] = nAlpha;
353 #endif // _SV_BMPACC_HXX
354 Index: vcl/source/gdi/bmpacc2.cxx
355 ===================================================================
356 RCS file: /cvs/gsl/vcl/source/gdi/bmpacc2.cxx,v
357 retrieving revision 1.2
358 diff -u -p -u -r1.2 bmpacc2.cxx
359 --- vcl/source/gdi/bmpacc2.cxx 28 Jun 2001 13:10:36 -0000 1.2
360 +++ vcl/source/gdi/bmpacc2.cxx 24 Sep 2003 16:36:49 -0000
361 @@ -277,7 +278,7 @@ IMPL_FORMAT_GETPIXEL( _32BIT_TC_ABGR )
363 IMPL_FORMAT_SETPIXEL( _32BIT_TC_ABGR )
365 - *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
366 + pScanline += ( nX << 2 ) + 1;
367 *pScanline++ = rBitmapColor.GetBlue();
368 *pScanline++ = rBitmapColor.GetGreen();
369 *pScanline = rBitmapColor.GetRed();
370 @@ -300,7 +302,7 @@ IMPL_FORMAT_GETPIXEL( _32BIT_TC_ARGB )
372 IMPL_FORMAT_SETPIXEL( _32BIT_TC_ARGB )
374 - *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
375 + pScanline = pScanline + ( nX << 2 ) + 1;
376 *pScanline++ = rBitmapColor.GetRed();
377 *pScanline++ = rBitmapColor.GetGreen();
378 *pScanline = rBitmapColor.GetBlue();
379 @@ -326,7 +328,6 @@ IMPL_FORMAT_SETPIXEL( _32BIT_TC_BGRA )
380 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
381 *pScanline++ = rBitmapColor.GetGreen();
382 *pScanline++ = rBitmapColor.GetRed();
386 // ------------------------------------------------------------------
387 @@ -349,7 +350,6 @@ IMPL_FORMAT_SETPIXEL( _32BIT_TC_RGBA )
388 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
389 *pScanline++ = rBitmapColor.GetGreen();
390 *pScanline++ = rBitmapColor.GetBlue();
394 // ------------------------------------------------------------------
395 Index: vcl/source/gdi/bitmap3.cxx
396 ===================================================================
397 RCS file: /cvs/gsl/vcl/source/gdi/bitmap3.cxx,v
398 retrieving revision 1.3
399 diff -u -p -u -r1.3 bitmap3.cxx
400 --- vcl/source/gdi/bitmap3.cxx 27 Aug 2001 12:57:08 -0000 1.3
401 +++ vcl/source/gdi/bitmap3.cxx 24 Sep 2003 16:39:29 -0000
402 @@ -401,6 +401,13 @@ BOOL Bitmap::Convert( BmpConversion eCon
403 bRet = ImplConvertGhosted();
406 + case BMP_CONVERSION_32BIT:
407 + if (nBitCount < 32)
408 + bRet = ImplConvertUp (32, FALSE);
414 DBG_ERROR( "Bitmap::Convert(): Unsupported conversion" );
416 @@ -1074,7 +1081,8 @@ BOOL Bitmap::ImplScaleInterpolate( const
417 BitmapReadAccess* pReadAcc = AcquireReadAccess();
418 long nWidth = pReadAcc->Width();
419 long nHeight = pReadAcc->Height();
420 - Bitmap aNewBmp( Size( nNewWidth, nHeight ), 24 );
421 + Bitmap aNewBmp( Size( nNewWidth, nHeight ),
422 + GetBitCount() == 32 ? 32 : 24 );
423 BitmapWriteAccess* pWriteAcc = aNewBmp.AcquireWriteAccess();
426 @@ -1184,7 +1192,8 @@ BOOL Bitmap::ImplScaleInterpolate( const
428 ImplAssignWithSize( aNewBmp );
429 pReadAcc = AcquireReadAccess();
430 - aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 );
431 + aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ),
432 + GetBitCount() == 32 ? 32 : 24 );
433 pWriteAcc = aNewBmp.AcquireWriteAccess();
435 if( pReadAcc && pWriteAcc )
436 Index: vcl/source/gdi/bitmap2.cxx
437 ===================================================================
438 RCS file: /cvs/gsl/vcl/source/gdi/bitmap2.cxx,v
439 retrieving revision 1.4
440 diff -u -p -u -r1.4 bitmap2.cxx
441 --- vcl/source/gdi/bitmap2.cxx 24 Apr 2003 13:17:58 -0000 1.4
442 +++ vcl/source/gdi/bitmap2.cxx 24 Sep 2003 16:40:07 -0000
443 @@ -204,7 +204,8 @@ BOOL Bitmap::ImplReadDIB( SvStream& rISt
445 USHORT nBitCount = ( aHeader.nBitCount <= 1 ) ? 1 :
446 ( aHeader.nBitCount <= 4 ) ? 4 :
447 - ( aHeader.nBitCount <= 8 ) ? 8 : 24;
448 + ( aHeader.nBitCount <= 8 ) ? 8 :
449 + ( aHeader.nBitCount <= 24 ) ? 24 : 32;
451 const Size aSizePixel( aHeader.nWidth, aHeader.nHeight );
452 BitmapPalette aDummyPal;
453 @@ -640,6 +641,7 @@ BOOL Bitmap::ImplReadDIBBits( SvStream&
454 ColorMask aMask( nRMask, nGMask, nBMask );
459 for( long nY = rHeader.nHeight - 1L; nY >= 0L; nY-- )
461 @@ -647,8 +649,10 @@ BOOL Bitmap::ImplReadDIBBits( SvStream&
463 for( long nX = 0L; nX < nWidth; nX++ )
465 - aMask.GetColorFor32Bit( aColor, (BYTE*) pTmp32++ );
466 + BYTE *pPix = (BYTE *) pTmp32++;
467 + aMask.GetColorFor32Bit( aColor, pPix );
468 rAcc.SetPixel( nY, nX, aColor );
469 + rAcc.SetAlpha( nY, nX, pPix[ 3 ] );
473 @@ -1009,6 +1013,27 @@ BOOL Bitmap::ImplWriteDIBBits( SvStream&
479 + BitmapColor aPixelColor;
481 + for( long nY = nHeight - 1; nY >= 0L; nY-- )
485 + for( long nX = 0L; nX < nWidth; nX++ )
487 + aPixelColor = rAcc.GetPixel( nY, nX );
488 + *pTmp++ = aPixelColor.GetBlue();
489 + *pTmp++ = aPixelColor.GetGreen();
490 + *pTmp++ = aPixelColor.GetRed();
493 + rOStm.Write( pBuf, nAlignedWidth );
500 BitmapColor aPixelColor;
501 @@ -1023,6 +1048,7 @@ BOOL Bitmap::ImplWriteDIBBits( SvStream&
502 *pTmp++ = aPixelColor.GetBlue();
503 *pTmp++ = aPixelColor.GetGreen();
504 *pTmp++ = aPixelColor.GetRed();
505 + *pTmp++ = rAcc.GetAlpha( nY, nX );
508 rOStm.Write( pBuf, nAlignedWidth );
509 @@ -1038,6 +1064,38 @@ BOOL Bitmap::ImplWriteDIBBits( SvStream&
510 rImageSize = rOStm.Tell() - rImageSize;
512 return( rOStm.GetError() == 0UL );
515 +// ------------------------------------------------------------------
518 +Bitmap::GetAlphaMask() const
520 + if( GetBitCount() < 32 )
523 + Size aSize = GetSizePixel();
524 + Bitmap aAlpha( aSize, 8, &GetGreyPalette( 256 ) );
526 + aAlpha.Erase( COL_WHITE );
528 + BitmapReadAccess *pSrc = AcquireReadAccess();
529 + BitmapWriteAccess *pDst = aAlpha.AcquireWriteAccess();
531 + for( long nY = 0; nY < aSize.Height(); nY++ )
533 + for( long nX = 0; nX < aSize.Width(); nX++ )
536 + aCol = pSrc->GetPixel( nY, nX );
537 + pDst->SetPixel( nY, nX, BitmapColor( 255 - pSrc->GetAlpha( nY, nX ) ) );
541 + ReleaseAccess( pSrc );
542 + ReleaseAccess( pDst );
547 // ------------------------------------------------------------------