imagingandcamerafws/imagingfws/GifScaler/src/GifScalerBody.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2003-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 // This is the implementation of the GifScaler Library
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __GIFSCALERBODY_H__
       
    19 #define __GIFSCALERBODY_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <fbs.h>
       
    23 #include <bitmaptransforms.h>
       
    24 
       
    25 #include "gifscaler.h" // Required for enums.
       
    26 
       
    27 // Color quantizer class.
       
    28 class CColorQuantizer;
       
    29 
       
    30 /**
       
    31 *
       
    32 * The private API for clients to call the GifScaler Library scaling and color quantization.
       
    33 * @internalTechnology
       
    34 *
       
    35 */
       
    36 
       
    37 /**
       
    38 *
       
    39 * Body of CGifScaler
       
    40 *
       
    41 * @internalTechnology
       
    42 *
       
    43 */
       
    44 
       
    45 NONSHARABLE_CLASS( CGifScaler::CBody ): public CActive
       
    46 	{
       
    47 	friend class CGifScaler;
       
    48 public:
       
    49 	// Current state.
       
    50 	enum TScaleState
       
    51 		{
       
    52 		EInactiveState,					// Scaling is inactive.
       
    53 		EScalingState,					// Scaling the image only.
       
    54 		EStartColorQuantization,		// Starting the color quantization.
       
    55 		ECleanUpPending,				// Scaling etc. complete, so start cleanup.
       
    56 		ECleanUpState,					// Cleaning up.
       
    57 		EScalingComplete				// All operations complete.
       
    58 		};
       
    59 
       
    60 private:
       
    61 	static CBody* NewL(CFbsBitmap& aSource, CFbsBitmap* aSourceMask, CGifScaler::TOptions aOptions);
       
    62 	~CBody();
       
    63 
       
    64 	void Scale(TRequestStatus* aStatus, CFbsBitmap& aDestination, CPalette& aPalette, TBool aMaintainAspectRatio);
       
    65 	void Scale(TRequestStatus* aStatus, CFbsBitmap& aDestination, CPalette& aPalette, TUint8 aTransparencyThreshold, TBool aMaintainAspectRatio);
       
    66 
       
    67 	// From CActive
       
    68 	void RunL();
       
    69 	TInt RunError(TInt aError);
       
    70 	void DoCancel();
       
    71 
       
    72 	// New fns.
       
    73 	CBody(CFbsBitmap& aSource, CFbsBitmap* aSourceMask, CGifScaler::TOptions aOptions);
       
    74 	void ConstructL();
       
    75 
       
    76 	// Cleanup fn.
       
    77 	// Used after scaling is complete.
       
    78 	void CleanUp();
       
    79 	
       
    80 	// Complete scaling.
       
    81 	void RequestComplete(TInt aReason);
       
    82 
       
    83 	// Complete current state.
       
    84 	void SelfComplete(TInt aReason);
       
    85 
       
    86 private:
       
    87 	// Source bitmap. (not owned)
       
    88 	CFbsBitmap& iSource;
       
    89 
       
    90 	// Source bitmap mask. (not owned)
       
    91 	CFbsBitmap* iSourceMask;
       
    92 
       
    93 	// Intermediate bitmap. (owned)
       
    94 	CFbsBitmap* iIntermediate;
       
    95 
       
    96 	// Destination bitmap. (not owned)
       
    97 	CFbsBitmap* iDestination;
       
    98 
       
    99 	// Destination mask bitmap. (owned)
       
   100 	CFbsBitmap* iDestinationMask;
       
   101 
       
   102 	// Scaling and color quantization options.
       
   103 	CGifScaler::TOptions iOptions;
       
   104 
       
   105 	// MaintainAspectRatio.
       
   106 	TBool iMaintainAspectRatio;
       
   107 
       
   108 	// Bitmap scaler. (owned)
       
   109 	CBitmapScaler* iBitmapScaler;
       
   110 	
       
   111 	// Request status to signal when done. (not owned)
       
   112 	TRequestStatus* iRequestStatus;
       
   113 
       
   114 	// Current state.
       
   115 	TScaleState iCurrentState;
       
   116 
       
   117 	// Tranparency indices.
       
   118 	TUint8 iTransparencyIndex;
       
   119 	TUint8 iReplacementIndex;
       
   120 	TUint8 iTransparencyThreshold;
       
   121 
       
   122 	// Color quantizer. (owned)
       
   123 	CColorQuantizer* iColorQuantizer;
       
   124 
       
   125 	// Output palette. (not owned)
       
   126 	CPalette *iPalette;
       
   127 	};
       
   128 
       
   129 #endif  // __GIFSCALERBODY_H__
       
   130