|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of Camera Bitmap Scaler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <bitmaptransforms.h> |
|
22 #include "camlogging.h" |
|
23 #include "cambitmapscaler.h" |
|
24 |
|
25 // =========================================================================== |
|
26 // Local constants |
|
27 |
|
28 namespace NCamCameraController |
|
29 { |
|
30 static const TInt KPriority = CActive::EPriorityHigh; |
|
31 } |
|
32 |
|
33 using namespace NCamCameraController; |
|
34 |
|
35 // =========================================================================== |
|
36 // public constructor and destructor |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // 2 phase constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCamBitmapScaler* |
|
43 CCamBitmapScaler::NewL( MCamBitmapScalerObserver& aObserver ) |
|
44 { |
|
45 CCamBitmapScaler* self = |
|
46 new (ELeave) CCamBitmapScaler( aObserver ); |
|
47 |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop( self ); |
|
51 |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CCamBitmapScaler::~CCamBitmapScaler() |
|
61 { |
|
62 PRINT( _L("Camera => ~CCamBitmapScaler") ); |
|
63 Cancel(); |
|
64 |
|
65 delete iScaledBitmap; |
|
66 delete iScaler; |
|
67 |
|
68 PRINT( _L("Camera <= ~CCamBitmapScaler") ); |
|
69 } |
|
70 |
|
71 // =========================================================================== |
|
72 // public methods |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // InitScalingL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void |
|
80 CCamBitmapScaler::InitScalingL( const TSize& aTargetSize, |
|
81 const TDisplayMode& aTargetDisplayMode, |
|
82 TBool aMaintainAspect ) |
|
83 { |
|
84 PRINT( _L("Camera => CCamBitmapScaler::InitScalingL") ); |
|
85 Cancel(); |
|
86 |
|
87 if( !iScaledBitmap ) iScaledBitmap = new (ELeave) CFbsBitmap; |
|
88 else iScaledBitmap->Reset(); |
|
89 |
|
90 PRINT3( _L("Camera <> Create bitmap, size(%d,%d), mode(%d)"), |
|
91 aTargetSize.iWidth, |
|
92 aTargetSize.iHeight, |
|
93 aTargetDisplayMode ); |
|
94 |
|
95 User::LeaveIfError( iScaledBitmap->Create( aTargetSize, |
|
96 aTargetDisplayMode ) ); |
|
97 |
|
98 iMaintainAspect = aMaintainAspect; |
|
99 PRINT( _L("Camera <= CCamBitmapScaler::InitScalingL") ); |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // StartScaling |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CCamBitmapScaler::StartScaling( CFbsBitmap& aSourceBitmap ) |
|
108 { |
|
109 PRINT( _L("Camera => CCamBitmapScaler::StartScaling") ); |
|
110 |
|
111 Cancel(); |
|
112 |
|
113 iScaler->Scale( &iStatus, aSourceBitmap, *iScaledBitmap, iMaintainAspect ); |
|
114 SetActive(); |
|
115 |
|
116 PRINT( _L("Camera <= CCamBitmapScaler::StartScaling") ); |
|
117 } |
|
118 |
|
119 |
|
120 // =========================================================================== |
|
121 // from CActive |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // virtual |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void |
|
128 CCamBitmapScaler::DoCancel() |
|
129 { |
|
130 PRINT( _L("Camera => CCamBitmapScaler::DoCancel") ); |
|
131 |
|
132 if( iScaler ) |
|
133 { |
|
134 iScaler->Cancel(); |
|
135 } |
|
136 |
|
137 PRINT( _L("Camera <= CCamBitmapScaler::DoCancel") ); |
|
138 } |
|
139 |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // virtual |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void |
|
146 CCamBitmapScaler::RunL() |
|
147 { |
|
148 PRINT1( _L("Camera => CCamBitmapScaler::RunL, iStatus:%d"), iStatus.Int() ); |
|
149 |
|
150 switch( iStatus.Int() ) |
|
151 { |
|
152 case KErrNone : |
|
153 { |
|
154 iObserver.BitmapScaled( iStatus.Int(), iScaledBitmap ); |
|
155 break; |
|
156 } |
|
157 default : |
|
158 { |
|
159 User::Leave( iStatus.Int() ); |
|
160 break; |
|
161 } |
|
162 } |
|
163 |
|
164 PRINT( _L("Camera <= CCamBitmapScaler::RunL") ); |
|
165 } |
|
166 |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // virtual |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 TInt |
|
173 CCamBitmapScaler::RunError( TInt aError ) |
|
174 { |
|
175 PRINT1( _L("Camera => CCamBitmapScaler::RunError(%d)"), aError ); |
|
176 |
|
177 // Leave has occurred in RunL. |
|
178 // Notify observer with error. |
|
179 iObserver.BitmapScaled( aError, NULL ); |
|
180 |
|
181 PRINT( _L("Camera <= CCamBitmapScaler::RunError") ); |
|
182 return KErrNone; |
|
183 } |
|
184 |
|
185 |
|
186 // =========================================================================== |
|
187 // private constructors |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void |
|
194 CCamBitmapScaler::ConstructL() |
|
195 { |
|
196 CActiveScheduler::Add( this ); |
|
197 |
|
198 iScaler = CBitmapScaler::NewL(); |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 CCamBitmapScaler::CCamBitmapScaler( MCamBitmapScalerObserver& aObserver ) |
|
207 : CActive( KPriority ), |
|
208 iObserver( aObserver ) |
|
209 { |
|
210 } |
|
211 |
|
212 // end of file |