imaging/imagingfws/ImageDisplay/plugins/Exif/ExifImageDisplay.cpp
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /** 	@file
       
    17 	@internalComponent */
       
    18 #include <iclexif.h>
       
    19 #include <exifutility.h>
       
    20 #include <icl/icl_uids.hrh>
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <icl/icl_uids_const.hrh>
       
    23 #include <icl/icl_uids_def.hrh>
       
    24 #endif
       
    25 #include "ExifImageDisplayPanic.h"
       
    26 
       
    27 #include "ExifImageDisplay.h"
       
    28 
       
    29 _LIT(KExifPanicCat, "ExifImageDisplay");
       
    30 
       
    31 CExifImageDisplayPlugin* CExifImageDisplayPlugin::NewL()
       
    32 	{
       
    33 	CExifImageDisplayPlugin* self = new(ELeave) CExifImageDisplayPlugin();
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 CExifImageDisplayPlugin::~CExifImageDisplayPlugin()
       
    41 	{
       
    42 	}
       
    43 
       
    44 CExifImageDisplayPlugin::CExifImageDisplayPlugin():
       
    45 							CGenericImageDisplayPlugin(KExifPanicCat)
       
    46 	{
       
    47 	iMaxUnscaledSize.SetSize(160,120);
       
    48 	iMaxReductionFactor = KMaxReductionFactor;
       
    49 	}
       
    50 
       
    51 void CExifImageDisplayPlugin::AfterOpenL()
       
    52 	{
       
    53 	GetExifMetadataReader(iExifReader);
       
    54 	}
       
    55 
       
    56 TInt CExifImageDisplayPlugin::ExtensionInterface(TUid aIFaceUid, TAny*& aIFacePtr)
       
    57 	{
       
    58 	if (KErrNone == CGenericImageDisplayPlugin::ExtensionInterface(aIFaceUid, aIFacePtr))
       
    59 		{
       
    60 		return KErrNone;
       
    61 		}
       
    62 	if (aIFaceUid != KExifImageDisplayExtensionUid)
       
    63 		{
       
    64 		return KErrNotSupported;
       
    65 		}
       
    66 	aIFacePtr = static_cast<MExifImageDisplayExtension*>(this);
       
    67 	return KErrNone;
       
    68 	}
       
    69 
       
    70 TUint CExifImageDisplayPlugin::ImageStatus() const
       
    71 	{
       
    72 	return CImageDisplay::EImageSingleFrame | (ThumbnailExists()?CImageDisplay::EImageHasThumbnail:0);
       
    73 	}
       
    74 
       
    75 TInt CExifImageDisplayPlugin::GetExifMetadataReader(MExifMetadataReader*& aPtr)
       
    76 	{
       
    77 	// it should be safe since we've asked for EXIF decoder during decoder creation
       
    78 	aPtr=static_cast<CJPEGExifDecoder*>(iDecoder)->ExifMetadata();
       
    79 	return (aPtr==NULL)? KErrNotSupported : KErrNone;
       
    80 	}
       
    81 
       
    82 const TUid CExifImageDisplayPlugin::Uid() const
       
    83 	{
       
    84 	return KExifImageDisplayExtensionUid;
       
    85 	}
       
    86 
       
    87 void CExifImageDisplayPlugin::Release()
       
    88 	{
       
    89 	}
       
    90 	
       
    91 TInt CExifImageDisplayPlugin::SetScaleQuality(TInt aQualityLevel)
       
    92 	{
       
    93 	return DoSetScaleQuality(aQualityLevel);
       
    94 	}
       
    95 	
       
    96 TInt CExifImageDisplayPlugin::SetMaximumReductionFactor(TInt aMaxReductionFactor)
       
    97 	{
       
    98 	return DoSetMaximumReductionFactor(aMaxReductionFactor);
       
    99 	}
       
   100 
       
   101 TBool CExifImageDisplayPlugin::ThumbnailExists() const
       
   102 	{
       
   103 	if (iExifReader==NULL)
       
   104 		{
       
   105 		return EFalse;
       
   106 		}
       
   107 	TExifReaderUtility util(iExifReader);
       
   108 	TUint16 dummy;
       
   109 	return (KErrNone == util.GetThumbCompression(dummy));
       
   110 	}
       
   111 
       
   112 TUint CExifImageDisplayPlugin::EffectiveRotation() const
       
   113 	{
       
   114 	TUint rotation=Options() & ( CImageDisplay::EOptionMirrorVertical |
       
   115 			(CImageDisplay::EOptionMirrorVertical - CImageDisplay::EOptionRotateCw90) );
       
   116 
       
   117 // calculate autorotation option for main image
       
   118 	if ( (Options() & CImageDisplay::EOptionAutoRotate) && iExifReader)
       
   119 		{
       
   120 		TExifReaderUtility utility(iExifReader);
       
   121 		TUint16 orientation(0);
       
   122 		TInt err=KErrNotFound;
       
   123 		if (ThumbnailRequested())
       
   124 			{
       
   125 			err=utility.GetThumbOrientation(orientation);
       
   126 			}
       
   127 		if (err!=KErrNone)
       
   128 			{
       
   129 			err = utility.GetOrientation(orientation);
       
   130 			}
       
   131 		if (KErrNone == err && orientation>0 && orientation<9)
       
   132 			{
       
   133 			// auto-rotation table using the EXIF 2.2 page 18
       
   134 			static const TUint 
       
   135 			KOrientation2Rotation[8]=	{
       
   136 										0, // 1
       
   137 										CImageDisplay::EOptionMirrorVertical, // 2
       
   138 										CImageDisplay::EOptionRotateCw180, // 3
       
   139 										CImageDisplay::EOptionMirrorHorizontal,	// 4
       
   140 										CImageDisplay::EOptionRotateCw90|CImageDisplay::EOptionMirrorVertical,		// 5
       
   141 										CImageDisplay::EOptionRotateCw90,		// 6
       
   142 										CImageDisplay::EOptionRotateCw270|CImageDisplay::EOptionMirrorVertical,		// 7
       
   143 										CImageDisplay::EOptionRotateCw270,		// 8
       
   144 										};
       
   145 			rotation = KOrientation2Rotation[orientation-1];
       
   146 			}
       
   147 		}
       
   148 	return rotation;
       
   149 	}
       
   150 
       
   151 TUid CExifImageDisplayPlugin::RequiredImageClass() const
       
   152 	{
       
   153 	return TUid::Uid(KUidICLJpegEXIFInterface);
       
   154 	}
       
   155