equal
deleted
inserted
replaced
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // CMaskedBitmap::CopyBitmap |
33 // CMaskedBitmap::CopyBitmap |
34 // ----------------------------------------------------------------------------- |
34 // ----------------------------------------------------------------------------- |
35 TInt BitmapUtil::CopyBitmap( const CFbsBitmap& aSource, CFbsBitmap& aDestination ) |
35 TInt BitmapUtil::CopyBitmap( const CFbsBitmap& aSource, CFbsBitmap& aDestination ) |
36 { |
36 { |
37 // TODO - how to check if source or destination is null reference |
|
38 TSize size( aSource.SizeInPixels() ); |
37 TSize size( aSource.SizeInPixels() ); |
39 TDisplayMode displayMode( aSource.DisplayMode() ); |
38 TDisplayMode displayMode( aSource.DisplayMode() ); |
40 TInt err( aDestination.Create( size, displayMode ) ); |
39 TInt err( aDestination.Create( size, displayMode ) ); |
41 if( !err ) |
40 if( !err ) |
42 { |
41 { |
53 // CMaskedBitmap::CopyBitmapData |
52 // CMaskedBitmap::CopyBitmapData |
54 // ----------------------------------------------------------------------------- |
53 // ----------------------------------------------------------------------------- |
55 TInt BitmapUtil::CopyBitmapData( const CFbsBitmap& aSource, CFbsBitmap& aDestination, |
54 TInt BitmapUtil::CopyBitmapData( const CFbsBitmap& aSource, CFbsBitmap& aDestination, |
56 const TSize& aSize, const TDisplayMode& aDisplayMode ) |
55 const TSize& aSize, const TDisplayMode& aDisplayMode ) |
57 { |
56 { |
58 // TODO - how to check if source or destination is null reference |
|
59 HBufC8* scanLine = HBufC8::New( aSource.ScanLineLength( aSize.iWidth, aDisplayMode ) ); |
57 HBufC8* scanLine = HBufC8::New( aSource.ScanLineLength( aSize.iWidth, aDisplayMode ) ); |
60 if( scanLine ) |
58 if( scanLine ) |
61 { |
59 { |
62 TPtr8 scanPtr( scanLine->Des() ); |
60 TPtr8 scanPtr( scanLine->Des() ); |
63 TPoint pp; |
61 TPoint pp; |
215 { |
213 { |
216 err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap ); |
214 err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap ); |
217 } |
215 } |
218 } |
216 } |
219 |
217 |
220 if( !err && maskHandle && iMask) |
218 if( !err && maskHandle ) |
221 { |
219 { |
222 if( aDuplicate ) |
220 if( aDuplicate ) |
223 { |
221 { |
224 err = iMask->Duplicate( maskHandle ); |
222 err = iMask->Duplicate( maskHandle ); |
225 } |
223 } |
247 // CMaskedBitmap::Reset |
245 // CMaskedBitmap::Reset |
248 // ----------------------------------------------------------------------------- |
246 // ----------------------------------------------------------------------------- |
249 void CMaskedBitmap::Reset() |
247 void CMaskedBitmap::Reset() |
250 { |
248 { |
251 iBitmap->Reset(); |
249 iBitmap->Reset(); |
252 if(iMask) iMask->Reset(); |
250 iMask->Reset(); |
253 } |
251 } |
254 |
252 |
255 |
253 |
256 // ----------------------------------------------------------------------------- |
254 // ----------------------------------------------------------------------------- |
257 // CMaskedBitmap::IsCreated |
255 // CMaskedBitmap::IsCreated |
272 // ----------------------------------------------------------------------------- |
270 // ----------------------------------------------------------------------------- |
273 // CMaskedBitmap::HasMask |
271 // CMaskedBitmap::HasMask |
274 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
275 TBool CMaskedBitmap::HasMask() const |
273 TBool CMaskedBitmap::HasMask() const |
276 { |
274 { |
277 return (iMask && iMask->Handle()!=0 ); |
275 return ( iMask->Handle() != 0 ); |
278 } |
276 } |
279 |
277 |
280 // ----------------------------------------------------------------------------- |
278 // ----------------------------------------------------------------------------- |
281 // CMaskedBitmap::Mask |
279 // CMaskedBitmap::Mask |
282 // ----------------------------------------------------------------------------- |
280 // ----------------------------------------------------------------------------- |
295 { |
293 { |
296 return; |
294 return; |
297 } |
295 } |
298 if( iBitmap->Handle() ) |
296 if( iBitmap->Handle() ) |
299 { |
297 { |
300 if( HasMask() ) |
298 if( iMask->Handle() ) |
301 { |
299 { |
302 aContext.BitBltMasked( aPoint, iBitmap, s, iMask, iInvertMask ); |
300 aContext.BitBltMasked( aPoint, iBitmap, s, iMask, iInvertMask ); |
303 } |
301 } |
304 else |
302 else |
305 { |
303 { |
317 { |
315 { |
318 return; |
316 return; |
319 } |
317 } |
320 if( iBitmap->Handle() ) |
318 if( iBitmap->Handle() ) |
321 { |
319 { |
322 if( HasMask() ) |
320 if( iMask->Handle() ) |
323 { |
321 { |
324 |
322 |
325 aContext.BitBltMasked( aPoint, iBitmap, aSource, iMask, iInvertMask ); |
323 aContext.BitBltMasked( aPoint, iBitmap, aSource, iMask, iInvertMask ); |
326 } |
324 } |
327 else |
325 else |
342 return; |
340 return; |
343 } |
341 } |
344 if( iBitmap->Handle() ) |
342 if( iBitmap->Handle() ) |
345 { |
343 { |
346 // ### FIXME DrawBitmapMasked is too buggy to use 2.8/week52, so no transparency with scaling |
344 // ### FIXME DrawBitmapMasked is too buggy to use 2.8/week52, so no transparency with scaling |
347 if( HasMask() ) |
345 if( iMask->Handle() ) |
348 { |
346 { |
349 aContext.DrawBitmapMasked( aTarget, iBitmap, s, iMask, iInvertMask ); |
347 aContext.DrawBitmapMasked( aTarget, iBitmap, s, iMask, iInvertMask ); |
350 } |
348 } |
351 else |
349 else |
352 { |
350 { |
365 return; |
363 return; |
366 } |
364 } |
367 if( iBitmap->Handle() ) |
365 if( iBitmap->Handle() ) |
368 { |
366 { |
369 // ### FIXME DrawBitmapMasked is too buggy to use 2.8/week52, so no transparency with scaling |
367 // ### FIXME DrawBitmapMasked is too buggy to use 2.8/week52, so no transparency with scaling |
370 if( HasMask() ) |
368 if( iMask->Handle() ) |
371 { |
369 { |
372 aContext.DrawBitmapMasked( aTarget, iBitmap, aSource, iMask, iInvertMask ); |
370 aContext.DrawBitmapMasked( aTarget, iBitmap, aSource, iMask, iInvertMask ); |
373 } |
371 } |
374 else |
372 else |
375 { |
373 { |
441 // CMaskedBitmap::Resize |
439 // CMaskedBitmap::Resize |
442 // ----------------------------------------------------------------------------- |
440 // ----------------------------------------------------------------------------- |
443 void CMaskedBitmap::Resize(TSize aSize) |
441 void CMaskedBitmap::Resize(TSize aSize) |
444 { |
442 { |
445 iBitmap->Resize(aSize); |
443 iBitmap->Resize(aSize); |
446 if (HasMask()) |
444 if (iMask) |
|
445 { |
447 iMask->Resize(aSize); |
446 iMask->Resize(aSize); |
|
447 } |
448 } |
448 } |
449 |
449 |
450 // ----------------------------------------------------------------------------- |
450 // ----------------------------------------------------------------------------- |
451 // CMaskedBitmap::TileInBitmapRect |
451 // CMaskedBitmap::TileInBitmapRect |
452 // ----------------------------------------------------------------------------- |
452 // ----------------------------------------------------------------------------- |
587 } |
587 } |
588 |
588 |
589 |
589 |
590 TBool CMaskedBitmap::IsFullyTransparent() |
590 TBool CMaskedBitmap::IsFullyTransparent() |
591 { |
591 { |
592 if (!HasMask()) |
592 if (!iMask || !iMask->Handle()) |
|
593 { |
593 return EFalse; |
594 return EFalse; |
|
595 } |
594 |
596 |
595 if( iMask->DisplayMode() != EGray2 ) |
597 if( iMask->DisplayMode() != EGray2 ) |
596 { |
598 { |
597 return EFalse; // fully transparent png? rare, dont bother |
599 return EFalse; // fully transparent png? rare, dont bother |
598 } |
600 } |
626 { |
628 { |
627 |
629 |
628 if ( iBitmap && iBitmap->Handle() ) |
630 if ( iBitmap && iBitmap->Handle() ) |
629 iBitmap->CompressInBackground(); |
631 iBitmap->CompressInBackground(); |
630 |
632 |
631 if ( HasMask() ) |
633 if ( iMask && iMask->Handle() ) |
632 iMask->CompressInBackground(); |
634 iMask->CompressInBackground(); |
633 |
635 |
634 } |
636 } |
635 |
637 |
636 CMaskedBitmap* CMaskedBitmap::ScaleImageToSize( TSize newSize ) |
638 CMaskedBitmap* CMaskedBitmap::ScaleImageToSize( TSize newSize ) |