]>
Commit | Line | Data |
---|---|---|
efef92ce | 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 | |
8 | @@ -177,7 +177,7 @@ | |
9 | #endif | |
10 | nBitCount = mpSalBitmap->GetBitCount(); | |
11 | ||
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 ); | |
14 | } | |
15 | ||
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 | |
24 | @@ -150,7 +150,7 @@ | |
25 | ||
26 | BitmapBuffer* SalBitmap::ImplCreateDIB( const Size& rSize, USHORT nBitCount, const BitmapPalette& rPal ) | |
27 | { | |
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!" ); | |
30 | ||
31 | BitmapBuffer* pDIB; | |
32 | ||
33 | @@ -169,9 +169,10 @@ | |
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; | |
38 | ||
39 | default: | |
40 | - pDIB->mnFormat |= BMP_FORMAT_24BIT_TC_BGR; | |
41 | + pDIB->mnFormat |= BMP_FORMAT_32BIT_TC_BGRA; | |
42 | break; | |
43 | } | |
44 | ||
45 | @@ -802,8 +803,10 @@ | |
46 | nBitCount = 4; | |
47 | else if( nBitCount <= 8 ) | |
48 | nBitCount = 8; | |
49 | - else | |
50 | + else if ( nBitCount <= 24) | |
51 | nBitCount = 24; | |
52 | + else | |
53 | + nBitCount = 32; | |
54 | } | |
55 | } | |
56 | else | |
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, | |
66 | const DirEntry& rOut, | |
67 | const String& rName, | |
68 | - const LangInfo& rLang ) | |
69 | + const LangInfo& rLang, | |
70 | + const Color& rMaskColor) | |
71 | { | |
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 ); | |
76 | aIStm >> aBmp; | |
77 | aIStm.Close(); | |
78 | - | |
79 | + | |
80 | if( pCollectStm && !aBmp.IsEmpty() ) | |
81 | { | |
82 | const ByteString aCollectString( aFileName, RTL_TEXTENCODING_ASCII_US ); | |
83 | @@ -237,6 +238,26 @@ void BmpCreator::ImplCreate( SvStream& r | |
84 | } | |
85 | else | |
86 | { | |
87 | + if (aBmp.GetBitCount () != 32) | |
88 | + { | |
89 | + aBmp.Convert (BMP_CONVERSION_32BIT); | |
90 | + | |
91 | + BitmapWriteAccess *pUpd = aBmp.AcquireWriteAccess(); | |
92 | + | |
93 | + for( long nY = 0; nY < aSize.Height(); nY++ ) { | |
94 | + for( long nX = 0; nX < aSize.Width(); nX++ ) { | |
95 | + BitmapColor aCol; | |
96 | + aCol = pUpd->GetPixel( nY, nX ); | |
97 | + if( aCol == rMaskColor ) | |
98 | + pUpd->SetAlpha( nY, nX, 0 ); | |
99 | + else | |
100 | + pUpd->SetAlpha( nY, nX, 255 ); | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + aBmp.ReleaseAccess( pUpd ); | |
105 | + } | |
106 | + | |
107 | if( aTotalBmp.IsEmpty() ) | |
108 | { | |
109 | // first bitmap determines metrics of total bitmap | |
110 | @@ -267,6 +286,15 @@ void BmpCreator::ImplCreate( SvStream& r | |
111 | aBmp.Convert( BMP_CONVERSION_24BIT ); | |
112 | ||
113 | aTotalBmp.CopyPixel( aDst, aSrc, &aBmp ); | |
114 | + | |
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 ); | |
122 | + | |
123 | aValidBmpBitVector[ n ] = true; | |
124 | } | |
125 | } | |
126 | @@ -335,6 +363,13 @@ void BmpCreator::ImplCreate( SvStream& r | |
127 | ||
128 | // ----------------------------------------------------------------------------- | |
129 | ||
130 | +static sal_Int32 GetColorVal( const ByteString &rLine ) | |
131 | +{ | |
132 | + ByteString aVal( rLine.GetToken( 1, '=' ) ); | |
133 | + aVal.EraseLeadingChars(); | |
134 | + return aVal.ToInt32() / 256; | |
135 | +} | |
136 | + | |
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 | |
141 | ||
142 | const String aName( aText.GetToken( 1, '"' ) ); | |
143 | ||
144 | + Color aMaskColor; | |
145 | + | |
146 | do | |
147 | { | |
148 | if( !bLangDep && | |
149 | @@ -405,6 +442,13 @@ void BmpCreator::Create( const String& r | |
150 | bLangDep = TRUE; | |
151 | } | |
152 | ||
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 ) ); | |
159 | + | |
160 | if (!pSRS->ReadLine(aByteText)) | |
161 | break; | |
162 | } | |
163 | @@ -415,7 +459,7 @@ void BmpCreator::Create( const String& r | |
164 | if( aText.Len() ) | |
165 | { | |
166 | bDone = TRUE; | |
167 | - ImplCreate( *pSRS, aInDirs, aOutDir, aName, rLang ); | |
168 | + ImplCreate( *pSRS, aInDirs, aOutDir, aName, rLang, aMaskColor ); | |
169 | } | |
170 | else if( ( rLang.mnLangNum != 49 ) && !bLangDep ) | |
171 | { | |
172 | ||
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& | |
181 | { | |
182 | long nNextIndex = 0L; | |
183 | ||
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 ) ) | |
190 | { | |
191 | @@ -1772,20 +1778,58 @@ Bitmap Bitmap::CreateDisplayBitmap( Outp | |
192 | ||
193 | // ------------------------------------------------------------------ | |
194 | ||
195 | +static BYTE doSaturate( BYTE c, BYTE i) | |
196 | +{ | |
197 | + int v = 1.2 * c - 0.2 * i; | |
198 | + if( v < 0 ) | |
199 | + return 0; | |
200 | + else if( v > 255 ) | |
201 | + return 255; | |
202 | + else | |
203 | + return v; | |
204 | +} | |
205 | + | |
206 | Bitmap Bitmap::GetColorTransformedBitmap( BmpColorMode eColorMode ) const | |
207 | { | |
208 | Bitmap aRet( *this ); | |
209 | - Color* pSrcColors = NULL; | |
210 | - Color* pDstColors = NULL; | |
211 | - ULONG nColorCount = 0; | |
212 | - | |
213 | - Image::GetColorTransformArrays( (ImageColorTransform) eColorMode, pSrcColors, pDstColors, nColorCount ); | |
214 | ||
215 | - if( nColorCount && pSrcColors && pDstColors ) | |
216 | - aRet.Replace( pSrcColors, pDstColors, nColorCount ); | |
217 | + if (eColorMode == BMP_COLOR_HIGHCONTRAST && GetBitCount() >= 24) { | |
218 | ||
219 | - delete[] pSrcColors; | |
220 | - delete[] pDstColors; | |
221 | + // Yet another special case for icons | |
222 | + BitmapReadAccess* pAcc = AcquireReadAccess(); | |
223 | + BitmapWriteAccess* pDis = aRet.AcquireWriteAccess(); | |
224 | + | |
225 | + Size aSize = GetSizePixel(); | |
226 | + | |
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 ); | |
237 | + } | |
238 | + } | |
239 | + | |
240 | + aRet.ReleaseAccess( pDis ); | |
241 | + ReleaseAccess( pAcc ); | |
242 | + } else { | |
243 | + | |
244 | + Color* pSrcColors = NULL; | |
245 | + Color* pDstColors = NULL; | |
246 | + ULONG nColorCount = 0; | |
247 | + | |
248 | + Image::GetColorTransformArrays( (ImageColorTransform) eColorMode, pSrcColors, pDstColors, nColorCount ); | |
249 | + | |
250 | + if( nColorCount && pSrcColors && pDstColors ) | |
251 | + aRet.Replace( pSrcColors, pDstColors, nColorCount ); | |
252 | + | |
253 | + delete[] pSrcColors; | |
254 | + delete[] pDstColors; | |
255 | + } | |
256 | ||
257 | return aRet; | |
258 | } | |
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 | |
273 | }; | |
274 | ||
275 | // ------------------------------------------------------------------------ | |
276 | @@ -389,6 +390,7 @@ public: | |
277 | ULONG GetChecksum() const; | |
278 | ||
279 | Bitmap CreateDisplayBitmap( OutputDevice* pDisplay ); | |
280 | + Bitmap GetAlphaMask() const; | |
281 | Bitmap GetColorTransformedBitmap( BmpColorMode eColorMode ) const; | |
282 | ||
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, | |
294 | const String& rName, | |
295 | - const LangInfo& rLang ); | |
296 | + const LangInfo& rLang, | |
297 | + const Color& rMaskColor ); | |
298 | ||
299 | protected: | |
300 | ||
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; | |
313 | }; | |
314 | ||
315 | // --------------------- | |
316 | @@ -235,6 +236,7 @@ public: | |
317 | inline void SetPaletteColor( USHORT nColor, const BitmapColor& rBitmapColor ); | |
318 | ||
319 | inline void SetPixel( long nY, long nX, const BitmapColor& rBitmapColor ); | |
320 | + inline void SetAlpha( long nY, long nX, const BYTE nAlpha ); | |
321 | ||
322 | inline void SetLineColor( const BitmapColor& rColor ); | |
323 | inline const BitmapColor& GetLineColor() const; | |
324 | @@ -455,6 +457,16 @@ inline BYTE BitmapReadAccess::GetLuminan | |
325 | ||
326 | // ------------------------------------------------------------------ | |
327 | ||
328 | +inline BYTE BitmapReadAccess::GetAlpha( long nY, long nX ) const | |
329 | +{ | |
330 | + if( maBitmap.GetBitCount() != 32 ) | |
331 | + return 255; | |
332 | + else | |
333 | + return mpScanBuf[ nY ] [ ( nX << 2 ) + 3 ]; | |
334 | +} | |
335 | + | |
336 | +// ------------------------------------------------------------------ | |
337 | + | |
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 ); | |
345 | +} | |
346 | + | |
347 | +inline void BitmapWriteAccess::SetAlpha( long nY, long nX, const BYTE nAlpha ) | |
348 | +{ | |
349 | + if( maBitmap.GetBitCount() == 32 ) | |
350 | + mpScanBuf[ nY ] [ ( nX << 2 ) + 3 ] = nAlpha; | |
351 | } | |
352 | ||
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 ) | |
362 | ||
363 | IMPL_FORMAT_SETPIXEL( _32BIT_TC_ABGR ) | |
364 | { | |
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 ) | |
371 | ||
372 | IMPL_FORMAT_SETPIXEL( _32BIT_TC_ARGB ) | |
373 | { | |
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(); | |
383 | - *pScanline = 0; | |
384 | } | |
385 | ||
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(); | |
391 | - *pScanline = 0; | |
392 | } | |
393 | ||
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(); | |
404 | break; | |
405 | ||
406 | + case BMP_CONVERSION_32BIT: | |
407 | + if (nBitCount < 32) | |
408 | + bRet = ImplConvertUp (32, FALSE); | |
409 | + else | |
410 | + bRet = TRUE; | |
411 | + break; | |
412 | + | |
413 | default: | |
414 | DBG_ERROR( "Bitmap::Convert(): Unsupported conversion" ); | |
415 | break; | |
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(); | |
424 | long* pLutInt; | |
425 | long* pLutFrac; | |
426 | @@ -1184,7 +1192,8 @@ BOOL Bitmap::ImplScaleInterpolate( const | |
427 | bRet = FALSE; | |
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(); | |
434 | ||
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 | |
444 | { | |
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; | |
450 | ||
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 ); | |
455 | BitmapColor aColor; | |
456 | UINT32* pTmp32; | |
457 | + UINT32 nCol; | |
458 | ||
459 | for( long nY = rHeader.nHeight - 1L; nY >= 0L; nY-- ) | |
460 | { | |
461 | @@ -647,8 +649,10 @@ BOOL Bitmap::ImplReadDIBBits( SvStream& | |
462 | ||
463 | for( long nX = 0L; nX < nWidth; nX++ ) | |
464 | { | |
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 ] ); | |
470 | } | |
471 | } | |
472 | } | |
473 | @@ -1009,6 +1013,27 @@ BOOL Bitmap::ImplWriteDIBBits( SvStream& | |
474 | } | |
475 | break; | |
476 | ||
477 | + case 24: | |
478 | + { | |
479 | + BitmapColor aPixelColor; | |
480 | + | |
481 | + for( long nY = nHeight - 1; nY >= 0L; nY-- ) | |
482 | + { | |
483 | + pTmp = pBuf; | |
484 | + | |
485 | + for( long nX = 0L; nX < nWidth; nX++ ) | |
486 | + { | |
487 | + aPixelColor = rAcc.GetPixel( nY, nX ); | |
488 | + *pTmp++ = aPixelColor.GetBlue(); | |
489 | + *pTmp++ = aPixelColor.GetGreen(); | |
490 | + *pTmp++ = aPixelColor.GetRed(); | |
491 | + } | |
492 | + | |
493 | + rOStm.Write( pBuf, nAlignedWidth ); | |
494 | + } | |
495 | + } | |
496 | + break; | |
497 | + | |
498 | default: | |
499 | { | |
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 ); | |
506 | } | |
507 | ||
508 | rOStm.Write( pBuf, nAlignedWidth ); | |
509 | @@ -1038,6 +1064,38 @@ BOOL Bitmap::ImplWriteDIBBits( SvStream& | |
510 | rImageSize = rOStm.Tell() - rImageSize; | |
511 | ||
512 | return( rOStm.GetError() == 0UL ); | |
513 | +} | |
514 | + | |
515 | +// ------------------------------------------------------------------ | |
516 | + | |
517 | +Bitmap | |
518 | +Bitmap::GetAlphaMask() const | |
519 | +{ | |
520 | + if( GetBitCount() < 32 ) | |
521 | + return Bitmap(); | |
522 | + | |
523 | + Size aSize = GetSizePixel(); | |
524 | + Bitmap aAlpha( aSize, 8, &GetGreyPalette( 256 ) ); | |
525 | + | |
526 | + aAlpha.Erase( COL_WHITE ); | |
527 | + | |
528 | + BitmapReadAccess *pSrc = AcquireReadAccess(); | |
529 | + BitmapWriteAccess *pDst = aAlpha.AcquireWriteAccess(); | |
530 | + | |
531 | + for( long nY = 0; nY < aSize.Height(); nY++ ) | |
532 | + { | |
533 | + for( long nX = 0; nX < aSize.Width(); nX++ ) | |
534 | + { | |
535 | + BitmapColor aCol; | |
536 | + aCol = pSrc->GetPixel( nY, nX ); | |
537 | + pDst->SetPixel( nY, nX, BitmapColor( 255 - pSrc->GetAlpha( nY, nX ) ) ); | |
538 | + } | |
539 | + } | |
540 | + | |
541 | + ReleaseAccess( pSrc ); | |
542 | + ReleaseAccess( pDst ); | |
543 | + | |
544 | + return aAlpha; | |
545 | } | |
546 | ||
547 | // ------------------------------------------------------------------ |