114 delete iDecoder; |
114 delete iDecoder; |
115 iDecoder = NULL; |
115 iDecoder = NULL; |
116 //Get Exif Metadata and the orientation tag from the file first |
116 //Get Exif Metadata and the orientation tag from the file first |
117 TUint16 orientation = GetOrientationL(aFileName); |
117 TUint16 orientation = GetOrientationL(aFileName); |
118 TInt isExtDecoderUsed = 0; |
118 TInt isExtDecoderUsed = 0; |
119 ///iDecoder = GlxtnImageDecoderFactory::NewL( iFs, aFileName ); |
|
120 iDecoder = GlxtnImageDecoderFactory::NewL( iFs, aFileName, isExtDecoderUsed ); |
119 iDecoder = GlxtnImageDecoderFactory::NewL( iFs, aFileName, isExtDecoderUsed ); |
121 iOriginalSize = iDecoder->FrameInfo().iOverallSizeInPixels; |
120 iOriginalSize = iDecoder->FrameInfo().iOverallSizeInPixels; |
122 //Get the orientation and set rotation on the decoder |
121 //Get the orientation and set rotation on the decoder |
123 //as well as update the original size |
122 //as well as update the original size |
124 if (isExtDecoderUsed) |
123 if (isExtDecoderUsed) |
216 // OPTION's for MMP file: |
215 // OPTION's for MMP file: |
217 // Interleave assembly code with C, output can be found on txt-files on some BUILD directory: |
216 // Interleave assembly code with C, output can be found on txt-files on some BUILD directory: |
218 // OPTION ARMCC --asm --interleave |
217 // OPTION ARMCC --asm --interleave |
219 // Modify optimization for ARM insturcion set and for maximum speed |
218 // Modify optimization for ARM insturcion set and for maximum speed |
220 // OPTION_REPLACE ARMCC --arm -Otime |
219 // OPTION_REPLACE ARMCC --arm -Otime |
221 /* aSource->LockHeap(); |
|
222 TUint16* sourceAddress = (TUint16*)aSource->DataAddress(); |
|
223 aSource->UnlockHeap(); |
|
224 aTarget->LockHeap(); |
|
225 TUint16* targetAddress = (TUint16*)aTarget->DataAddress(); |
|
226 aTarget->UnlockHeap(); |
|
227 ScaleColor64K(sourceAddress, aSource->DataStride(), |
|
228 sourceSize.iWidth, sourceSize.iHeight, 0, 0, sourceSize.iWidth, sourceSize.iHeight, |
|
229 targetAddress, aTarget->DataStride(), |
|
230 targetSize.iWidth, targetSize.iHeight); |
|
231 */ |
|
232 |
220 |
233 void CGlxtnImageUtility::FilterImageL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, CFbsBitmap* aTarget) |
221 void CGlxtnImageUtility::FilterImageL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, CFbsBitmap* aTarget) |
234 { |
222 { |
235 TRACER("void CGlxtnImageUtility::FilterImageL()"); |
223 TRACER("void CGlxtnImageUtility::FilterImageL()"); |
236 TSize sourceSize(aSource->SizeInPixels()); |
224 TSize sourceSize(aSource->SizeInPixels()); |
297 sourceImage->UnlockHeap(); |
285 sourceImage->UnlockHeap(); |
298 aTarget->LockHeap(); |
286 aTarget->LockHeap(); |
299 TUint16* targetAddress = (TUint16*)aTarget->DataAddress(); |
287 TUint16* targetAddress = (TUint16*)aTarget->DataAddress(); |
300 aTarget->UnlockHeap(); |
288 aTarget->UnlockHeap(); |
301 ScaleColor64K(sourceAddress, sourceImage->DataStride(), |
289 ScaleColor64K(sourceAddress, sourceImage->DataStride(), |
302 sourceImage->SizeInPixels().iWidth, sourceImage->SizeInPixels().iHeight, 0, 0, sourceImage->SizeInPixels().iWidth, sourceImage->SizeInPixels().iHeight, |
290 sourceImage->SizeInPixels().iWidth, |
303 targetAddress, aTarget->DataStride(), |
291 sourceImage->SizeInPixels().iHeight, 0, 0, |
304 targetSize.iWidth, targetSize.iHeight); |
292 sourceImage->SizeInPixels().iWidth, |
|
293 sourceImage->SizeInPixels().iHeight, targetAddress, |
|
294 aTarget->DataStride(), targetSize.iWidth, targetSize.iHeight); |
305 |
295 |
306 /* if ( !iBitGc ) |
|
307 { |
|
308 iBitGc = CFbsBitGc::NewL(); |
|
309 } |
|
310 CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(aTarget); |
|
311 CleanupStack::PushL(bitmapDevice); |
|
312 iBitGc->Activate(bitmapDevice); |
|
313 iBitGc->DrawBitmap(targetRect, sourceImage, sourceRect); |
|
314 CleanupStack::PopAndDestroy(bitmapDevice); |
|
315 */ |
|
316 *aStatus = KRequestPending; |
296 *aStatus = KRequestPending; |
317 User::RequestComplete(aStatus, KErrNone); |
297 User::RequestComplete(aStatus, KErrNone); |
318 } |
298 } |
319 |
299 |
320 void CGlxtnImageUtility::ScaleColor64K( TUint16* aSrc, TInt aSrcStride, TInt /*aSrcCols*/, TInt /*aSrcRows*/, |
300 void CGlxtnImageUtility::ScaleColor64K( TUint16* aSrc, TInt aSrcStride, TInt /*aSrcCols*/, TInt /*aSrcRows*/, |
407 #define b565( rgb ) (bm565(rgb)) |
387 #define b565( rgb ) (bm565(rgb)) |
408 #define rgb565( r, g, b ) (((r)<<11)|((g)<<5)|(b)) |
388 #define rgb565( r, g, b ) (((r)<<11)|((g)<<5)|(b)) |
409 |
389 |
410 #define mask32gbr655 0x07e0f81f |
390 #define mask32gbr655 0x07e0f81f |
411 |
391 |
412 // Keep below three defs in sync with each other! |
392 // Keep below three defs in sync with each other |
413 #define KFIRLen 2 |
393 #define KFIRLen 2 |
414 #define KFIRCen (KFIRLen / 2) |
394 #define KFIRCen (KFIRLen / 2) |
415 #define incFIRIndex( i ) i = (i + 1) & (KFIRLen - 1) |
395 #define incFIRIndex( i ) i = (i + 1) & (KFIRLen - 1) |
416 // Keep above three defs in sync with each other! |
396 // Keep above three defs in sync with each other |
417 |
397 |
418 void CGlxtnImageUtility::FIRFiltering( |
398 void CGlxtnImageUtility::FIRFiltering( |
419 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
399 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
420 { |
400 { |
421 TRACER("void CGlxtnImageUtility::FIRFiltering( )"); |
401 TRACER("void CGlxtnImageUtility::FIRFiltering( )"); |
427 TUint FIRsum; |
407 TUint FIRsum; |
428 // Horizontal scan. |
408 // Horizontal scan. |
429 p = aDst; |
409 p = aDst; |
430 for ( row = aDstRows - 1; row >= 0; row-- ) |
410 for ( row = aDstRows - 1; row >= 0; row-- ) |
431 { |
411 { |
432 // read for cache |
|
433 //for ( col = aDstCols - 1; col >= 0; col-- ) TInt temp = p[ col ]; |
|
434 // Fill in the FIR first. |
412 // Fill in the FIR first. |
435 // TODO: Fill in with extrapolated values at edges! |
413 // TODO: Fill in with extrapolated values at edges |
436 FIRsum = ((KFIRLen / 2)<<21) | ((KFIRLen / 2)<<11) | (KFIRLen / 2); // for correct rounding |
414 FIRsum = ((KFIRLen / 2)<<21) | ((KFIRLen / 2)<<11) | (KFIRLen / 2); // for correct rounding |
437 i = 0; |
415 i = 0; |
438 TUint32 mask1 = mask32gbr655; |
416 TUint32 mask1 = mask32gbr655; |
439 for ( col = 0; col < KFIRLen; col++ ) |
417 for ( col = 0; col < KFIRLen; col++ ) |
440 { |
418 { |
490 p += aDstStridep; |
468 p += aDstStridep; |
491 } |
469 } |
492 } |
470 } |
493 } |
471 } |
494 // |
472 // |
495 // Keep below three defs in sync with each other! |
473 // NOTE: Keep below three defs in sync with each other |
496 #define KFIRLen4 4 |
474 #define KFIRLen4 4 |
497 #define KFIRCen4 (KFIRLen4 / 2) |
475 #define KFIRCen4 (KFIRLen4 / 2) |
498 #define incFIRIndex4( i ) i = (i + 1) & (KFIRLen4 - 1) |
476 #define incFIRIndex4( i ) i = (i + 1) & (KFIRLen4 - 1) |
499 // Keep above three defs in sync with each other! |
477 // NOTE: Keep above three defs in sync with each other |
500 |
478 |
501 void CGlxtnImageUtility::FIRFiltering4( |
479 void CGlxtnImageUtility::FIRFiltering4( |
502 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
480 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
503 { |
481 { |
504 TRACER("void CGlxtnImageUtility::FIRFiltering4()"); |
482 TRACER("void CGlxtnImageUtility::FIRFiltering4()"); |
510 TUint FIRsum; |
488 TUint FIRsum; |
511 // Horizontal scan. |
489 // Horizontal scan. |
512 p = aDst; |
490 p = aDst; |
513 for ( row = aDstRows - 1; row >= 0; row-- ) |
491 for ( row = aDstRows - 1; row >= 0; row-- ) |
514 { |
492 { |
515 // read for cache |
|
516 //for ( col = aDstCols - 1; col >= 0; col-- ) TInt temp = p[ col ]; |
|
517 // Fill in the FIR first. |
493 // Fill in the FIR first. |
518 // TODO: Fill in with extrapolated values at edges! |
494 // TODO: Fill in with extrapolated values at edges |
519 FIRsum = ((KFIRLen4 / 2)<<21) | ((KFIRLen4 / 2)<<11) | (KFIRLen4 / 2); // for correct rounding |
495 FIRsum = ((KFIRLen4 / 2)<<21) | ((KFIRLen4 / 2)<<11) | (KFIRLen4 / 2); // for correct rounding |
520 i = 0; |
496 i = 0; |
521 TUint32 mask1 = mask32gbr655; |
497 TUint32 mask1 = mask32gbr655; |
522 for ( col = 0; col < KFIRLen4; col++ ) |
498 for ( col = 0; col < KFIRLen4; col++ ) |
523 { |
499 { |
573 p += aDstStridep; |
549 p += aDstStridep; |
574 } |
550 } |
575 } |
551 } |
576 } |
552 } |
577 |
553 |
578 // Keep below three defs in sync with each other! |
554 // Keep below three defs in sync with each other |
579 #define KFIRLen8 8 |
555 #define KFIRLen8 8 |
580 #define KFIRCen8 (KFIRLen8 / 2) |
556 #define KFIRCen8 (KFIRLen8 / 2) |
581 #define incFIRIndex8( i ) i = (i + 1) & (KFIRLen8 - 1) |
557 #define incFIRIndex8( i ) i = (i + 1) & (KFIRLen8 - 1) |
582 // Keep above three defs in sync with each other! |
558 // Keep above three defs in sync with each other |
583 |
559 |
584 void CGlxtnImageUtility::FIRFiltering8( |
560 void CGlxtnImageUtility::FIRFiltering8( |
585 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
561 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ) |
586 { |
562 { |
587 TRACER("void CGlxtnImageUtility::FIRFiltering8()"); |
563 TRACER("void CGlxtnImageUtility::FIRFiltering8()"); |
593 TUint FIRsum; |
569 TUint FIRsum; |
594 // Horizontal scan. |
570 // Horizontal scan. |
595 p = aDst; |
571 p = aDst; |
596 for ( row = aDstRows - 1; row >= 0; row-- ) |
572 for ( row = aDstRows - 1; row >= 0; row-- ) |
597 { |
573 { |
598 // read for cache |
|
599 //for ( col = aDstCols - 1; col >= 0; col-- ) TInt temp = p[ col ]; |
|
600 // Fill in the FIR first. |
574 // Fill in the FIR first. |
601 // TODO: Fill in with extrapolated values at edges! |
575 // TODO: Fill in with extrapolated values at edges |
602 FIRsum = ((KFIRLen8 / 2)<<21) | ((KFIRLen8 / 2)<<11) | (KFIRLen8 / 2); // for correct rounding |
576 FIRsum = ((KFIRLen8 / 2)<<21) | ((KFIRLen8 / 2)<<11) | (KFIRLen8 / 2); // for correct rounding |
603 i = 0; |
577 i = 0; |
604 TUint32 mask1 = mask32gbr655; |
578 TUint32 mask1 = mask32gbr655; |
605 for ( col = 0; col < KFIRLen8; col++ ) |
579 for ( col = 0; col < KFIRLen8; col++ ) |
606 { |
580 { |