|
1 /* |
|
2 * Copyright (c) 2004 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: Image Transforms subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <e32svr.h> |
|
22 #include <fbs.h> |
|
23 |
|
24 #include "CVtImageBitmap.h" |
|
25 |
|
26 // MACROS |
|
27 |
|
28 #ifdef _DEBUG |
|
29 # define __IF_DEBUG(t) {RDebug::t;} |
|
30 #else |
|
31 # define __IF_DEBUG(t) |
|
32 #endif |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CVtImageBitmap::NewL( TInt aBitmapHandle ) |
|
38 // ----------------------------------------------------------------------------- |
|
39 EXPORT_C CVtImageBitmap* CVtImageBitmap::NewL( TInt aBitmapHandle ) |
|
40 { |
|
41 CVtImageBitmap* self = new ( ELeave ) CVtImageBitmap(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aBitmapHandle ); |
|
44 CleanupStack::Pop(); // self |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CVtImageBitmap::NewL( const TSize& aSize, TDisplayMode aDisplayMode ) |
|
50 // ----------------------------------------------------------------------------- |
|
51 EXPORT_C CVtImageBitmap* CVtImageBitmap::NewL( |
|
52 const TSize& aSize, |
|
53 TDisplayMode aDisplayMode ) |
|
54 { |
|
55 CVtImageBitmap* self = new ( ELeave ) CVtImageBitmap(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL( aSize, aDisplayMode ); |
|
58 CleanupStack::Pop(); // self |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CVtImageBitmap::~CVtImageBitmap() |
|
64 // ----------------------------------------------------------------------------- |
|
65 EXPORT_C CVtImageBitmap::~CVtImageBitmap() |
|
66 { |
|
67 delete iBitmap; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CVtImageBitmap::ResizeL( const TSize& aSize ) |
|
72 // ----------------------------------------------------------------------------- |
|
73 EXPORT_C void CVtImageBitmap::ResizeL( const TSize& aSize ) |
|
74 { |
|
75 User::LeaveIfError( iBitmap->Resize( aSize ) ); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CVtImageBitmap::SetBitmapL( TInt aBitmapHandle ) |
|
80 // ----------------------------------------------------------------------------- |
|
81 EXPORT_C void CVtImageBitmap::SetBitmapL( TInt aBitmapHandle ) |
|
82 { |
|
83 delete iBitmap; |
|
84 iBitmap = 0; |
|
85 ConstructL( aBitmapHandle ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CVtImageBitmap::Bitmap() const |
|
90 // ----------------------------------------------------------------------------- |
|
91 EXPORT_C CFbsBitmap& CVtImageBitmap::Bitmap() const |
|
92 { |
|
93 return *iBitmap; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CVtImageBitmap::NeedHeapLock() const |
|
98 // ----------------------------------------------------------------------------- |
|
99 TBool CVtImageBitmap::NeedHeapLock() const |
|
100 { |
|
101 return iBitmap->IsLargeBitmap(); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CVtImageBitmap::DisplayMode() const |
|
106 // ----------------------------------------------------------------------------- |
|
107 CVtImage::TVtDisplayMode CVtImageBitmap::DisplayMode() const |
|
108 { |
|
109 return CVtImage::DisplayModeToVtDisplayMode( iBitmap->DisplayMode() ); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CVtImageBitmap::Size() const |
|
114 // ----------------------------------------------------------------------------- |
|
115 TSize CVtImageBitmap::Size() const |
|
116 { |
|
117 return iBitmap->SizeInPixels(); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CVtImageBitmap::BytesPerRow() const |
|
122 // ----------------------------------------------------------------------------- |
|
123 TInt CVtImageBitmap::BytesPerRow() const |
|
124 { |
|
125 return iBitmap->ScanLineLength( Size().iWidth, iBitmap->DisplayMode() ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CVtImageBitmap::DataAddress() const |
|
130 // ----------------------------------------------------------------------------- |
|
131 TUint32* CVtImageBitmap::DataAddress() const |
|
132 { |
|
133 return iBitmap->DataAddress(); |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CVtImageBitmap::LineAddress( TInt aLine ) const |
|
138 // ----------------------------------------------------------------------------- |
|
139 TUint32* CVtImageBitmap::LineAddress( TInt aLine ) const |
|
140 { |
|
141 if( aLine < 0 ) |
|
142 { |
|
143 aLine = 0; |
|
144 } |
|
145 else if( aLine > Size().iHeight - 1 ) |
|
146 { |
|
147 aLine = Size().iHeight - 1; |
|
148 } |
|
149 return reinterpret_cast< TUint32* >( |
|
150 reinterpret_cast< TUint8* >( DataAddress() ) + BytesPerRow() * aLine ); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CVtImageBitmap::CVtImageBitmap() |
|
155 // ----------------------------------------------------------------------------- |
|
156 CVtImageBitmap::CVtImageBitmap() |
|
157 : CVtImage( CVtImage::EVtImageBitmap ) |
|
158 { |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CVtImageBitmap::ConstructL( const TSize& aSize, TDisplayMode aDisplayMode ) |
|
163 // ----------------------------------------------------------------------------- |
|
164 void CVtImageBitmap::ConstructL( const TSize& aSize, TDisplayMode aDisplayMode ) |
|
165 { |
|
166 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
167 User::LeaveIfError( iBitmap->Create( aSize, aDisplayMode ) ); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CVtImageBitmap::ConstructL( TInt aBitmapHandle ) |
|
172 // ----------------------------------------------------------------------------- |
|
173 void CVtImageBitmap::ConstructL( TInt aBitmapHandle ) |
|
174 { |
|
175 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
176 User::LeaveIfError( iBitmap->Duplicate( aBitmapHandle ) ); |
|
177 } |
|
178 |
|
179 // End of File |
|
180 |
|
181 |