imagehandlinglib/Src/CIHLImageViewerExtJpg.h
changeset 54 48dd0f169f0d
parent 42 2e2a89493e2b
equal deleted inserted replaced
42:2e2a89493e2b 54:48dd0f169f0d
     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:  Implementation of Image Viewer class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CIHLIMAGEVIEWEREXTJPG_H
       
    20 #define CIHLIMAGEVIEWEREXTJPG_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "MIHLImageViewer.h"
       
    24 #include <e32base.h>
       
    25 
       
    26 //FORWARD DECLARATIONS
       
    27 class MIHLFileImageExtJpg;
       
    28 class MIHLBitmap;
       
    29 class MIHLViewerObserver;
       
    30 class CIHLBitmap;
       
    31 class CIHLBitmapProcessor;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 /**
       
    35 *  CIHLImageViewer
       
    36 *
       
    37 *  Image Viewer implementation class.
       
    38 *  @lib IHL.lib
       
    39 *  @since 3.0
       
    40 */
       
    41 NONSHARABLE_CLASS( CIHLImageViewerExtJpg ) : public CTimer, public MIHLImageViewer
       
    42     {
       
    43     public:  // Constructors and destructor
       
    44 
       
    45         /**
       
    46         * Two-phased constructor.
       
    47         */
       
    48         static CIHLImageViewerExtJpg* NewL( const TSize& aViewerSize,
       
    49 									  MIHLFileImageExtJpg& aSource,
       
    50 									  MIHLBitmap& aDestination,
       
    51 									  MIHLViewerObserver& aObserver,
       
    52 									  const TUint32 aOptions );
       
    53 
       
    54         /*
       
    55         * Virtual destructor.
       
    56         */
       
    57         virtual ~CIHLImageViewerExtJpg();
       
    58 
       
    59 	public: // From base class MIHLViewer
       
    60 		
       
    61 		  /*
       
    62         * From MIHLViewer, see base class header.
       
    63         */
       
    64 		TIHLInterfaceType Type() const;
       
    65 		
       
    66 	public:
       
    67 	
       
    68 		/*
       
    69         * From MIHLImageViewer, see base class header.
       
    70         */
       
    71 		TBool IsAnimation() const;
       
    72 
       
    73         /*
       
    74         * From MIHLImageViewer, see base class header.
       
    75         */
       
    76 		void Play();
       
    77 
       
    78         /*
       
    79         * From MIHLImageViewer, see base class header.
       
    80         */
       
    81 		void Stop();
       
    82 
       
    83         /*
       
    84         * From MIHLImageViewer, see base class header.
       
    85         */
       
    86 		TBool IsPlaying() const;
       
    87 
       
    88         /*
       
    89         * From MIHLImageViewer, see base class header.
       
    90         */
       
    91 		TInt AnimationFrameCount() const;
       
    92 
       
    93         /*
       
    94         * From MIHLImageViewer, see base class header.
       
    95         */
       
    96 		TInt AnimationFrame() const;
       
    97 
       
    98         /*
       
    99         * From MIHLImageViewer, see base class header.
       
   100         */
       
   101 		TInt SetAnimationFrame( TInt aFrameIndex );
       
   102 
       
   103         /*
       
   104         * From MIHLImageViewer, see base class header.
       
   105         */
       
   106 		TInt SetViewerSize( const TSize& aViewerSize, TInt srcBitmapScaleFactor = 1 );
       
   107 
       
   108         /*
       
   109         * From MIHLImageViewer, see base class header.
       
   110         */
       
   111 		TSize ViewerSize() const;
       
   112 
       
   113         /*
       
   114         * From MIHLImageViewer, see base class header.
       
   115         */
       
   116 		TInt MoveSourceRect( TInt aDx, TInt aDy );
       
   117 
       
   118         /*
       
   119         * From MIHLImageViewer, see base class header.
       
   120         */
       
   121 		TInt SetSourceRectPosition( const TPoint& aPosition );
       
   122 
       
   123         /*
       
   124         * From MIHLImageViewer, see base class header.
       
   125         */
       
   126 		TRect SourceRect() const;
       
   127 
       
   128         /*
       
   129         * From MIHLImageViewer, see base class header.
       
   130         */
       
   131 		TSize SourceSize() const;
       
   132 
       
   133         /*
       
   134         * From MIHLImageViewer, see base class header.
       
   135         */
       
   136 		TInt SetZoomRatio( TReal aZoomRatio );
       
   137 
       
   138         /*
       
   139         * From MIHLImageViewer, see base class header.
       
   140         */
       
   141 		TReal ZoomRatio() const;
       
   142 
       
   143         /*
       
   144         * From MIHLImageViewer, see base class header.
       
   145         */
       
   146 		TReal ZoomToFitRatio() const;
       
   147 
       
   148         /*
       
   149         * From MIHLImageViewer, see base class header.
       
   150         */
       
   151 		TInt RotateClockwise();
       
   152 
       
   153         /*
       
   154         * From MIHLImageViewer, see base class header.
       
   155         */
       
   156 		TInt RotateCounterClockwise();
       
   157 
       
   158         /*
       
   159         * From MIHLImageViewer, see base class header.
       
   160         */
       
   161 		TInt SetRotationAngle( TInt aRotationAngle );
       
   162 
       
   163         /*
       
   164         * From MIHLImageViewer, see base class header.
       
   165         */
       
   166 		TInt RotationAngle() const;
       
   167 
       
   168         /*
       
   169         * From MIHLImageViewer, see base class header.
       
   170         */
       
   171 		TInt SetVerticalMirroring( TBool aValue );
       
   172 
       
   173         /*
       
   174         * From MIHLImageViewer, see base class header.
       
   175         */
       
   176 		TBool VerticalMirroring() const;
       
   177 
       
   178         /*
       
   179         * From MIHLImageViewer, see base class header.
       
   180         */
       
   181 		TInt SetHorizontalMirroring( TBool aValue );
       
   182 
       
   183         /*
       
   184         * From MIHLImageViewer, see base class header.
       
   185         */
       
   186 		TBool HorizontalMirroring() const;
       
   187 
       
   188         /*
       
   189         * From MIHLImageViewer, see base class header.
       
   190         */
       
   191 		void SetFilter( MIHLFilter* aFilter );
       
   192 
       
   193 	public: 
       
   194 
       
   195       
       
   196 
       
   197 	public: // From base class CTimer
       
   198 		
       
   199 		/*
       
   200         * From CTimer, see base class header.
       
   201         */
       
   202 		void DoCancel();
       
   203 
       
   204         /*
       
   205         * From CTimer, see base class header.
       
   206         */
       
   207 		void RunL();
       
   208 
       
   209         /*
       
   210         * From CTimer, see base class header.
       
   211         */
       
   212 		TInt RunError( TInt aError );
       
   213       
       
   214 
       
   215 	private: // Private methods
       
   216 
       
   217         /*
       
   218         * Start asynchronous processing with new settings.
       
   219         * This is needed always when settings are changed.
       
   220         */
       
   221 		TInt ApplySettings();
       
   222 
       
   223         /*
       
   224         * Start load process source bitmap.
       
   225         */
       
   226 		TInt AsyncLoad();
       
   227 
       
   228         /*
       
   229         * Finish processing and notify client.
       
   230         */
       
   231 		TInt Finish();
       
   232 
       
   233         /*
       
   234         * Complete dummy request. This causes RunL() method to be called.
       
   235         * Needed by state machine.
       
   236         */
       
   237 		void SelfComplete();
       
   238 
       
   239         /*
       
   240         * Calculate source bitmap rectangle needed by processor.
       
   241         * Rectangle is affected by rotating and mirroring settings etc.
       
   242         */
       
   243 		TRect CalculateProcessSourceRect( const TSize& aSourceCacheSize );
       
   244 
       
   245         /*
       
   246         * Calculate destination bitmap rectangle needed by processor.
       
   247         * Rectangle is affected by rotating and mirroring settings etc.
       
   248         */
       
   249 		TRect CalculateProcessDestinationRect();
       
   250 
       
   251         /*
       
   252         * Calculate needed zoomratio for "fit-to-screen" zooming.
       
   253         */
       
   254 		void CalculateZoomToFitRatio();
       
   255 
       
   256         /*
       
   257         * Calculate source bitmap rectangle and destination bitmap size.
       
   258         * These values needs to be recalculated when rectangle setting is changed.
       
   259         */
       
   260 		void CalculateSourceRectAndDestinationSize();
       
   261 
       
   262         /*
       
   263         * Assert if source bitmap rectangle and destination bitmpa size are valid.
       
   264         * This method is called by CalculateSourceRectAndDestinationSize()
       
   265         */
       
   266 #ifdef _DEBUG
       
   267 		void AssertSourceRectAndDestinationSize();
       
   268 #endif
       
   269 
       
   270 	private: // Private constructors
       
   271 
       
   272         void ConstructL();
       
   273         CIHLImageViewerExtJpg( const TSize& aViewerSize,
       
   274 						 MIHLFileImageExtJpg& aSource,
       
   275 						 MIHLBitmap& aDestination,
       
   276 						 MIHLViewerObserver& aObserver,
       
   277 						 const TUint32 aOptions );
       
   278 
       
   279 	private: // Private data types
       
   280 
       
   281 		enum TViewerState
       
   282 			{
       
   283 			EInactive,
       
   284 			ELoad,
       
   285 			EProcess
       
   286 			};
       
   287 
       
   288 	private: // Data
       
   289 
       
   290 		// Viewer state
       
   291 		TViewerState iViewerState;
       
   292 
       
   293 		// Ref: Observers
       
   294 		MIHLViewerObserver& iObserver;
       
   295 
       
   296 		// Ref: Viewer source image
       
   297 		MIHLFileImageExtJpg& iSource;
       
   298 		TSize iSourceSize;
       
   299 		TRect iSourceRect;
       
   300 
       
   301 		// Ref: Viewer destination bitmap
       
   302 		MIHLBitmap& iDestination;
       
   303 		TSize iDestinationSize;
       
   304 
       
   305 		// Viewing settings
       
   306 		const TUint32 iOptions;
       
   307 		TSize iViewerSize;
       
   308 		TReal iZoomRatio;
       
   309 		TReal iZoomToFitRatio;
       
   310 		TInt iRotationAngle;
       
   311 		TBool iVerticalMirroring;
       
   312 		TBool iHorizontalMirroring;
       
   313 
       
   314 		// Decoder capabilities
       
   315 		TInt iCapabilities;
       
   316 		
       
   317 		// Internal processor flag
       
   318 		TBool iInternalProcessingNeeded;
       
   319 	
       
   320 		// Own: Bitmap caches
       
   321 		CIHLBitmap* iCacheSource;
       
   322 		CIHLBitmap* iCacheDestination;
       
   323 		// Own: Bitmap processor
       
   324 		CIHLBitmapProcessor* iProcessor;
       
   325 		// src bitmap scale factor
       
   326 		TInt iSrcBitmapScaleFactor;
       
   327 
       
   328     };
       
   329 
       
   330 #endif // CIHLIMAGEVIEWEREXTJPG_H
       
   331 
       
   332 // End of File