|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CMIDBitmapImage.h" |
|
20 #include "LcdFbsImage.h" |
|
21 |
|
22 CMIDBitmapImage::CMIDBitmapImage(CLcdFbsImage& aImageRep) |
|
23 : iImageRep(aImageRep) |
|
24 , iRefCount(0) |
|
25 { |
|
26 iImageRep.AddRef(); |
|
27 } |
|
28 |
|
29 CMIDBitmapImage::~CMIDBitmapImage() |
|
30 { |
|
31 iImageRep.RemoveRef(); |
|
32 } |
|
33 |
|
34 void CMIDBitmapImage::AddRef() |
|
35 { |
|
36 ++iRefCount; |
|
37 } |
|
38 |
|
39 void CMIDBitmapImage::RemoveRef() |
|
40 { |
|
41 if (--iRefCount == 0) |
|
42 { |
|
43 delete this; |
|
44 } |
|
45 } |
|
46 |
|
47 CFbsBitmap* CMIDBitmapImage::ColorBitmap() const |
|
48 { |
|
49 return iImageRep.ColorBitmap(); |
|
50 } |
|
51 |
|
52 CFbsBitmap* CMIDBitmapImage::AlphaBitmap() const |
|
53 { |
|
54 return iImageRep.AlphaBitmap(); |
|
55 } |
|
56 |
|
57 CFbsBitmap* CMIDBitmapImage::CreateColorBitmapL(TDisplayMode aMode) const |
|
58 { |
|
59 return CLcdFbsImage::CopyBitmapL(iImageRep.ColorBitmap(), aMode, EFalse); |
|
60 } |
|
61 |
|
62 CFbsBitmap* CMIDBitmapImage::CreateAlphaBitmapL(TDisplayMode aMode, TBool aInvert) const |
|
63 { |
|
64 CFbsBitmap* alphaBitmap = iImageRep.AlphaBitmap(); |
|
65 if (!alphaBitmap) |
|
66 { |
|
67 return NULL; |
|
68 } |
|
69 return CLcdFbsImage::CopyBitmapL(alphaBitmap, aMode, aInvert); |
|
70 } |
|
71 |
|
72 /** |
|
73 * Create a duplicate bitmap of the color bitmap. The duplicate |
|
74 * bitmap will refer to the same pixel data. |
|
75 * Caller takes ownership. |
|
76 */ |
|
77 CFbsBitmap* CMIDBitmapImage::DuplicateColorBitmapL() const |
|
78 { |
|
79 return CLcdFbsImage::DuplicateBitmapL(iImageRep.ColorBitmap()); |
|
80 } |
|
81 |
|
82 /** |
|
83 * Create a duplicate bitmap of the alpha bitmap. The duplicate |
|
84 * bitmap will refer to the same pixel data. |
|
85 * Caller takes ownership. |
|
86 * May return NULL if no alpha bitmap is present. |
|
87 */ |
|
88 CFbsBitmap* CMIDBitmapImage::DuplicateAlphaBitmapL() const |
|
89 { |
|
90 CFbsBitmap* alphaBitmap = iImageRep.AlphaBitmap(); |
|
91 if (!alphaBitmap) |
|
92 { |
|
93 return NULL; |
|
94 } |
|
95 return CLcdFbsImage::DuplicateBitmapL(alphaBitmap); |
|
96 } |
|
97 |
|
98 void CMIDBitmapImage::Draw(CBitmapContext& aContext, const TPoint& aPoint) const |
|
99 { |
|
100 TRect rect(ColorBitmap()->SizeInPixels()); |
|
101 Draw(aContext, aPoint, rect); |
|
102 } |
|
103 |
|
104 void CMIDBitmapImage::Draw(CBitmapContext& aContext, const TPoint& aPoint, const TRect& aRect) const |
|
105 { |
|
106 CFbsBitmap* colorBitmap = ColorBitmap(); |
|
107 |
|
108 if (colorBitmap) |
|
109 { |
|
110 CFbsBitmap* alphaBitmap = AlphaBitmap(); |
|
111 |
|
112 if (alphaBitmap) |
|
113 { |
|
114 aContext.BitBltMasked(aPoint, colorBitmap, aRect, alphaBitmap, EFalse); |
|
115 } |
|
116 else |
|
117 { |
|
118 aContext.BitBlt(aPoint, colorBitmap, aRect); |
|
119 } |
|
120 } |
|
121 } |