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