|
1 /* |
|
2 * Copyright (c) 2006 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 * CDCDCDigitalZoom |
|
16 * Scaling of image to display size & zooming. |
|
17 * Includes support for different scaling and crop sizes with pan&scan. |
|
18 * Pan can use previously computed scaled data when changing. |
|
19 * Based on IMAAMI scaling algorithm. |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 #include <fbs.h> |
|
27 #include "DCDigitalZoom.h" |
|
28 |
|
29 |
|
30 |
|
31 /* |
|
32 ----------------------------------------------------------------------------- |
|
33 |
|
34 CDCDigitalZoom::CDCDigitalZoom |
|
35 |
|
36 C++ constructor. |
|
37 |
|
38 Initialises set of member parameters. |
|
39 |
|
40 ----------------------------------------------------------------------------- |
|
41 */ |
|
42 CDCDigitalZoom::CDCDigitalZoom() |
|
43 { |
|
44 |
|
45 iParams.sizeX = 176; //640; // Size of VGA image for X |
|
46 iParams.sizeY = 144; //480; // Size of VGA image for Y |
|
47 iParams.scaleX = 1.0f; // No Scaling for X |
|
48 iParams.scaleY = 1.0f; // No scaling for Y |
|
49 iParams.allShiftX = 0; // No pan |
|
50 iParams.allShiftY = 0; // |
|
51 iParams.newShiftX = 0; // No pan |
|
52 iParams.newShiftY = 0; // |
|
53 |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 /* |
|
59 ----------------------------------------------------------------------------- |
|
60 |
|
61 CDCDigitalZoom::ConstructL |
|
62 |
|
63 Second phase constructor. |
|
64 |
|
65 Construct the object. (not used, may leave) |
|
66 |
|
67 ----------------------------------------------------------------------------- |
|
68 */ |
|
69 |
|
70 void CDCDigitalZoom::ConstructL() |
|
71 { |
|
72 // This function is intentionally left blank. |
|
73 } |
|
74 |
|
75 |
|
76 |
|
77 /* |
|
78 ----------------------------------------------------------------------------- |
|
79 |
|
80 CDCDigitalZoom::NewLC |
|
81 |
|
82 Allocate the memory and construct the object. |
|
83 Pushs pointer to a new instance to Cleanupstack. |
|
84 |
|
85 Return value: |
|
86 CDCDigitalZoom* self Pointer to a new instance |
|
87 |
|
88 ----------------------------------------------------------------------------- |
|
89 */ |
|
90 |
|
91 CDCDigitalZoom* CDCDigitalZoom::NewLC() |
|
92 { |
|
93 CDCDigitalZoom* self = new (ELeave) CDCDigitalZoom(); |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 |
|
97 return self; |
|
98 } |
|
99 |
|
100 |
|
101 |
|
102 /* |
|
103 ----------------------------------------------------------------------------- |
|
104 |
|
105 CDCDigitalZoom::NewL |
|
106 |
|
107 Allocate the memory and construct the object. |
|
108 |
|
109 Return value: |
|
110 CDCDigitalZoom* self Pointer to a new instance |
|
111 |
|
112 ----------------------------------------------------------------------------- |
|
113 */ |
|
114 |
|
115 CDCDigitalZoom* CDCDigitalZoom::NewL() |
|
116 { |
|
117 CDCDigitalZoom* self = CDCDigitalZoom::NewLC(); |
|
118 CleanupStack::Pop(); |
|
119 |
|
120 return self; |
|
121 } |
|
122 |
|
123 |
|
124 |
|
125 /* |
|
126 ----------------------------------------------------------------------------- |
|
127 |
|
128 CDCDigitalZoom::~CDCDigitalZoom |
|
129 |
|
130 C++ destructor. |
|
131 |
|
132 ----------------------------------------------------------------------------- |
|
133 */ |
|
134 |
|
135 CDCDigitalZoom::~CDCDigitalZoom() |
|
136 { |
|
137 // This function is intentionally left blank. |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 /* |
|
143 ----------------------------------------------------------------------------- |
|
144 |
|
145 CDCDigitalZoom::ProcessL |
|
146 |
|
147 Main function of digital zoom. (public) |
|
148 Calls processing function (zoomImage). |
|
149 |
|
150 NOTE: |
|
151 ImageZoomParams iParams have to be set before calling |
|
152 this function, so that the wanted processing is done. |
|
153 |
|
154 Parameters in: |
|
155 CFbsBitmap* aOriPtr Pointer to source image bitmap |
|
156 |
|
157 Parameters out: |
|
158 CFbsBitmap* aOutPtr Pointer to destination image bitmap |
|
159 |
|
160 Return value: None |
|
161 |
|
162 ----------------------------------------------------------------------------- |
|
163 */ |
|
164 |
|
165 void CDCDigitalZoom::ProcessL(const CFbsBitmap *aOriPtr, CFbsBitmap *aOutPtr) |
|
166 { |
|
167 //EColor16M image is needed |
|
168 if(aOutPtr->DisplayMode() != EColor16M) |
|
169 { |
|
170 return; |
|
171 } |
|
172 |
|
173 if(aOriPtr->DisplayMode() != EColor16M) |
|
174 { |
|
175 return; |
|
176 } |
|
177 |
|
178 // Find size of original image |
|
179 TInt oriSizeX = aOriPtr->SizeInPixels().iWidth; |
|
180 TInt oriSizeY = aOriPtr->SizeInPixels().iHeight; |
|
181 |
|
182 //Do scaling |
|
183 DecimateL(aOriPtr, aOutPtr, |
|
184 iParams.sizeX, iParams.sizeY, |
|
185 oriSizeX, oriSizeY, |
|
186 iParams.scaleX, iParams.scaleY, |
|
187 iParams.allShiftX, iParams.allShiftY, |
|
188 iParams.newShiftX, iParams.newShiftY); |
|
189 } |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 /* |
|
195 ----------------------------------------------------------------------------- |
|
196 |
|
197 DecimateL |
|
198 |
|
199 IMAAMI scaling core function |
|
200 |
|
201 ----------------------------------------------------------------------------- |
|
202 */ |
|
203 void CDCDigitalZoom::DecimateL(const CFbsBitmap* aOriPtr, CFbsBitmap* aOutPtr, |
|
204 TInt aOutSizeX, TInt aOutSizeY, |
|
205 TInt aOriSizeX, TInt aOriSizeY, |
|
206 TReal aZoomX, TReal aZoomY, |
|
207 TInt allShiftX, TInt allShiftY, |
|
208 TInt newShiftX, TInt newShiftY) |
|
209 { |
|
210 TInt32 |
|
211 divider, |
|
212 xPos, yPos, tmpline, |
|
213 xAver, yAver, |
|
214 xStep, yStep, |
|
215 tmpEnd, tmpSta, |
|
216 sumB, sumG, sumR, |
|
217 tmpB, tmpG, tmpR; |
|
218 |
|
219 TInt32 |
|
220 x, y, |
|
221 i, j, |
|
222 LastLine, |
|
223 xInt, yInt, |
|
224 xStaInt, yStaInt, |
|
225 xEndInt, yEndInt, |
|
226 xFirstInt, yFirstInt; |
|
227 |
|
228 TUint32 |
|
229 LineNum, |
|
230 outFlag, |
|
231 xRem, yRem, |
|
232 xStaRem, yStaRem, |
|
233 xEndRem, yEndRem, |
|
234 xStaWei, yStaWei, |
|
235 xEndWei, yEndWei, |
|
236 xAllWei, yAllWei, |
|
237 xMaxWei, yMaxWei, |
|
238 xLoopSta, yLoopSta, |
|
239 xLoopEnd, yLoopEnd, |
|
240 xFirstRem, yFirstRem; |
|
241 |
|
242 TUint32 |
|
243 PIX_BITS = 13, // 13 |
|
244 PIXEL = (TUint32)(1 << PIX_BITS), |
|
245 HALF_PIX = (TUint32)(1 << (PIX_BITS - 1)), |
|
246 REMAINDER = (TUint32)(PIXEL - 1), |
|
247 WEI_BITS = 4, // 4 |
|
248 HALF_WEI = (TUint32)(1 << (WEI_BITS - 1)), |
|
249 DIF1_BITS = (TUint32)(PIX_BITS - WEI_BITS), |
|
250 HALF_DIF1 = (TUint32)(1 << (DIF1_BITS - 1)), |
|
251 REM_HDIF1 = (TUint32)(HALF_DIF1 - 1), |
|
252 RED_BITS = 4, // 4 |
|
253 HALF_RED = (TUint32)(1 << (RED_BITS - 1)); |
|
254 |
|
255 |
|
256 if(aZoomX < 0.20 || aZoomY < 0.20) |
|
257 { |
|
258 RED_BITS = 5; |
|
259 HALF_RED = (TUint32)(1 << (RED_BITS - 1)); |
|
260 } |
|
261 |
|
262 // Allocate local temporal input0 line buffer and push its pointer to CleanupStack |
|
263 HBufC8* oriLine0 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
264 CleanupStack::PushL(oriLine0); |
|
265 |
|
266 // Allocate local temporal input1 line buffer and push its pointer to CleanupStack |
|
267 HBufC8* oriLine1 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
268 CleanupStack::PushL(oriLine1); |
|
269 |
|
270 // Allocate local temporal input2 line buffer and push its pointer to CleanupStack |
|
271 HBufC8* oriLine2 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
272 CleanupStack::PushL(oriLine2); |
|
273 |
|
274 // Allocate local temporal input3 line buffer and push its pointer to CleanupStack |
|
275 HBufC8* oriLine3 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
276 CleanupStack::PushL(oriLine3); |
|
277 |
|
278 // Allocate local temporal input4 line buffer and push its pointer to CleanupStack |
|
279 HBufC8* oriLine4 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
280 CleanupStack::PushL(oriLine4); |
|
281 |
|
282 // Allocate local temporal input5 line buffer and push its pointer to CleanupStack |
|
283 HBufC8* oriLine5 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
284 CleanupStack::PushL(oriLine5); |
|
285 |
|
286 // Allocate local temporal input6 line buffer and push its pointer to CleanupStack |
|
287 HBufC8* oriLine6 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
288 CleanupStack::PushL(oriLine6); |
|
289 |
|
290 // Allocate local temporal input7 line buffer and push its pointer to CleanupStack |
|
291 HBufC8* oriLine7 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
292 CleanupStack::PushL(oriLine7); |
|
293 |
|
294 // Allocate local temporal input8 line buffer and push its pointer to CleanupStack |
|
295 HBufC8* oriLine8 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
296 CleanupStack::PushL(oriLine8); |
|
297 |
|
298 // Allocate local temporal input9 line buffer and push its pointer to CleanupStack |
|
299 HBufC8* oriLine9 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
300 CleanupStack::PushL(oriLine9); |
|
301 |
|
302 // Allocate local temporal input10 line buffer and push its pointer to CleanupStack |
|
303 HBufC8* oriLine10 = HBufC8::NewMaxL(3 * aOriSizeX); // BGRBGR... |
|
304 CleanupStack::PushL(oriLine10); |
|
305 |
|
306 // Set pointers of input lines |
|
307 TUint8* line0Ptr = (TUint8*)oriLine0->Des().Ptr(); |
|
308 TUint8* line1Ptr = (TUint8*)oriLine1->Des().Ptr(); |
|
309 TUint8* line2Ptr = (TUint8*)oriLine2->Des().Ptr(); |
|
310 TUint8* line3Ptr = (TUint8*)oriLine3->Des().Ptr(); |
|
311 TUint8* line4Ptr = (TUint8*)oriLine4->Des().Ptr(); |
|
312 TUint8* line5Ptr = (TUint8*)oriLine5->Des().Ptr(); |
|
313 TUint8* line6Ptr = (TUint8*)oriLine6->Des().Ptr(); |
|
314 TUint8* line7Ptr = (TUint8*)oriLine7->Des().Ptr(); |
|
315 TUint8* line8Ptr = (TUint8*)oriLine8->Des().Ptr(); |
|
316 TUint8* line9Ptr = (TUint8*)oriLine9->Des().Ptr(); |
|
317 TUint8* line10Ptr = (TUint8*)oriLine10->Des().Ptr(); |
|
318 TUint8* linePtrs[11] = {line0Ptr, line1Ptr, line2Ptr, line3Ptr, line4Ptr, |
|
319 line5Ptr, line6Ptr, line7Ptr, line8Ptr, line9Ptr, line10Ptr}; |
|
320 |
|
321 TUint8* tmpPtr; |
|
322 TUint8* tempPtr; |
|
323 |
|
324 // Set TPtr8s of input lines |
|
325 TPtr8 Ptr0(line0Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
326 TPtr8 Ptr1(line1Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
327 TPtr8 Ptr2(line2Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
328 TPtr8 Ptr3(line3Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
329 TPtr8 Ptr4(line4Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
330 TPtr8 Ptr5(line5Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
331 TPtr8 Ptr6(line6Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
332 TPtr8 Ptr7(line7Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
333 TPtr8 Ptr8(line8Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
334 TPtr8 Ptr9(line9Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
335 TPtr8 Ptr10(line10Ptr, 3 * aOriSizeX, 3 * aOriSizeX); |
|
336 TPtr8 Ptrs[11] = {Ptr0, Ptr1, Ptr2, Ptr3, Ptr4, Ptr5, Ptr6, Ptr7, Ptr8, Ptr9, Ptr10}; |
|
337 |
|
338 // Set indicator for order of input lines |
|
339 TInt lines[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
|
340 |
|
341 // Allocate local temporal output line buffer and push its pointer to CleanupStack |
|
342 HBufC8* scanLine = HBufC8::NewMaxL(3 * aOutSizeX); |
|
343 CleanupStack::PushL(scanLine); |
|
344 |
|
345 // Set pointer of output line |
|
346 TUint8* DataPtr = (TUint8*)scanLine->Des().Ptr(); |
|
347 |
|
348 // Set TPtr8 of output line |
|
349 TPtr8 linePtr(DataPtr, 3 * aOutSizeX, 3 * aOutSizeX); |
|
350 |
|
351 |
|
352 // Calculate step between output pixels in original image |
|
353 xStep = (TInt)(PIXEL / aZoomX + 0.5); |
|
354 yStep = (TInt)(PIXEL / aZoomY + 0.5); |
|
355 |
|
356 // Calculate First output pixel position in original image |
|
357 xPos = ((aOriSizeX - 1) << (PIX_BITS - 1)) - (((aOutSizeX - 1 - (allShiftX << 1)) * xStep) >> 1); |
|
358 yPos = ((aOriSizeY - 1) << (PIX_BITS - 1)) - (((aOutSizeY - 1 - (allShiftY << 1)) * yStep) >> 1); |
|
359 |
|
360 xFirstInt = (TInt32)(xPos >> PIX_BITS); |
|
361 if(xPos < 0) xFirstRem = (TUint32)((xPos + ((-xFirstInt) << PIX_BITS)) & REMAINDER); |
|
362 else xFirstRem = (TUint32)(xPos & REMAINDER); |
|
363 |
|
364 yFirstInt = (TInt32)(yPos >> PIX_BITS); |
|
365 if(yPos < 0) yFirstRem = (TUint32)((yPos + ((-yFirstInt) << PIX_BITS)) & REMAINDER); |
|
366 else yFirstRem = (TUint32)(yPos & REMAINDER); |
|
367 |
|
368 // Calculate averaging area around the original pixel position |
|
369 xAver = (TInt)(xStep >> 1); |
|
370 yAver = (TInt)(yStep >> 1); |
|
371 |
|
372 // For bilinear interpolation at least 1 pixel have to be used |
|
373 if(aZoomX > 1 && xAver < (TInt32)(HALF_PIX)) xAver = HALF_PIX; |
|
374 if(aZoomY > 1 && yAver < (TInt32)(HALF_PIX)) yAver = HALF_PIX; |
|
375 |
|
376 // Calculate maximum weight sum |
|
377 yMaxWei = (TUint32)(((yAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
378 xMaxWei = (TUint32)(((xAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
379 |
|
380 // Calculate filter divider for filter window |
|
381 divider = (TInt)((xMaxWei * yMaxWei + HALF_RED) >> RED_BITS); |
|
382 |
|
383 while(divider <= 256 && WEI_BITS < PIX_BITS) |
|
384 { |
|
385 WEI_BITS++; |
|
386 HALF_WEI = (TUint32)(1 << (WEI_BITS - 1)); |
|
387 DIF1_BITS = (TUint32)(PIX_BITS - WEI_BITS); |
|
388 HALF_DIF1 = (TUint32)(1 << (DIF1_BITS - 1)); |
|
389 REM_HDIF1 = (TUint32)(HALF_DIF1 - 1); |
|
390 |
|
391 // Calculate maximum weight sum |
|
392 yMaxWei = (TUint32)(((yAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
393 xMaxWei = (TUint32)(((xAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
394 |
|
395 // Calculate filter divider for filter window |
|
396 divider = (TInt)((xMaxWei * yMaxWei + HALF_RED) >> RED_BITS); |
|
397 } |
|
398 |
|
399 if(divider > 1024) |
|
400 { |
|
401 WEI_BITS--; |
|
402 HALF_WEI = (TUint32)(1 << (WEI_BITS - 1)); |
|
403 DIF1_BITS = (TUint32)(PIX_BITS - WEI_BITS); |
|
404 HALF_DIF1 = (TUint32)(1 << (DIF1_BITS - 1)); |
|
405 REM_HDIF1 = (TUint32)(HALF_DIF1 - 1); |
|
406 |
|
407 // Calculate maximum weight sum |
|
408 yMaxWei = (TUint32)(((yAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
409 xMaxWei = (TUint32)(((xAver << 1) + HALF_DIF1) >> DIF1_BITS); |
|
410 |
|
411 // Calculate filter divider for filter window |
|
412 divider = (TInt)((xMaxWei * yMaxWei + HALF_RED) >> RED_BITS); |
|
413 } |
|
414 |
|
415 while(divider <= 512 && RED_BITS > 0) |
|
416 { |
|
417 RED_BITS--; |
|
418 HALF_RED = (TUint32)(1 << (RED_BITS - 1)); |
|
419 |
|
420 divider = (TInt)((xMaxWei * yMaxWei + HALF_RED) >> RED_BITS); |
|
421 } |
|
422 |
|
423 if(divider > 1024) |
|
424 { |
|
425 RED_BITS++; |
|
426 HALF_RED = (TUint32)(1 << (RED_BITS - 1)); |
|
427 } |
|
428 |
|
429 // Initialise y loop limiters |
|
430 yLoopSta = 0; |
|
431 yLoopEnd = (TUint32)(aOutSizeY); |
|
432 |
|
433 // Initialise x loop limiters |
|
434 xLoopSta = 0; |
|
435 xLoopEnd = (TUint32)(aOutSizeX); |
|
436 |
|
437 // Calculate only the panned image |
|
438 if(newShiftY > 0) |
|
439 { |
|
440 // Update y loop start |
|
441 yLoopSta = (TUint32)(aOutSizeY - newShiftY); |
|
442 |
|
443 // Initialise y position |
|
444 yInt = yFirstInt; |
|
445 yRem = yFirstRem; |
|
446 |
|
447 // Copy available image and change y position |
|
448 for(y = 0; y < (TInt32)yLoopSta; y++) |
|
449 { |
|
450 // Read output line from source image |
|
451 aOriPtr->GetScanLine(Ptrs[lines[0]], TPoint(0, y+newShiftY), aOriSizeX, aOriPtr->DisplayMode()); |
|
452 |
|
453 //Set the line to destination image |
|
454 aOutPtr->SetScanLine(linePtr, y); |
|
455 |
|
456 // Update y position |
|
457 tmpEnd = (TInt)(yRem + yStep); |
|
458 yInt = (TInt32)(yInt + (tmpEnd >> PIX_BITS)); |
|
459 yRem = (TUint32)(tmpEnd & REMAINDER); |
|
460 } |
|
461 |
|
462 // Update y position of first pixel |
|
463 yFirstInt = yInt; |
|
464 yFirstRem = yRem; |
|
465 } |
|
466 else if(newShiftY < 0) |
|
467 { |
|
468 // Update y loop end |
|
469 yLoopEnd = (TUint32)(-newShiftY); |
|
470 |
|
471 // Copy available image |
|
472 for(y = (TInt32)(aOutSizeY - 1); y >= (TInt32)yLoopEnd; y--) |
|
473 { |
|
474 // Read output line from source image |
|
475 aOriPtr->GetScanLine(Ptrs[lines[0]], TPoint(0, y+newShiftY), aOriSizeX, aOriPtr->DisplayMode()); |
|
476 |
|
477 //Set the line to destination image |
|
478 aOutPtr->SetScanLine(linePtr, y); |
|
479 } |
|
480 } |
|
481 |
|
482 // Calculate only the panned image |
|
483 if(newShiftX > 0) |
|
484 { |
|
485 // Update x loop start |
|
486 xLoopSta = (TUint32)(aOutSizeX - newShiftX); |
|
487 |
|
488 // Initialise x position |
|
489 xInt = xFirstInt; |
|
490 xRem = xFirstRem; |
|
491 |
|
492 // Change x position |
|
493 for(x = 0; x < (TInt32)xLoopSta; x++) |
|
494 { |
|
495 // Update x position |
|
496 tmpSta = (TInt)(xRem + xStep); |
|
497 xInt = (TInt32)(xInt + (tmpSta >> PIX_BITS)); |
|
498 xRem = (TUint32)(tmpSta & REMAINDER); |
|
499 } |
|
500 |
|
501 // Update x position of first pixel |
|
502 xFirstInt = xInt; |
|
503 xFirstRem = xRem; |
|
504 } |
|
505 else if(newShiftX < 0) |
|
506 { |
|
507 // Update loop end |
|
508 xLoopEnd = (TUint32)(-newShiftX); |
|
509 } |
|
510 |
|
511 // Initialise y position |
|
512 yInt = yFirstInt; |
|
513 yRem = yFirstRem; |
|
514 |
|
515 tmpEnd = (TInt)(yRem + yAver + HALF_PIX + HALF_WEI); |
|
516 yEndInt = (TInt32)((tmpEnd >> PIX_BITS) + yInt); |
|
517 yEndRem = (TUint32)(tmpEnd & REMAINDER); |
|
518 |
|
519 //Read 11 lines from the source image |
|
520 if (yEndInt >= 10) |
|
521 { |
|
522 aOriPtr->GetScanLine(Ptrs[lines[0]], TPoint(0, yEndInt-10), aOriSizeX, aOriPtr->DisplayMode()); |
|
523 aOriPtr->GetScanLine(Ptrs[lines[1]], TPoint(0, yEndInt-9), aOriSizeX, aOriPtr->DisplayMode()); |
|
524 aOriPtr->GetScanLine(Ptrs[lines[2]], TPoint(0, yEndInt-8), aOriSizeX, aOriPtr->DisplayMode()); |
|
525 aOriPtr->GetScanLine(Ptrs[lines[3]], TPoint(0, yEndInt-7), aOriSizeX, aOriPtr->DisplayMode()); |
|
526 aOriPtr->GetScanLine(Ptrs[lines[4]], TPoint(0, yEndInt-6), aOriSizeX, aOriPtr->DisplayMode()); |
|
527 aOriPtr->GetScanLine(Ptrs[lines[5]], TPoint(0, yEndInt-5), aOriSizeX, aOriPtr->DisplayMode()); |
|
528 aOriPtr->GetScanLine(Ptrs[lines[6]], TPoint(0, yEndInt-4), aOriSizeX, aOriPtr->DisplayMode()); |
|
529 aOriPtr->GetScanLine(Ptrs[lines[7]], TPoint(0, yEndInt-3), aOriSizeX, aOriPtr->DisplayMode()); |
|
530 aOriPtr->GetScanLine(Ptrs[lines[8]], TPoint(0, yEndInt-2), aOriSizeX, aOriPtr->DisplayMode()); |
|
531 aOriPtr->GetScanLine(Ptrs[lines[9]], TPoint(0, yEndInt-1), aOriSizeX, aOriPtr->DisplayMode()); |
|
532 aOriPtr->GetScanLine(Ptrs[lines[10]], TPoint(0, yEndInt ), aOriSizeX, aOriPtr->DisplayMode()); |
|
533 } |
|
534 else |
|
535 { |
|
536 if(yEndInt >= 0) |
|
537 aOriPtr->GetScanLine(Ptrs[lines[10]], TPoint(0, yEndInt ), aOriSizeX, aOriPtr->DisplayMode()); |
|
538 if(yEndInt >= 1) |
|
539 aOriPtr->GetScanLine(Ptrs[lines[9]], TPoint(0, yEndInt-1), aOriSizeX, aOriPtr->DisplayMode()); |
|
540 if(yEndInt >= 2) |
|
541 aOriPtr->GetScanLine(Ptrs[lines[8]], TPoint(0, yEndInt-2), aOriSizeX, aOriPtr->DisplayMode()); |
|
542 if(yEndInt >= 3) |
|
543 aOriPtr->GetScanLine(Ptrs[lines[7]], TPoint(0, yEndInt-3), aOriSizeX, aOriPtr->DisplayMode()); |
|
544 if(yEndInt >= 4) |
|
545 aOriPtr->GetScanLine(Ptrs[lines[6]], TPoint(0, yEndInt-4), aOriSizeX, aOriPtr->DisplayMode()); |
|
546 if(yEndInt >= 5) |
|
547 aOriPtr->GetScanLine(Ptrs[lines[5]], TPoint(0, yEndInt-5), aOriSizeX, aOriPtr->DisplayMode()); |
|
548 if(yEndInt >= 6) |
|
549 aOriPtr->GetScanLine(Ptrs[lines[4]], TPoint(0, yEndInt-6), aOriSizeX, aOriPtr->DisplayMode()); |
|
550 if(yEndInt >= 7) |
|
551 aOriPtr->GetScanLine(Ptrs[lines[3]], TPoint(0, yEndInt-7), aOriSizeX, aOriPtr->DisplayMode()); |
|
552 if(yEndInt >= 8) |
|
553 aOriPtr->GetScanLine(Ptrs[lines[2]], TPoint(0, yEndInt-8), aOriSizeX, aOriPtr->DisplayMode()); |
|
554 if(yEndInt >= 9) |
|
555 aOriPtr->GetScanLine(Ptrs[lines[1]], TPoint(0, yEndInt-9), aOriSizeX, aOriPtr->DisplayMode()); |
|
556 if(yEndInt >= 10) |
|
557 aOriPtr->GetScanLine(Ptrs[lines[0]], TPoint(0, yEndInt-10), aOriSizeX, aOriPtr->DisplayMode()); |
|
558 } |
|
559 LastLine = (TInt32)(yEndInt); |
|
560 |
|
561 // Loop y for result image |
|
562 for(y = (TInt32)yLoopSta; y < (TInt32)yLoopEnd; y++) |
|
563 { |
|
564 // Calculate used y pixels |
|
565 tmpSta = (TInt)(yRem - yAver + HALF_PIX + HALF_WEI); |
|
566 yStaInt = (TInt32)((tmpSta >> PIX_BITS) + yInt); |
|
567 yStaRem = (TUint32)(tmpSta & REMAINDER); |
|
568 |
|
569 tmpEnd = (TInt)(yRem + yAver + HALF_PIX + HALF_WEI); |
|
570 yEndInt = (TInt32)((tmpEnd >> PIX_BITS) + yInt); |
|
571 yEndRem = (TUint32)(tmpEnd & REMAINDER); |
|
572 |
|
573 //Read a new line from the source image if needed |
|
574 while (yEndInt > LastLine && LastLine < aOriSizeY-1) |
|
575 { |
|
576 LastLine++; |
|
577 tmpline = lines[0]; |
|
578 lines[0] = lines[1]; |
|
579 lines[1] = lines[2]; |
|
580 lines[2] = lines[3]; |
|
581 lines[3] = lines[4]; |
|
582 lines[4] = lines[5]; |
|
583 lines[5] = lines[6]; |
|
584 lines[6] = lines[7]; |
|
585 lines[7] = lines[8]; |
|
586 lines[8] = lines[9]; |
|
587 lines[9] = lines[10]; |
|
588 lines[10] = tmpline; |
|
589 |
|
590 if(LastLine >= 0) |
|
591 aOriPtr->GetScanLine(Ptrs[lines[10]], TPoint(0, LastLine), aOriSizeX, aOriPtr->DisplayMode()); |
|
592 } |
|
593 |
|
594 //Set pixel pointer to beginning of destination line |
|
595 DataPtr = (TUint8*)scanLine->Des().Ptr(); |
|
596 |
|
597 // Calculate column weights and weight sum |
|
598 yStaWei = (TUint32)((PIXEL - yStaRem - 1) >> DIF1_BITS); |
|
599 yEndWei = (TUint32)((yEndRem) >> DIF1_BITS); |
|
600 yAllWei = (TUint32)(yStaWei + ((yEndInt - yStaInt - 1) << WEI_BITS) + yEndWei); |
|
601 |
|
602 // Check that the weight sum is not too big |
|
603 if(yAllWei > yMaxWei) |
|
604 { |
|
605 if(((yEndRem) & REM_HDIF1) > ((PIXEL - yStaRem) & REM_HDIF1)) |
|
606 { |
|
607 yStaWei -= 1; |
|
608 } |
|
609 else |
|
610 { |
|
611 yEndWei -= 1; |
|
612 } |
|
613 yAllWei -= 1; |
|
614 } |
|
615 |
|
616 // Initialise x position |
|
617 xInt = xFirstInt; |
|
618 xRem = xFirstRem; |
|
619 |
|
620 // Calculate only the panned image |
|
621 if(newShiftX > 0) |
|
622 { |
|
623 tmpPtr = DataPtr; |
|
624 tempPtr = tmpPtr + newShiftX * 3; |
|
625 |
|
626 // Copy available image to the beginning of line |
|
627 for(x = 0; x < (TInt32)xLoopSta; x++) |
|
628 { |
|
629 *tmpPtr++ = *tempPtr++; |
|
630 *tmpPtr++ = *tempPtr++; |
|
631 *tmpPtr++ = *tempPtr++; |
|
632 } |
|
633 } |
|
634 else if(newShiftX < 0) |
|
635 { |
|
636 tmpPtr = DataPtr + 3 * aOutSizeX - 1; |
|
637 tempPtr = tmpPtr + newShiftX * 3; |
|
638 |
|
639 // Copy available image to the end of line |
|
640 for(x = (TInt32)(aOutSizeX - 1); x >= (TInt32)xLoopEnd; x--) |
|
641 { |
|
642 *tmpPtr-- = *tempPtr--; |
|
643 *tmpPtr-- = *tempPtr--; |
|
644 *tmpPtr-- = *tempPtr--; |
|
645 } |
|
646 } |
|
647 |
|
648 LineNum = (TUint32)((yStaInt - LastLine + 10) % 11); |
|
649 |
|
650 // Loop x for result image |
|
651 for(x = (TInt32)xLoopSta; x < (TInt32)xLoopEnd; x++) |
|
652 { |
|
653 // Calculate used x pixels |
|
654 tmpSta = (TInt)(xRem - xAver + HALF_PIX + HALF_WEI); |
|
655 xStaInt = (TInt32)((tmpSta >> PIX_BITS) + xInt); |
|
656 xStaRem = (TUint32)((tmpSta & REMAINDER)); |
|
657 |
|
658 tmpEnd = (TInt)(xRem + xAver + HALF_PIX + HALF_WEI); |
|
659 xEndInt = (TInt32)((tmpEnd >> PIX_BITS) + xInt); |
|
660 xEndRem = (TUint32)(tmpEnd & REMAINDER); |
|
661 |
|
662 // Calculate line weights and weight sum |
|
663 xStaWei = (TUint32)((PIXEL - xStaRem - 1) >> DIF1_BITS); |
|
664 xEndWei = (TUint32)((xEndRem) >> DIF1_BITS); |
|
665 xAllWei = (TUint32)(xStaWei + ((xEndInt - xStaInt - 1) << WEI_BITS) + xEndWei); |
|
666 |
|
667 // Check that the weight sum is not too big |
|
668 if(xAllWei > xMaxWei) |
|
669 { |
|
670 if(((xEndRem) & REM_HDIF1) > ((PIXEL - xStaRem) & REM_HDIF1)) |
|
671 { |
|
672 xStaWei -= 1; |
|
673 } |
|
674 else |
|
675 { |
|
676 xEndWei -= 1; |
|
677 } |
|
678 xAllWei -= 1; |
|
679 } |
|
680 |
|
681 // Calculate filter divider for filter window |
|
682 divider = (TInt)((xAllWei * yAllWei + HALF_RED) >> RED_BITS); |
|
683 |
|
684 // Calculate pixel values |
|
685 outFlag = 0; |
|
686 |
|
687 // Initialise block result |
|
688 sumB = 0; |
|
689 sumG = 0; |
|
690 sumR = 0; |
|
691 |
|
692 LineNum = (TUint32)((yStaInt - LastLine + 10) % 11); |
|
693 |
|
694 // Accumulate first line |
|
695 if(yStaWei != 0) |
|
696 { |
|
697 // Line number |
|
698 if(yStaInt < 0) outFlag = 1; |
|
699 else if(yStaInt >= aOriSizeY) outFlag = 1; |
|
700 else |
|
701 { |
|
702 // Initialise line result |
|
703 tmpB = 0; |
|
704 tmpG = 0; |
|
705 tmpR = 0; |
|
706 |
|
707 // First pixel in first line |
|
708 if(xStaWei != 0) |
|
709 { |
|
710 // Column number |
|
711 if(xStaInt < 0) outFlag = 1; |
|
712 else if(xStaInt >= aOriSizeX) outFlag = 1; |
|
713 else |
|
714 { |
|
715 // Pixel weighting to line result |
|
716 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xStaInt)) * xStaWei); |
|
717 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 1)) * xStaWei); |
|
718 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 2)) * xStaWei); |
|
719 } |
|
720 } |
|
721 |
|
722 // Middle pixels in first line |
|
723 for(i = (TInt32)(xStaInt + 1); i < xEndInt; i++) |
|
724 { |
|
725 // Column number |
|
726 if(i < 0) outFlag = 1; |
|
727 else if(i >= aOriSizeX) outFlag = 1; |
|
728 else |
|
729 { |
|
730 // Pixel weighting to line result |
|
731 tmpB = (TInt)(tmpB + ((*(linePtrs[lines[LineNum]] + 3 * i )) << WEI_BITS)); |
|
732 tmpG = (TInt)(tmpG + ((*(linePtrs[lines[LineNum]] + 3 * i + 1)) << WEI_BITS)); |
|
733 tmpR = (TInt)(tmpR + ((*(linePtrs[lines[LineNum]] + 3 * i + 2)) << WEI_BITS)); |
|
734 } |
|
735 } |
|
736 |
|
737 // Last pixel in first line |
|
738 if(xEndWei != 0) |
|
739 { |
|
740 // Column number |
|
741 if(xEndInt < 0) outFlag = 1; |
|
742 else if(xEndInt >= aOriSizeX) outFlag = 1; |
|
743 else |
|
744 { |
|
745 // Pixel weighting to line result |
|
746 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xEndInt )) * xEndWei); |
|
747 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 1)) * xEndWei); |
|
748 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 2)) * xEndWei); |
|
749 } |
|
750 } |
|
751 |
|
752 // Pixel weighting to block result |
|
753 sumB = (TInt)(sumB + ((yStaWei * tmpB + HALF_RED) >> RED_BITS)); |
|
754 sumG = (TInt)(sumG + ((yStaWei * tmpG + HALF_RED) >> RED_BITS)); |
|
755 sumR = (TInt)(sumR + ((yStaWei * tmpR + HALF_RED) >> RED_BITS)); |
|
756 } |
|
757 } |
|
758 LineNum++; |
|
759 |
|
760 // Accumulate middle lines |
|
761 for(j = (TInt32)(yStaInt + 1); j < yEndInt; j++) |
|
762 { |
|
763 // Line number |
|
764 if(j < 0) outFlag = 1; |
|
765 else if(j >= aOriSizeY) outFlag = 1; |
|
766 else |
|
767 { |
|
768 // Initialise line result |
|
769 tmpB = 0; |
|
770 tmpG = 0; |
|
771 tmpR = 0; |
|
772 |
|
773 // First pixel in middle lines |
|
774 if(xStaWei != 0) |
|
775 { |
|
776 // Column number |
|
777 if(xStaInt < 0) outFlag = 1; |
|
778 else if(xStaInt >= aOriSizeX) outFlag = 1; |
|
779 else |
|
780 { |
|
781 // Pixel weighting to line result |
|
782 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xStaInt )) * xStaWei); |
|
783 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 1)) * xStaWei); |
|
784 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 2)) * xStaWei); |
|
785 } |
|
786 } |
|
787 |
|
788 // Middle pixels in middle lines |
|
789 for(i = (TInt32)(xStaInt + 1); i < xEndInt; i++) |
|
790 { |
|
791 // Column number |
|
792 if(i < 0) outFlag = 1; |
|
793 else if(i >= aOriSizeX) outFlag = 1; |
|
794 else |
|
795 { |
|
796 // Pixel weighting to line result |
|
797 tmpB = (TInt)(tmpB + ((*(linePtrs[lines[LineNum]] + 3 * i )) << WEI_BITS)); |
|
798 tmpG = (TInt)(tmpG + ((*(linePtrs[lines[LineNum]] + 3 * i + 1)) << WEI_BITS)); |
|
799 tmpR = (TInt)(tmpR + ((*(linePtrs[lines[LineNum]] + 3 * i + 2)) << WEI_BITS)); |
|
800 } |
|
801 } |
|
802 |
|
803 // Last pixel in middle lines |
|
804 if(xEndWei != 0) |
|
805 { |
|
806 // Column number |
|
807 if(xEndInt < 0) outFlag = 1; |
|
808 else if(xEndInt >= aOriSizeX) outFlag = 1; |
|
809 else |
|
810 { |
|
811 // Pixel weighting to line result |
|
812 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xEndInt )) * xEndWei); |
|
813 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 1)) * xEndWei); |
|
814 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 2)) * xEndWei); |
|
815 } |
|
816 } |
|
817 |
|
818 // Pixel weighting to block result |
|
819 sumB = (TInt)(sumB + (((tmpB << WEI_BITS) + HALF_RED) >> RED_BITS)); |
|
820 sumG = (TInt)(sumG + (((tmpG << WEI_BITS) + HALF_RED) >> RED_BITS)); |
|
821 sumR = (TInt)(sumR + (((tmpR << WEI_BITS) + HALF_RED) >> RED_BITS)); |
|
822 } |
|
823 LineNum++; |
|
824 } |
|
825 |
|
826 |
|
827 // Accumulate last line |
|
828 if(yEndWei != 0) |
|
829 { |
|
830 // Line number |
|
831 if(yEndInt < 0) outFlag = 1; |
|
832 else if(yEndInt >= aOriSizeY) outFlag = 1; |
|
833 else |
|
834 { |
|
835 // Initialise line result |
|
836 tmpB = 0; |
|
837 tmpG = 0; |
|
838 tmpR = 0; |
|
839 |
|
840 // First pixel in last line |
|
841 if(xStaWei != 0) |
|
842 { |
|
843 // Column number |
|
844 if(xStaInt < 0) outFlag = 1; |
|
845 else if(xStaInt >= aOriSizeX) outFlag = 1; |
|
846 else |
|
847 { |
|
848 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xStaInt )) * xStaWei); |
|
849 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 1)) * xStaWei); |
|
850 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xStaInt + 2)) * xStaWei); |
|
851 } |
|
852 } |
|
853 |
|
854 // Middle pixels in last line |
|
855 for(i = (TInt32)(xStaInt + 1); i < xEndInt; i++) |
|
856 { |
|
857 // Column number |
|
858 if(i < 0) outFlag = 1; |
|
859 else if(i >= aOriSizeX) outFlag = 1; |
|
860 else |
|
861 { |
|
862 tmpB = (TInt)(tmpB + ((*(linePtrs[lines[LineNum]] + 3 * i )) << WEI_BITS)); |
|
863 tmpG = (TInt)(tmpG + ((*(linePtrs[lines[LineNum]] + 3 * i + 1)) << WEI_BITS)); |
|
864 tmpR = (TInt)(tmpR + ((*(linePtrs[lines[LineNum]] + 3 * i + 2)) << WEI_BITS)); |
|
865 } |
|
866 } |
|
867 |
|
868 // Last pixel in last line |
|
869 if(xEndWei != 0) |
|
870 { |
|
871 // Column number |
|
872 if(xEndInt < 0) outFlag = 1; |
|
873 else if(xEndInt >= aOriSizeX) outFlag = 1; |
|
874 else |
|
875 { |
|
876 tmpB = (TInt)(tmpB + (*(linePtrs[lines[LineNum]] + 3 * xEndInt )) * xEndWei); |
|
877 tmpG = (TInt)(tmpG + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 1)) * xEndWei); |
|
878 tmpR = (TInt)(tmpR + (*(linePtrs[lines[LineNum]] + 3 * xEndInt + 2)) * xEndWei); |
|
879 } |
|
880 } |
|
881 |
|
882 // Pixel weighting to block result |
|
883 sumB = (TInt)(sumB + ((yEndWei * tmpB + HALF_RED) >> RED_BITS)); |
|
884 sumG = (TInt)(sumG + ((yEndWei * tmpG + HALF_RED) >> RED_BITS)); |
|
885 sumR = (TInt)(sumR + ((yEndWei * tmpR + HALF_RED) >> RED_BITS)); |
|
886 } |
|
887 } |
|
888 LineNum++; |
|
889 |
|
890 |
|
891 // Pixels outside the original image are needed |
|
892 if(outFlag > 0 || divider == 0) |
|
893 { |
|
894 // Save output values |
|
895 *(DataPtr + x * 3 ) = 255; |
|
896 *(DataPtr + x * 3 + 1) = 255; |
|
897 *(DataPtr + x * 3 + 2) = 255; |
|
898 } |
|
899 |
|
900 // Pixels are inside the original image |
|
901 else |
|
902 { |
|
903 if(divider == 1) |
|
904 { |
|
905 tmpB = sumB; |
|
906 tmpG = sumG; |
|
907 tmpR = sumR; |
|
908 } |
|
909 else if(divider == 2) |
|
910 { |
|
911 tmpB = (TInt)((sumB + 1) >> 1); |
|
912 tmpG = (TInt)((sumG + 1) >> 1); |
|
913 tmpR = (TInt)((sumR + 1) >> 1); |
|
914 } |
|
915 else if(divider == 4) |
|
916 { |
|
917 tmpB = (TInt)((sumB + 2) >> 2); |
|
918 tmpG = (TInt)((sumG + 2) >> 2); |
|
919 tmpR = (TInt)((sumR + 2) >> 2); |
|
920 } |
|
921 else if(divider == 8) |
|
922 { |
|
923 tmpB = (TInt)((sumB + 4) >> 3); |
|
924 tmpG = (TInt)((sumG + 4) >> 3); |
|
925 tmpR = (TInt)((sumR + 4) >> 3); |
|
926 } |
|
927 else if(divider == 16) |
|
928 { |
|
929 tmpB = (TInt)((sumB + 8) >> 4); |
|
930 tmpG = (TInt)((sumG + 8) >> 4); |
|
931 tmpR = (TInt)((sumR + 8) >> 4); |
|
932 } |
|
933 else if(divider == 32) |
|
934 { |
|
935 tmpB = (TInt)((sumB + 16) >> 5); |
|
936 tmpG = (TInt)((sumG + 16) >> 5); |
|
937 tmpR = (TInt)((sumR + 16) >> 5); |
|
938 } |
|
939 else if(divider == 64) |
|
940 { |
|
941 tmpB = (TInt)((sumB + 32) >> 6); |
|
942 tmpG = (TInt)((sumG + 32) >> 6); |
|
943 tmpR = (TInt)((sumR + 32) >> 6); |
|
944 } |
|
945 else if(divider == 128) |
|
946 { |
|
947 tmpB = (TInt)((sumB + 64) >> 7); |
|
948 tmpG = (TInt)((sumG + 64) >> 7); |
|
949 tmpR = (TInt)((sumR + 64) >> 7); |
|
950 } |
|
951 else if(divider == 256) |
|
952 { |
|
953 tmpB = (TInt)((sumB + 128) >> 8); |
|
954 tmpG = (TInt)((sumG + 128) >> 8); |
|
955 tmpR = (TInt)((sumR + 128) >> 8); |
|
956 } |
|
957 else if(divider == 512) |
|
958 { |
|
959 tmpB = (TInt)((sumB + 256) >> 9); |
|
960 tmpG = (TInt)((sumG + 256) >> 9); |
|
961 tmpR = (TInt)((sumR + 256) >> 9); |
|
962 } |
|
963 else if(divider == 1024) |
|
964 { |
|
965 tmpB = (TInt)((sumB + 512) >> 10); |
|
966 tmpG = (TInt)((sumG + 512) >> 10); |
|
967 tmpR = (TInt)((sumR + 512) >> 10); |
|
968 } |
|
969 else |
|
970 { |
|
971 tmpB = (TInt)(((sumB * KDivTable[divider - 2]) + 32768) >> 16); |
|
972 tmpG = (TInt)(((sumG * KDivTable[divider - 2]) + 32768) >> 16); |
|
973 tmpR = (TInt)(((sumR * KDivTable[divider - 2]) + 32768) >> 16); |
|
974 } |
|
975 |
|
976 // Save output values |
|
977 if(tmpB > 255) |
|
978 *(DataPtr + x * 3 ) = 255; |
|
979 else |
|
980 *(DataPtr + x * 3 ) = (TUint8)(tmpB); |
|
981 if(tmpG > 255) |
|
982 *(DataPtr + x * 3 + 1) = 255; |
|
983 else |
|
984 *(DataPtr + x * 3 + 1) = (TUint8)(tmpG); |
|
985 if(tmpR > 255) |
|
986 *(DataPtr + x * 3 + 2) = 255; |
|
987 else |
|
988 *(DataPtr + x * 3 + 2) = (TUint8)(tmpR); |
|
989 } |
|
990 |
|
991 // Update x position |
|
992 tmpEnd = (TInt)(xRem + xStep); |
|
993 xInt = (TInt32)(xInt + (tmpEnd >> PIX_BITS)); |
|
994 xRem = (TUint32)(tmpEnd & REMAINDER); |
|
995 } |
|
996 |
|
997 //Set processed line |
|
998 aOutPtr->SetScanLine(linePtr, y); |
|
999 |
|
1000 // Update y position |
|
1001 tmpEnd = (TInt)(yRem + yStep); |
|
1002 yInt = (TInt32)(yInt + (tmpEnd >> PIX_BITS)); |
|
1003 yRem = (TUint32)(tmpEnd & REMAINDER); |
|
1004 } |
|
1005 |
|
1006 // Delete local temporal line buffers (pop from CleanupStack) |
|
1007 CleanupStack::PopAndDestroy(12); // scanLine, oriLine0 and oriLine1 |
|
1008 } |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 /* |
|
1014 ----------------------------------------------------------------------------- |
|
1015 |
|
1016 SetParams |
|
1017 |
|
1018 Set processing parameters |
|
1019 |
|
1020 Return Values: none |
|
1021 |
|
1022 ----------------------------------------------------------------------------- |
|
1023 */ |
|
1024 void CDCDigitalZoom::SetParameters(DCDigitalZoomParams* params) |
|
1025 { |
|
1026 iParams = *params; |
|
1027 } |
|
1028 |
|
1029 |
|
1030 |
|
1031 /* |
|
1032 ----------------------------------------------------------------------------- |
|
1033 |
|
1034 GetParams |
|
1035 |
|
1036 Get current processing parameters |
|
1037 |
|
1038 Return Values: none |
|
1039 |
|
1040 ----------------------------------------------------------------------------- |
|
1041 */ |
|
1042 void CDCDigitalZoom::GetParameters(DCDigitalZoomParams* params) |
|
1043 { |
|
1044 *params = iParams; |
|
1045 } |
|
1046 //----IMAAMI---- |