equal
deleted
inserted
replaced
81 { |
81 { |
82 } |
82 } |
83 |
83 |
84 |
84 |
85 CMaskedBitmap::CMaskedBitmap(CFbsBitmap* aBitmap, CFbsBitmap* aMask) |
85 CMaskedBitmap::CMaskedBitmap(CFbsBitmap* aBitmap, CFbsBitmap* aMask) |
86 : iBitmap(aBitmap),iMask(aMask) |
86 : iBitmap(aBitmap),iMask(aMask),i_DecodingCompleted(ETrue) |
87 { |
87 { |
88 } |
88 } |
89 |
89 |
90 // ---------------------------------------------------------------------------- |
90 // ---------------------------------------------------------------------------- |
91 // |
91 // |
184 else |
184 else |
185 { |
185 { |
186 err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap ); |
186 err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap ); |
187 } |
187 } |
188 } |
188 } |
|
189 if(!err) |
|
190 SetInitialisationCompletionStatus(ETrue); |
189 return err; |
191 return err; |
190 } |
192 } |
191 |
193 |
192 // ----------------------------------------------------------------------------- |
194 // ----------------------------------------------------------------------------- |
193 // CMaskedBitmap::Copy |
195 // CMaskedBitmap::Copy |
230 if( err ) |
232 if( err ) |
231 { |
233 { |
232 iBitmap->Reset(); |
234 iBitmap->Reset(); |
233 } |
235 } |
234 } |
236 } |
|
237 if(!err) |
|
238 SetInitialisationCompletionStatus(ETrue); |
235 return err; |
239 return err; |
236 } |
240 } |
237 |
241 |
238 // ----------------------------------------------------------------------------- |
242 // ----------------------------------------------------------------------------- |
239 // CMaskedBitmap::Copy |
243 // CMaskedBitmap::Copy |
248 // ----------------------------------------------------------------------------- |
252 // ----------------------------------------------------------------------------- |
249 void CMaskedBitmap::Reset() |
253 void CMaskedBitmap::Reset() |
250 { |
254 { |
251 iBitmap->Reset(); |
255 iBitmap->Reset(); |
252 if(iMask) iMask->Reset(); |
256 if(iMask) iMask->Reset(); |
|
257 SetInitialisationCompletionStatus(EFalse); |
253 } |
258 } |
254 |
259 |
255 |
260 |
256 // ----------------------------------------------------------------------------- |
261 // ----------------------------------------------------------------------------- |
257 // CMaskedBitmap::IsCreated |
262 // CMaskedBitmap::IsCreated |
485 } |
490 } |
486 |
491 |
487 void CMaskedBitmap::TileInBitmapRect( CFbsBitmap* trgBmp, const TRect& aTrgRect, const TPoint& aOffset ) |
492 void CMaskedBitmap::TileInBitmapRect( CFbsBitmap* trgBmp, const TRect& aTrgRect, const TPoint& aOffset ) |
488 { |
493 { |
489 trgBmp->LockHeap(); |
494 trgBmp->LockHeap(); |
490 |
495 |
|
496 if ( aTrgRect.Width() < 0 || aTrgRect.Height() < 0 ) |
|
497 { |
|
498 trgBmp->UnlockHeap(); |
|
499 return; |
|
500 } |
491 TSize sz = trgBmp->SizeInPixels(); |
501 TSize sz = trgBmp->SizeInPixels(); |
492 TUint32* buf = (TUint32*)(trgBmp->DataAddress()); |
502 TUint32* buf = (TUint32*)(trgBmp->DataAddress()); |
493 |
503 |
494 // bitmap with 32-bit depth doesn't need padding for a scanline. |
504 // bitmap with 32-bit depth doesn't need padding for a scanline. |
495 TInt padding = trgBmp->DisplayMode() == EColor16MU ? 0 : (sz.iWidth & 1); |
505 TInt padding = trgBmp->DisplayMode() == EColor16MU ? 0 : (sz.iWidth & 1); |
632 if ( HasMask() ) |
642 if ( HasMask() ) |
633 iMask->CompressInBackground(); |
643 iMask->CompressInBackground(); |
634 |
644 |
635 } |
645 } |
636 |
646 |
637 CMaskedBitmap* CMaskedBitmap::ScaleImageToSize( TSize newSize ) |
647 CMaskedBitmap* CMaskedBitmap::ScaleImageToSize( TSize newSize, bool storeScaledImage) |
638 { |
648 { |
639 if (iScaledBitmap && iScaledBitmap->SizeInPixels() == newSize) |
649 |
|
650 if (storeScaledImage && iScaledBitmap && iScaledBitmap->SizeInPixels() == newSize) |
640 return iScaledBitmap; |
651 return iScaledBitmap; |
641 |
652 |
642 delete iScaledBitmap; |
653 CMaskedBitmap* scaledBitmap = CMaskedBitmap::NewL(); |
643 iScaledBitmap = NULL; |
654 |
644 iScaledBitmap = CMaskedBitmap::NewL(); |
655 CFbsBitmap& bmp = scaledBitmap->BitmapModifyable(); |
645 |
|
646 CFbsBitmap& bmp = iScaledBitmap->BitmapModifyable(); |
|
647 bmp.Create(newSize, iBitmap->DisplayMode()); |
656 bmp.Create(newSize, iBitmap->DisplayMode()); |
648 |
657 |
649 // scale the image quickly |
658 // scale the image quickly |
650 CFbsBitGc* bitGc; |
659 CFbsBitGc* bitGc; |
651 CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &bmp ); |
660 CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &bmp ); |
653 User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); |
662 User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); |
654 CleanupStack::PushL( bitGc ); |
663 CleanupStack::PushL( bitGc ); |
655 bitGc->DrawBitmap(TRect(TPoint(0,0), newSize), iBitmap, iBitmap->SizeInPixels()); |
664 bitGc->DrawBitmap(TRect(TPoint(0,0), newSize), iBitmap, iBitmap->SizeInPixels()); |
656 CleanupStack::PopAndDestroy(2); |
665 CleanupStack::PopAndDestroy(2); |
657 |
666 |
658 CFbsBitmap& msk = iScaledBitmap->MaskModifyable(); |
667 CFbsBitmap& msk = scaledBitmap->MaskModifyable(); |
659 if( HasMask() ) { |
668 if( HasMask() ) { |
660 msk.Create(newSize, iMask->DisplayMode()); |
669 msk.Create(newSize, iMask->DisplayMode()); |
661 |
670 |
662 // scale the image quickly |
671 // scale the image quickly |
663 CFbsBitGc* bitGc; |
672 CFbsBitGc* bitGc; |
666 User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); |
675 User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); |
667 CleanupStack::PushL( bitGc ); |
676 CleanupStack::PushL( bitGc ); |
668 bitGc->DrawBitmap(TRect(TPoint(0,0), newSize), iMask, iMask->SizeInPixels()); |
677 bitGc->DrawBitmap(TRect(TPoint(0,0), newSize), iMask, iMask->SizeInPixels()); |
669 CleanupStack::PopAndDestroy(2); |
678 CleanupStack::PopAndDestroy(2); |
670 } |
679 } |
671 |
680 if (storeScaledImage) { |
672 return iScaledBitmap; |
681 delete iScaledBitmap; |
|
682 iScaledBitmap = NULL; |
|
683 iScaledBitmap = scaledBitmap; |
|
684 } |
|
685 return scaledBitmap; |
673 } |
686 } |
674 |
687 |
|
688 void CMaskedBitmap::SetInitialisationCompletionStatus(TBool aDecodingCompleted) |
|
689 { |
|
690 i_DecodingCompleted = aDecodingCompleted; |
|
691 } |
|
692 |
|
693 |
|
694 TBool CMaskedBitmap::IsCompletlyInitialised() |
|
695 { |
|
696 return i_DecodingCompleted; |
|
697 } |
|
698 |
|
699 |
675 // End of File |
700 // End of File |