|
1 // Copyright (c) 2008-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 file contains declaration for image transform |
|
15 // Test Design: |
|
16 // Test Spec: |
|
17 // |
|
18 // |
|
19 |
|
20 #ifndef __IMAGETRANS_H__ |
|
21 #define __IMAGETRANS_H__ |
|
22 |
|
23 #include "e32base.h" |
|
24 #include "e32std.h" |
|
25 #include "e32cons.h" |
|
26 #include "e32cmn.h" |
|
27 #include "bacline.h" |
|
28 #include "f32file.h" |
|
29 #include <imagetransform.h> |
|
30 #include <imageconversion.h> |
|
31 #include <icl/squeezetransformextension.h> |
|
32 #include <icl/orientationtransformextension.h> |
|
33 #include <icl/overlaytransformextension.h> |
|
34 |
|
35 #ifndef EXIT_FAILURE /* define exit() codes if not provided */ |
|
36 #define EXIT_FAILURE 0 |
|
37 #endif |
|
38 #ifndef EXIT_SUCCESS /* define exit() codes if not provided */ |
|
39 #define EXIT_SUCCESS 1 |
|
40 #endif |
|
41 typedef enum |
|
42 { |
|
43 ITRAN_NONE, /* no transformation */ |
|
44 ITRAN_FLIP, |
|
45 ITRAN_ROTATE, |
|
46 ITRAN_TRANSPOSE, /* 90-degree rotation + horzontal flip */ |
|
47 ITRAN_TRANSVERSE, /* 270-degree rotation + horzontal flip */ |
|
48 ITRAN_OVERLAY, |
|
49 ITRAN_SQU, /* squeezing with proposed size */ |
|
50 ITRAN_AUTOSQU, /* autosqueezing with proposed size and resize action */ |
|
51 ITRAN_HELP /* help for the imagetran tool */ |
|
52 } ITRAN_CODES; |
|
53 |
|
54 typedef struct |
|
55 { |
|
56 ITRAN_CODES iTransform; |
|
57 TFileName iOutputfile; |
|
58 TFileName iInputfile; |
|
59 } ITRAN_CMD_INFO; |
|
60 |
|
61 _LIT8(KToolName, "imagetran"); |
|
62 const TInt KChunkDataOffset = 0; //the data offset from where the image frame starts |
|
63 const TUid KImageFramePluginUid = {0x101F7C60}; |
|
64 |
|
65 static ITRAN_CMD_INFO iTransOpt; // Transformation option |
|
66 |
|
67 class CActiveListener : public CActive |
|
68 { |
|
69 public: |
|
70 CActiveListener() : CActive(CActive::EPriorityIdle) { CActiveScheduler::Add(this); } |
|
71 void InitialiseActiveListener() { SetActive(); } |
|
72 // From CActive |
|
73 virtual void RunL() { CActiveScheduler::Stop(); } |
|
74 virtual void DoCancel() {}; |
|
75 }; |
|
76 |
|
77 class CActiveTransformListener : public CActiveListener |
|
78 { |
|
79 public: |
|
80 void InitialiseActiveListener(CImageTransform* aTransform) |
|
81 { |
|
82 iTransform = aTransform; |
|
83 CActiveListener::InitialiseActiveListener(); |
|
84 } |
|
85 // From CActive |
|
86 virtual void DoCancel() |
|
87 { |
|
88 if (iTransform) |
|
89 iTransform->CancelTransform(); |
|
90 } |
|
91 protected: |
|
92 CImageTransform* iTransform; |
|
93 }; |
|
94 |
|
95 class CITArgsandFuncts :public CBase |
|
96 { |
|
97 public: |
|
98 /* Constructor for parsing the command line arguments */ |
|
99 CITArgsandFuncts(){}; |
|
100 |
|
101 /* Create the CITArgsandFuncts object */ |
|
102 static CITArgsandFuncts* NewL(); |
|
103 void ConstructL(); |
|
104 |
|
105 /* Destrcutor */ |
|
106 ~CITArgsandFuncts(); |
|
107 |
|
108 /* Start the image transformation by parsing the commandline arguments */ |
|
109 void ImageTranMainL(); |
|
110 |
|
111 /*Receive Arguments and perform the operation based on the option */ |
|
112 void ImageTransformL(); |
|
113 |
|
114 /* Perform transformations squeeze,autosqueeze,rotation/flip,overlay, */ |
|
115 void Peform_TransformationL(); |
|
116 |
|
117 /* Usage of the Imagetran Command line tool */ |
|
118 void ImageTranUsage (); |
|
119 |
|
120 /* exit imagetran tool */ |
|
121 void ExitImageTranTool(); |
|
122 |
|
123 /* Parse switches */ |
|
124 void ParseSwitches (TInt aArgCount); |
|
125 |
|
126 /* Parsing squeeze transformation parameters */ |
|
127 TInt ParseSqueezeParams(TInt aArgNum); |
|
128 |
|
129 /* Parsing autosqueeze transformation parameters */ |
|
130 TInt ParseAutoSqueezeParams(TInt aArgNum); |
|
131 |
|
132 /* Parsing flip transformation parameters */ |
|
133 TInt ParseFlipParams(TInt aArgNum); |
|
134 |
|
135 /* Parsing Rotate transformation parameters */ |
|
136 TInt ParseRotateParams(TInt aArgNum); |
|
137 |
|
138 /* Parsing Transpose transformation parameters */ |
|
139 TInt ParseTransposeParams(TInt aArgNum); |
|
140 |
|
141 /* Parsing Transverse transformation parameters */ |
|
142 TInt ParseTransverseParams(TInt aArgNum); |
|
143 |
|
144 /* Parsing Overlay transformation parameters */ |
|
145 TInt ParseOverlayParams(TInt aArgNum); |
|
146 |
|
147 /* Parsing proposedsizeinbytes for squeeze & autosqueeze transformation */ |
|
148 TInt ParseProposedSize(TInt aArgNum); |
|
149 |
|
150 /* Parsing maximagesize for autosqueeze transformation */ |
|
151 TInt ParseMaxImageSize(TInt aArgNum); |
|
152 |
|
153 /* Parsing minimagesize for autosqueeze transformation */ |
|
154 TInt ParseMinImageSize(TInt aArgNum); |
|
155 |
|
156 /* Parsing squeeze options for autosqueeze transformation */ |
|
157 TInt ParseSqueezeOptions(TInt aArgNum); |
|
158 |
|
159 /* Parsing qualityfactor for autosqueeze transformation */ |
|
160 TInt ParseQualityFactor(TInt aArgNum); |
|
161 |
|
162 /* Parsing colormode(sampling) for autosqueeze tarnsformation */ |
|
163 TInt ParseColorMode(TInt aArgNum); |
|
164 |
|
165 /* Parsing flip options for flip transformation */ |
|
166 TInt ParseFlipOpt(TInt aArgNum); |
|
167 |
|
168 /* Parsing rotation angle for rotate transformation */ |
|
169 TInt ParseRotationAngle(TInt aArgNum); |
|
170 |
|
171 /* Parsing overlay position for overlay transformation */ |
|
172 TInt ParseOverlayPosition(TInt aArgNum); |
|
173 |
|
174 /* Parsing inputfile name for transformation */ |
|
175 TInt ParseInputFile(TInt aArgNum); |
|
176 |
|
177 /* Parsing outputfile name for transformation */ |
|
178 TInt ParseOutputFile(TInt aArgNum); |
|
179 |
|
180 /* Parsing overlayfile name for overlay transformation */ |
|
181 TInt ParseOverLayFile(TInt aArgNum); |
|
182 |
|
183 /*Case-insensitive matching of possibly-abbreviated keyword switches*/ |
|
184 TBool KeywordMatch (TPtrC aKeyMatch, const TDesC16& aKeyword, TInt aMinchars); |
|
185 |
|
186 /* Read next argument from commandline */ |
|
187 void ReadNextArg(TInt aArgNum); |
|
188 |
|
189 /* Get the input image size to valiadte MaxImagesize and MinImagesize against input image size */ |
|
190 void Fetch_ImageSize(); |
|
191 |
|
192 /* Validate imagesize to check it not a alphanumeric or alphabetic */ |
|
193 TUint ValidateImageSize(); |
|
194 |
|
195 /* To detect multiple transform options and set the transforma option slected */ |
|
196 void Select_Transform (ITRAN_CODES aTransform); |
|
197 |
|
198 /* Set source and destination file, squeeze option transformation, |
|
199 orientation uid for rotate,flip,transpose or transverse option */ |
|
200 void SetupTransformation (ITRAN_CODES aTransCode); |
|
201 |
|
202 /* Set extension, overlayfile and overlay position for overlay comamnd */ |
|
203 void SetupOverlayTrans(); |
|
204 |
|
205 |
|
206 private: |
|
207 CImageTransform* iImageTransform; |
|
208 CCommandLineArguments* iCmdArgs; // To hold teh command line args |
|
209 CConsoleBase* iConsole; // To print the messages on console |
|
210 TPtrC iOutputfile, iInputfile; // To hold the i/p and o/p files |
|
211 TPtrC iOverlayfile; // To hold the overlay file |
|
212 TFileName iToolName; // To hold the toolname for console messages purposes |
|
213 TBuf8<596> iArgBuf; // To hold all the comamnd line args in buffer |
|
214 TPtrC iArgumentPtr; // To extract the command line args |
|
215 TUint iProposedSize; // Proposed size for squeezing |
|
216 RFs iFs; |
|
217 TSize iInputImageSize; // Inputfile image size for validating max and min image size |
|
218 CSqueezeTransformExtension* iTransExtn; // Transofrmation extension such as squeeze, rotate, flip or overlay |
|
219 CActiveScheduler* iScheduler; |
|
220 TInt iColorMode; // If 0-420,1-422,2-444,3-411 colour samlping autosqueeze. This is an optional parameter. |
|
221 TBool iEndOfCmd; // If true-> end of cmd args reached, if false-> still cmd args are there |
|
222 TUid iSamplingUid; // Sampling uid based on clourmode for autosqueeze |
|
223 COrientationTransformExtension* iTransOrientation; // Transformation orientation for image like rotate,flip,transpose,transverse |
|
224 COverlayTransformExtension* iOverlayExtn; // OverLay extension for overlay transformation |
|
225 COrientationTransformExtension::TOrientation iOrientation; // Transformation orientation for image like rotate,flip,transpose,transverse |
|
226 TAdvancedSqueezeParams iSqueezeAutoResizeParams; // Provides advanced parameters for autosqueezing |
|
227 TPoint iPoint; |
|
228 }; |
|
229 #endif // __IMAGETRANS_H__ |