|
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 // Parsing functions for imagetran tool |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TImageTran.h" |
|
19 |
|
20 /* |
|
21 * Parsing squeeze transformation parameters |
|
22 */ |
|
23 TInt CITArgsandFuncts::ParseSqueezeParams(TInt aArgNum) |
|
24 { |
|
25 Select_Transform(ITRAN_SQU); |
|
26 /* To get the proposed size or inputfile or outputfile for squeeze */ |
|
27 do |
|
28 { |
|
29 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
30 { |
|
31 if(KeywordMatch(iArgumentPtr.Mid(1), _L("p"), 1)) //Proposedsizeinbytes |
|
32 { |
|
33 aArgNum = ParseProposedSize(aArgNum); |
|
34 } |
|
35 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
36 { |
|
37 aArgNum = ParseInputFile(aArgNum); |
|
38 } |
|
39 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
40 { |
|
41 aArgNum = ParseOutputFile(aArgNum); |
|
42 } |
|
43 else |
|
44 { |
|
45 /* unknown switch */ |
|
46 iConsole->Printf( _L( "Unknown parameter in the squeeze command\n") ); |
|
47 ImageTranUsage(); |
|
48 } |
|
49 } |
|
50 else |
|
51 { |
|
52 /* Missing parameters for squeeze command */ |
|
53 iConsole->Printf( _L( "Missing squeeze parameters in command\n") ); |
|
54 ExitImageTranTool(); |
|
55 } |
|
56 |
|
57 ReadNextArg(++aArgNum); |
|
58 if(aArgNum == iCmdArgs->Count()) |
|
59 { |
|
60 break; |
|
61 } |
|
62 } while(aArgNum < iCmdArgs->Count()); |
|
63 /* Validate required parameter for squeeze */ |
|
64 if(iProposedSize <= 0) |
|
65 { |
|
66 /* Missing parameters for squeeze command */ |
|
67 iConsole->Printf( _L( "Missing squeeze parameters in command\n") ); |
|
68 ExitImageTranTool(); |
|
69 } |
|
70 return aArgNum; |
|
71 } |
|
72 |
|
73 /* |
|
74 * Parsing autosqueeze transformation parameters |
|
75 */ |
|
76 TInt CITArgsandFuncts::ParseAutoSqueezeParams(TInt aArgNum) |
|
77 { |
|
78 Select_Transform(ITRAN_AUTOSQU); |
|
79 // To get the proposed size or inputfile or outputfile or maximagesize |
|
80 // or minimagesize for auto squeeze |
|
81 do |
|
82 { |
|
83 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
84 { |
|
85 if(KeywordMatch(iArgumentPtr.Mid(1), _L("p"), 1)) //Proposedsizeinbytes |
|
86 { |
|
87 aArgNum = ParseProposedSize(aArgNum); |
|
88 } |
|
89 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
90 { |
|
91 aArgNum = ParseInputFile(aArgNum); |
|
92 } |
|
93 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
94 { |
|
95 aArgNum = ParseOutputFile(aArgNum); |
|
96 } |
|
97 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("max"), 1)) //MaxImagesize |
|
98 { |
|
99 aArgNum = ParseMaxImageSize(aArgNum); |
|
100 } |
|
101 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("min"), 1)) //MinImagesize |
|
102 { |
|
103 aArgNum = ParseMinImageSize(aArgNum); |
|
104 } |
|
105 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("mode"), 1)) //SamplingMode |
|
106 { |
|
107 aArgNum = ParseColorMode(aArgNum); |
|
108 } |
|
109 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("q"), 1)) //Qualityfactor |
|
110 { |
|
111 aArgNum = ParseQualityFactor(aArgNum); |
|
112 } |
|
113 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("sqopt"), 1)) //Autosqueezeoption |
|
114 { |
|
115 aArgNum = ParseSqueezeOptions(aArgNum); |
|
116 } |
|
117 else |
|
118 { |
|
119 /* unknown switch */ |
|
120 iConsole->Printf( _L( "Unknown parameter in the autosqueeze command\n") ); |
|
121 ImageTranUsage(); |
|
122 } |
|
123 } |
|
124 else |
|
125 { |
|
126 /* Missing parameters for squeeze command */ |
|
127 iConsole->Printf( _L( "Missing autosqueeze parameters in command\n") ); |
|
128 ExitImageTranTool(); |
|
129 } |
|
130 ReadNextArg(++aArgNum); |
|
131 if(aArgNum == iCmdArgs->Count()) |
|
132 { |
|
133 break; |
|
134 } |
|
135 } while(aArgNum < iCmdArgs->Count()); |
|
136 /* Validate whether all the autosqueeze parameters are entered */ |
|
137 if(iProposedSize <= 0 || iSqueezeAutoResizeParams.iMaxImageSize.iWidth <= 0 || |
|
138 iSqueezeAutoResizeParams.iMaxImageSize.iHeight <= 0 || |
|
139 iSqueezeAutoResizeParams.iMinImageSize.iWidth <= 0 || |
|
140 iSqueezeAutoResizeParams.iMinImageSize.iHeight <= 0) |
|
141 { |
|
142 /* Missing parameters for squeeze command */ |
|
143 iConsole->Printf( _L( "Missing autosqueeze parameters in command\n") ); |
|
144 ExitImageTranTool(); |
|
145 } |
|
146 return aArgNum; |
|
147 } |
|
148 |
|
149 /* |
|
150 * Parsing flip transformation parameters |
|
151 */ |
|
152 TInt CITArgsandFuncts::ParseFlipParams(TInt aArgNum) |
|
153 { |
|
154 Select_Transform(ITRAN_FLIP); |
|
155 /* To flip horzontal or vertical for flip command */ |
|
156 do |
|
157 { |
|
158 if(iEndOfCmd) |
|
159 { |
|
160 iConsole->Printf(_L("Missing flipoption in flip command\n")); |
|
161 ImageTranUsage(); |
|
162 } |
|
163 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
164 { |
|
165 if(KeywordMatch(iArgumentPtr.Mid(1), _L("flipopt"), 1)) //Flipoption |
|
166 { |
|
167 aArgNum = ParseFlipOpt(aArgNum); |
|
168 } |
|
169 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
170 { |
|
171 aArgNum = ParseInputFile(aArgNum); |
|
172 } |
|
173 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
174 { |
|
175 aArgNum = ParseOutputFile(aArgNum); |
|
176 } |
|
177 else |
|
178 { |
|
179 /* unknown switch */ |
|
180 iConsole->Printf( _L( "Unknown parameter in the flip command\n") ); |
|
181 ImageTranUsage(); |
|
182 } |
|
183 } |
|
184 else |
|
185 { |
|
186 /* Missing parameters for flip command */ |
|
187 iConsole->Printf( _L( "Missing flip parameters in command\n") ); |
|
188 ExitImageTranTool(); |
|
189 } |
|
190 ReadNextArg(++aArgNum); |
|
191 if(aArgNum == iCmdArgs->Count()) |
|
192 { |
|
193 break; |
|
194 } |
|
195 } while(aArgNum < iCmdArgs->Count()); |
|
196 return aArgNum; |
|
197 } |
|
198 |
|
199 /* |
|
200 * Parsing Rotate transformation parameters |
|
201 */ |
|
202 TInt CITArgsandFuncts::ParseRotateParams(TInt aArgNum) |
|
203 { |
|
204 Select_Transform(ITRAN_ROTATE); |
|
205 /* To rotate 0,90,180,270 degrees for rotate command */ |
|
206 do |
|
207 { |
|
208 if(iEndOfCmd) |
|
209 { |
|
210 iConsole->Printf(_L("Missing rotation angle in rotate command\n")); |
|
211 ImageTranUsage(); |
|
212 } |
|
213 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
214 { |
|
215 if(KeywordMatch(iArgumentPtr.Mid(1), _L("ang"), 1)) //Rotationangle |
|
216 { |
|
217 aArgNum = ParseRotationAngle(aArgNum); |
|
218 } |
|
219 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
220 { |
|
221 aArgNum = ParseInputFile(aArgNum); |
|
222 } |
|
223 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
224 { |
|
225 aArgNum = ParseOutputFile(aArgNum); |
|
226 } |
|
227 else |
|
228 { |
|
229 /* unknown switch */ |
|
230 iConsole->Printf( _L( "Unknown parameter in the rotation command\n") ); |
|
231 ImageTranUsage(); |
|
232 } |
|
233 } |
|
234 else |
|
235 { |
|
236 /* Missing parameters for squeeze command */ |
|
237 iConsole->Printf( _L( "Missing rotation parameters in command\n") ); |
|
238 ExitImageTranTool(); |
|
239 } |
|
240 ReadNextArg(++aArgNum); |
|
241 if(aArgNum == iCmdArgs->Count()) |
|
242 { |
|
243 break; |
|
244 } |
|
245 } while(aArgNum < iCmdArgs->Count()); |
|
246 return aArgNum; |
|
247 } |
|
248 |
|
249 /* |
|
250 * Parsing transpose transformation parameters |
|
251 */ |
|
252 TInt CITArgsandFuncts::ParseTransposeParams(TInt aArgNum) |
|
253 { |
|
254 Select_Transform(ITRAN_TRANSPOSE); |
|
255 |
|
256 /* To flip horzontal or vertical for flip command */ |
|
257 do |
|
258 { |
|
259 |
|
260 if(iEndOfCmd) |
|
261 { |
|
262 iConsole->Printf(_L("Missing inputfile and outputfile in transverse command\n")); |
|
263 ImageTranUsage(); |
|
264 } |
|
265 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
266 { |
|
267 if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
268 { |
|
269 aArgNum = ParseInputFile(aArgNum); |
|
270 } |
|
271 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
272 { |
|
273 aArgNum = ParseOutputFile(aArgNum); |
|
274 } |
|
275 else |
|
276 { |
|
277 /* unknown switch */ |
|
278 iConsole->Printf( _L( "Unknown parameter in the transpose command\n") ); |
|
279 ImageTranUsage(); |
|
280 } |
|
281 iOrientation = COrientationTransformExtension::ETransposeOverMainDiagonal; |
|
282 } |
|
283 else |
|
284 { |
|
285 /* Missing parameters for squeeze command */ |
|
286 iConsole->Printf( _L( "Missing transpose parameters in command\n") ); |
|
287 ExitImageTranTool(); |
|
288 } |
|
289 ReadNextArg(++aArgNum); |
|
290 if(aArgNum == iCmdArgs->Count()) |
|
291 { |
|
292 break; |
|
293 } |
|
294 } while(aArgNum < iCmdArgs->Count()); |
|
295 return aArgNum; |
|
296 } |
|
297 |
|
298 /* |
|
299 * Parsing transpose transformation parameters |
|
300 */ |
|
301 TInt CITArgsandFuncts::ParseTransverseParams(TInt aArgNum) |
|
302 { |
|
303 Select_Transform(ITRAN_TRANSVERSE); |
|
304 |
|
305 /* To flip horzontal or vertical for flip command */ |
|
306 do |
|
307 { |
|
308 if(iEndOfCmd) |
|
309 { |
|
310 iConsole->Printf(_L("Missing inputfile and outputfile in transverse command\n")); |
|
311 ImageTranUsage(); |
|
312 } |
|
313 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
314 { |
|
315 if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
316 { |
|
317 aArgNum = ParseInputFile(aArgNum); |
|
318 } |
|
319 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
320 { |
|
321 aArgNum = ParseOutputFile(aArgNum); |
|
322 } |
|
323 else |
|
324 { |
|
325 /* unknown switch */ |
|
326 iConsole->Printf( _L( "Unknown parameter in the transverse command\n") ); |
|
327 ImageTranUsage(); |
|
328 } |
|
329 iOrientation = COrientationTransformExtension::ETransposeOverMinorDiagonal; |
|
330 } |
|
331 else |
|
332 { |
|
333 /* Missing parameters for squeeze command */ |
|
334 iConsole->Printf( _L( "Missing transverse parameters in command\n") ); |
|
335 ExitImageTranTool(); |
|
336 } |
|
337 ReadNextArg(++aArgNum); |
|
338 if(aArgNum == iCmdArgs->Count()) |
|
339 { |
|
340 break; |
|
341 } |
|
342 } while(aArgNum < iCmdArgs->Count()); |
|
343 return aArgNum; |
|
344 } |
|
345 /* |
|
346 * Parsing proposedsizeinbytes for squeeze & autosqueeze transformation |
|
347 */ |
|
348 TInt CITArgsandFuncts::ParseOverlayParams(TInt aArgNum) |
|
349 { |
|
350 Select_Transform(ITRAN_OVERLAY); |
|
351 |
|
352 /* To set overlay/replace image for overlay command */ |
|
353 do |
|
354 { |
|
355 if(iEndOfCmd) |
|
356 { |
|
357 iConsole->Printf(_L("Missing rotation angle in rotate command\n")); |
|
358 ImageTranUsage(); |
|
359 } |
|
360 if (iArgumentPtr.Left(1).Compare(_L("-")) == 0) |
|
361 { |
|
362 if(KeywordMatch(iArgumentPtr.Mid(1), _L("pos"), 1)) //Rotationangle |
|
363 { |
|
364 aArgNum = ParseOverlayPosition(aArgNum); |
|
365 } |
|
366 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("i"), 1)) //Inputfile |
|
367 { |
|
368 aArgNum = ParseInputFile(aArgNum); |
|
369 } |
|
370 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("o"), 1)) //Outputfile |
|
371 { |
|
372 aArgNum = ParseOutputFile(aArgNum); |
|
373 } |
|
374 else if(KeywordMatch(iArgumentPtr.Mid(1), _L("ovl"), 1)) //Outputfile |
|
375 { |
|
376 aArgNum = ParseOverLayFile(aArgNum); |
|
377 } |
|
378 else |
|
379 { |
|
380 /* unknown switch */ |
|
381 iConsole->Printf( _L( "Unknown parameter in the rotation command\n") ); |
|
382 ImageTranUsage(); |
|
383 } |
|
384 } |
|
385 else |
|
386 { |
|
387 /* Missing parameters for squeeze command */ |
|
388 iConsole->Printf( _L( "Missing rotation parameters in command\n") ); |
|
389 ExitImageTranTool(); |
|
390 } |
|
391 ReadNextArg(++aArgNum); |
|
392 if(aArgNum == iCmdArgs->Count()) |
|
393 { |
|
394 break; |
|
395 } |
|
396 } while(aArgNum < iCmdArgs->Count()); |
|
397 return aArgNum; |
|
398 } |
|
399 |
|
400 /* |
|
401 * Parsing proposedsizeinbytes for squeeze & autosqueeze transformation |
|
402 */ |
|
403 TInt CITArgsandFuncts::ParseProposedSize(TInt aArgNum) |
|
404 { |
|
405 ReadNextArg(++aArgNum); |
|
406 if(iEndOfCmd) |
|
407 { |
|
408 iConsole->Printf(_L("Missing proposedsizeinbytes in squeeze/autosqueeze command\n")); |
|
409 ExitImageTranTool(); |
|
410 } |
|
411 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
412 { |
|
413 /* Validate whether its a valid numeric number or not */ |
|
414 iProposedSize = ValidateImageSize(); |
|
415 } |
|
416 else |
|
417 { |
|
418 iConsole->Printf(_L("Missing proposedsizeinbytes in squeeze/autosqueeze command\n")); |
|
419 ExitImageTranTool(); |
|
420 } |
|
421 return aArgNum; |
|
422 } |
|
423 |
|
424 /* |
|
425 * Parsing maximagesize for autosqueeze transformation |
|
426 */ |
|
427 TInt CITArgsandFuncts::ParseMaxImageSize(TInt aArgNum) |
|
428 { |
|
429 ReadNextArg(++aArgNum); |
|
430 if(iEndOfCmd) |
|
431 { |
|
432 iConsole->Printf(_L("Missing maximagesize in autosqueeze command\n")); |
|
433 ImageTranUsage(); |
|
434 } |
|
435 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
436 { |
|
437 /*validate whether its a valid MaxImagesize or not*/ |
|
438 iSqueezeAutoResizeParams.iMaxImageSize.iWidth = ValidateImageSize(); |
|
439 |
|
440 ReadNextArg(++aArgNum); |
|
441 if(iEndOfCmd) |
|
442 { |
|
443 iConsole->Printf(_L("Missing maximageheight in autosqueeze command\n")); |
|
444 ImageTranUsage(); |
|
445 } |
|
446 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
447 { |
|
448 /*validate whether its a valid MaxImagesize or not*/ |
|
449 iSqueezeAutoResizeParams.iMaxImageSize.iHeight = ValidateImageSize(); |
|
450 } |
|
451 else |
|
452 { |
|
453 iConsole->Printf(_L("Missing maximageheight in autosqueeze command\n")); |
|
454 ExitImageTranTool(); |
|
455 } |
|
456 } |
|
457 else |
|
458 { |
|
459 iConsole->Printf(_L("Missing maximagewidth in autosqueeze command\n")); |
|
460 ExitImageTranTool(); |
|
461 } |
|
462 return aArgNum; |
|
463 } |
|
464 |
|
465 /* |
|
466 * Parsing minimagesize for autosqueeze transformation |
|
467 */ |
|
468 TInt CITArgsandFuncts::ParseMinImageSize(TInt aArgNum) |
|
469 { |
|
470 ReadNextArg(++aArgNum); |
|
471 if(iEndOfCmd) |
|
472 { |
|
473 iConsole->Printf(_L("Missing minimagesize in autosqueeze command\n")); |
|
474 ImageTranUsage(); |
|
475 } |
|
476 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
477 { |
|
478 /* Validate whether its a valid MinImagesize or not */ |
|
479 iSqueezeAutoResizeParams.iMinImageSize.iWidth = ValidateImageSize(); |
|
480 |
|
481 ReadNextArg(++aArgNum); |
|
482 if(iEndOfCmd) |
|
483 { |
|
484 iConsole->Printf(_L("Missing minimageheight in autosqueeze command\n")); |
|
485 ImageTranUsage(); |
|
486 } |
|
487 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
488 { |
|
489 /* Validate whether its a valid MinImagesize or not */ |
|
490 iSqueezeAutoResizeParams.iMinImageSize.iHeight = ValidateImageSize(); |
|
491 } |
|
492 else |
|
493 { |
|
494 iConsole->Printf(_L("Missing minimageheight in autosqueeze command\n")); |
|
495 ExitImageTranTool(); |
|
496 } |
|
497 } |
|
498 else |
|
499 { |
|
500 iConsole->Printf(_L("Missing minimagewidth in autosqueeze command\n")); |
|
501 ExitImageTranTool(); |
|
502 } |
|
503 return aArgNum; |
|
504 } |
|
505 |
|
506 /* |
|
507 * Parsing squeeze options for autosqueeze transformation |
|
508 * Squeeze options are |
|
509 * PreserveSourceEncodingQuality |
|
510 * PrioritizeLargeImageSize |
|
511 * ResizePrioritizeHighEncodingQuality |
|
512 * MiddleCourse |
|
513 */ |
|
514 TInt CITArgsandFuncts::ParseSqueezeOptions(TInt aArgNum) |
|
515 { |
|
516 /* to get autosqueeze option. */ |
|
517 ReadNextArg(++aArgNum); |
|
518 if(iEndOfCmd) |
|
519 { |
|
520 iConsole->Printf(_L("Missing autosqueezeoption in autosqueeze command\n")); |
|
521 ImageTranUsage(); |
|
522 } |
|
523 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
524 { |
|
525 /* Validate whether its a valid numeric or not */ |
|
526 iSqueezeAutoResizeParams.iResizeAction = ValidateImageSize(); |
|
527 if(iSqueezeAutoResizeParams.iResizeAction < 0 || iSqueezeAutoResizeParams.iResizeAction > 3) |
|
528 { |
|
529 iConsole->Printf(_L("UnKnow autosqueezeoption in autosqueeze command\n")); |
|
530 ImageTranUsage(); |
|
531 } |
|
532 } |
|
533 else |
|
534 { |
|
535 iConsole->Printf(_L("Missing autosqueezeoption in autosqueeze command\n")); |
|
536 ExitImageTranTool(); |
|
537 } |
|
538 return aArgNum; |
|
539 } |
|
540 |
|
541 /* |
|
542 * Parsing qualityfactor for autosqueeze transformation |
|
543 * Must be in the range (0.0) to (1.0) |
|
544 */ |
|
545 TInt CITArgsandFuncts::ParseQualityFactor(TInt aArgNum) |
|
546 { |
|
547 ReadNextArg(++aArgNum); |
|
548 if(iEndOfCmd) |
|
549 { |
|
550 iConsole->Printf(_L("Missing qualityfactor in autosqueeze command\n")); |
|
551 ExitImageTranTool(); |
|
552 } |
|
553 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
554 { |
|
555 TLex lLex(iArgumentPtr); |
|
556 lLex.Val(iSqueezeAutoResizeParams.iMinEncodingQuality); |
|
557 if(iSqueezeAutoResizeParams.iMinEncodingQuality < 0.0 || iSqueezeAutoResizeParams.iMinEncodingQuality > 1.0) |
|
558 { |
|
559 iConsole->Printf(_L("Qulaityfactor for autosqueeze is not within the range 0.0 to 1.0\n")); |
|
560 ExitImageTranTool(); |
|
561 } |
|
562 } |
|
563 else |
|
564 { |
|
565 iConsole->Printf(_L("Missing qualityfactor in autosqueeze command\n")); |
|
566 ExitImageTranTool(); |
|
567 } |
|
568 return aArgNum; |
|
569 } |
|
570 |
|
571 /* |
|
572 * Parsing colormode(sampling) for autosqueeze tarnsformation |
|
573 */ |
|
574 TInt CITArgsandFuncts::ParseColorMode(TInt aArgNum) |
|
575 { |
|
576 ReadNextArg(++aArgNum); |
|
577 if(iEndOfCmd) |
|
578 { |
|
579 iConsole->Printf(_L("Missing samplingmode in autosqueeze command\n")); |
|
580 ImageTranUsage(); |
|
581 } |
|
582 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
583 { |
|
584 /* Validate whether its a valid numeric or not */ |
|
585 iColorMode = ValidateImageSize(); |
|
586 if(iColorMode == 0) |
|
587 { |
|
588 iSqueezeAutoResizeParams.iSamplingUid = KUidSamplingColor420; |
|
589 } |
|
590 else if(iColorMode == 1) |
|
591 { |
|
592 iSqueezeAutoResizeParams.iSamplingUid = KUidSamplingColor422; |
|
593 } |
|
594 else if(iColorMode == 2) |
|
595 { |
|
596 iSqueezeAutoResizeParams.iSamplingUid = KUidSamplingColor444; |
|
597 } |
|
598 else if(iColorMode == 3) |
|
599 { |
|
600 iSqueezeAutoResizeParams.iSamplingUid = KUidSamplingColor411; |
|
601 } |
|
602 else |
|
603 { |
|
604 iConsole->Printf(_L("Unknow samplingmode in autosqueeze command\n")); |
|
605 ImageTranUsage(); |
|
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 iConsole->Printf(_L("Missing samplingmode in autosqueeze command\n")); |
|
611 ExitImageTranTool(); |
|
612 } |
|
613 return aArgNum; |
|
614 } |
|
615 |
|
616 /* |
|
617 * Parsing flip options for flip transformation |
|
618 * flip options are |
|
619 * horizontal |
|
620 * vertical |
|
621 */ |
|
622 TInt CITArgsandFuncts::ParseFlipOpt(TInt aArgNum) |
|
623 { |
|
624 ReadNextArg(++aArgNum); |
|
625 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
626 { |
|
627 if(KeywordMatch(iArgumentPtr, _L("horizontal"), 1)) //Fliphorizontal |
|
628 { |
|
629 iOrientation = COrientationTransformExtension::EMirrorHorizontalAxis; |
|
630 } |
|
631 else if(KeywordMatch(iArgumentPtr, _L("vertical"), 1)) //Flipvertical |
|
632 { |
|
633 iOrientation = COrientationTransformExtension::EMirrorVerticalAxis; |
|
634 } |
|
635 else |
|
636 { |
|
637 /* unknown flip option */ |
|
638 iConsole->Printf( _L( "Unknown flip option in the command\n") ); |
|
639 ImageTranUsage(); |
|
640 } |
|
641 } |
|
642 else |
|
643 { |
|
644 iConsole->Printf(_L("Missing flipoption in flip command\n")); |
|
645 ExitImageTranTool(); |
|
646 } |
|
647 return aArgNum; |
|
648 } |
|
649 |
|
650 /* |
|
651 * Parsing rotation angle for rotate transformation |
|
652 * rotation angles are |
|
653 * 0,90,180,270 degrees |
|
654 */ |
|
655 TInt CITArgsandFuncts::ParseRotationAngle(TInt aArgNum) |
|
656 { |
|
657 ReadNextArg(++aArgNum); |
|
658 if(iEndOfCmd) |
|
659 { |
|
660 iConsole->Printf(_L("Missing rotation angle in rotation command\n")); |
|
661 ExitImageTranTool(); |
|
662 } |
|
663 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
664 { |
|
665 if (KeywordMatch(iArgumentPtr,_L("0"), 2)) |
|
666 { |
|
667 iOrientation = COrientationTransformExtension::ERotationNone; |
|
668 } |
|
669 else if (KeywordMatch(iArgumentPtr,_L("90"), 2)) |
|
670 { |
|
671 iOrientation = COrientationTransformExtension::ERotation90DegreesClockwise; |
|
672 } |
|
673 else if (KeywordMatch(iArgumentPtr,_L("180"), 3)) |
|
674 { |
|
675 iOrientation = COrientationTransformExtension::ERotation180DegreesClockwise; |
|
676 } |
|
677 else if (KeywordMatch(iArgumentPtr,_L("270"), 3)) |
|
678 { |
|
679 iOrientation = COrientationTransformExtension::ERotation270DegreesClockwise; |
|
680 } |
|
681 else |
|
682 { |
|
683 /* unknown flip option */ |
|
684 iConsole->Printf( _L( "Unknown rotation angle in the rotation command\n") ); |
|
685 ImageTranUsage(); |
|
686 } |
|
687 } |
|
688 else |
|
689 { |
|
690 iConsole->Printf(_L("Missing rotationangle in rotate command\n")); |
|
691 ExitImageTranTool(); |
|
692 } |
|
693 return aArgNum; |
|
694 } |
|
695 |
|
696 /* |
|
697 * Parsing overlay position for overlay transformation |
|
698 */ |
|
699 TInt CITArgsandFuncts::ParseOverlayPosition(TInt aArgNum) |
|
700 { |
|
701 ReadNextArg(++aArgNum); |
|
702 if(iEndOfCmd) |
|
703 { |
|
704 iConsole->Printf(_L("Missing overlay position in overlay command command\n")); |
|
705 ImageTranUsage(); |
|
706 } |
|
707 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
708 { |
|
709 /*validate whether its a valid X point or not*/ |
|
710 iPoint.iX = ValidateImageSize(); |
|
711 |
|
712 ReadNextArg(++aArgNum); |
|
713 if(iEndOfCmd) |
|
714 { |
|
715 iConsole->Printf(_L("Missing X point in overlay command\n")); |
|
716 ExitImageTranTool(); |
|
717 } |
|
718 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
719 { |
|
720 /*validate whether its a valid MaxImagesize or not*/ |
|
721 iPoint.iY = ValidateImageSize(); |
|
722 } |
|
723 else |
|
724 { |
|
725 iConsole->Printf(_L("Missing Y point in overlay command\n")); |
|
726 ExitImageTranTool(); |
|
727 } |
|
728 } |
|
729 else |
|
730 { |
|
731 iConsole->Printf(_L("Missing overlay position in overlay command\n")); |
|
732 ExitImageTranTool(); |
|
733 } |
|
734 return aArgNum; |
|
735 } |
|
736 /* |
|
737 * Parsing inputfile name for transformation |
|
738 */ |
|
739 TInt CITArgsandFuncts::ParseInputFile(TInt aArgNum) |
|
740 { |
|
741 ReadNextArg(++aArgNum); |
|
742 if(iEndOfCmd) |
|
743 { |
|
744 iConsole->Printf(_L("Missing inputfile in command\n")); |
|
745 ExitImageTranTool(); |
|
746 } |
|
747 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
748 { |
|
749 /* Set input file */ |
|
750 iInputfile.Set(iArgumentPtr); |
|
751 } |
|
752 else |
|
753 { |
|
754 iConsole->Printf(_L("Missing inputfile in command\n")); |
|
755 ExitImageTranTool(); |
|
756 } |
|
757 return aArgNum; |
|
758 } |
|
759 |
|
760 /* |
|
761 * Parsing outputfile name for transformation |
|
762 */ |
|
763 TInt CITArgsandFuncts::ParseOutputFile(TInt aArgNum) |
|
764 { |
|
765 ReadNextArg(++aArgNum); |
|
766 |
|
767 if(iEndOfCmd) |
|
768 { |
|
769 iConsole->Printf(_L("Missing outputfile in command\n")); |
|
770 ExitImageTranTool(); |
|
771 } |
|
772 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
773 { |
|
774 /* Set output file */ |
|
775 iOutputfile.Set(iArgumentPtr); |
|
776 } |
|
777 else |
|
778 { |
|
779 iConsole->Printf(_L("Missing outputfile in command\n")); |
|
780 ExitImageTranTool(); |
|
781 } |
|
782 return aArgNum; |
|
783 } |
|
784 |
|
785 /* |
|
786 * Parsing outputfile name for transformation |
|
787 */ |
|
788 TInt CITArgsandFuncts::ParseOverLayFile(TInt aArgNum) |
|
789 { |
|
790 ReadNextArg(++aArgNum); |
|
791 |
|
792 if(iEndOfCmd) |
|
793 { |
|
794 iConsole->Printf(_L("Missing overlayfile in command\n")); |
|
795 ExitImageTranTool(); |
|
796 } |
|
797 if (iArgumentPtr.Left(1).Compare(_L("-")) != 0) |
|
798 { |
|
799 /* Set output file */ |
|
800 iOverlayfile.Set(iArgumentPtr); |
|
801 } |
|
802 else |
|
803 { |
|
804 iConsole->Printf(_L("Missing overlayfile in command\n")); |
|
805 ExitImageTranTool(); |
|
806 } |
|
807 return aArgNum; |
|
808 } |