|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef JPEGROTATOR_H |
|
21 #define JPEGROTATOR_H |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CJpegRotatorImpl; |
|
31 class RFs; |
|
32 |
|
33 |
|
34 /* CLASS: MJpegRotatorObserver |
|
35 * |
|
36 * Observer interface, which can be optionally implemented |
|
37 * to receive progress information during the image rotation |
|
38 * (in block mode only). |
|
39 * |
|
40 */ |
|
41 class MJpegRotatorObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Informs the caller that one set of image data blocks has been |
|
47 * processed, so the progress bar should be incremented. |
|
48 * The size of the progress increment is returned by RotateImageL |
|
49 * |
|
50 * @param - |
|
51 * @param - |
|
52 */ |
|
53 virtual void Increment() = 0; |
|
54 }; |
|
55 |
|
56 |
|
57 |
|
58 /* CLASS: CJpegRotator |
|
59 * |
|
60 * Rotates an image in 90 degrees steps. |
|
61 * Available rotation modes: |
|
62 * |
|
63 * - ERotModeCounterClockwise, |
|
64 * - ERotModeClockwise, |
|
65 * - ERotMode90, |
|
66 * - ERotMode180, |
|
67 * - ERotMode270 |
|
68 * |
|
69 * |
|
70 * USAGE |
|
71 * |
|
72 * Example 1: asynchronous rotate |
|
73 * |
|
74 * iJpegRotator = CJpegRotator::NewL( iEikonEnv->FsSession() ); |
|
75 * |
|
76 * // Launch wait dialog |
|
77 * iWaitDialog = new (ELeave) CAknWaitDialog ( |
|
78 * reinterpret_cast<CEikDialog**>(&iWaitDialog), |
|
79 * ETrue ); |
|
80 * iWaitDialog->SetTone( CAknNoteDialog::EConfirmationTone ); |
|
81 * iWaitDialog->ExecuteLD( R_WAIT_DIALOG ); |
|
82 * |
|
83 * // Start waiting active object. Inthis example, we have an dedicated AO |
|
84 * // to wait for the completion, but of course the caller could itself be the AO. |
|
85 * delete iWaiter; |
|
86 * iWaiter = new (ELeave) CJpegRotatorTestWaiter (*this); |
|
87 * iWaiter->StartWaitL(); |
|
88 * |
|
89 * // Start rotate |
|
90 * iJpegRotator->RotateImageL( (iWaiter->iStatus), iSource, iTarget, CJpegRotator::ERotModeClockwise ); |
|
91 * ... |
|
92 * ... |
|
93 * // When the rotate is finished, (iWaiter->iStatus) will be completed with KErrNone, |
|
94 * // or an error code, if the rotate failed or was cancelled. |
|
95 * |
|
96 * |
|
97 */ |
|
98 class CJpegRotator : public CBase |
|
99 { |
|
100 |
|
101 public: |
|
102 |
|
103 /** @name Typedefs:*/ |
|
104 //@{ |
|
105 enum TRotationMode |
|
106 { |
|
107 ERotModeCounterClockwise = 0, |
|
108 ERotModeClockwise = 1, |
|
109 ERotMode90 = ERotModeCounterClockwise, |
|
110 ERotMode180 = 2, |
|
111 ERotMode270 = ERotModeClockwise, |
|
112 ERotMode0 = 3 |
|
113 }; |
|
114 //@} |
|
115 |
|
116 /** @name Methods:*/ |
|
117 //@{ |
|
118 |
|
119 /** NewLC factory method, does not pop cleanup stack |
|
120 * |
|
121 * @param - aFsSession |
|
122 * @param - aObserver |
|
123 * @return pointer to created CJpegRotator object |
|
124 */ |
|
125 IMPORT_C static CJpegRotator * NewLC ( RFs & aFsSession ); |
|
126 |
|
127 /** NewL factory method, pops cleanup stack |
|
128 * |
|
129 * @param - aFsSession |
|
130 * @param - aObserver |
|
131 * @return pointer to created CJpegRotator object |
|
132 */ |
|
133 IMPORT_C static CJpegRotator * NewL ( RFs & aFsSession ); |
|
134 |
|
135 /** Destructor |
|
136 * |
|
137 * @param - |
|
138 * @return - |
|
139 */ |
|
140 IMPORT_C ~CJpegRotator (); |
|
141 |
|
142 /** RotateImageL |
|
143 * |
|
144 * Rotates the JPEG image, asynchronous one-block version. |
|
145 * |
|
146 * Lossless rotate mode is used by default |
|
147 * |
|
148 * Starts the rotate. After the rotation is completed, the |
|
149 * supplied TRequestStatus is completed. |
|
150 * |
|
151 * If the rotation fails, the request is completed with the error code, |
|
152 * KErrNone otherwise. The function may also leave, if the error happens |
|
153 * during the pre-rotate check phase. |
|
154 * |
|
155 * Possible error codes include: |
|
156 * - KErrArgument if the rotation argument is out of range. |
|
157 * - KErrNotFound if the source file does not exist. |
|
158 * - KErrCorrupt if the source image could not be read. |
|
159 * - KErrNotSupported if the image type can't be handled (not baseline JPEG) |
|
160 * - KErrPathNotFound if the target path does not exist. |
|
161 * - KErrAlreadyExists if the target file already exists. |
|
162 * - Other system-wide error codes. |
|
163 * |
|
164 * @param aStatus - |
|
165 * Reference to the TRequestStatus of an active object, |
|
166 * which will be completed when the rotation finishes. |
|
167 * @param aRotationMode - The rotation direction |
|
168 * @param aSourceFileName - The image to be rotated |
|
169 * @param aTargetFileName - The target file where the rotated image will be saved |
|
170 * @param aHandleExifData - Do we update/create the EXIF data in the JPEG image |
|
171 * @param aForceLossyMode - Use lossy mode instead of lossless mode |
|
172 * @return - |
|
173 */ |
|
174 IMPORT_C void RotateImageL ( |
|
175 TRequestStatus & aStatus, |
|
176 const TDesC & aSourceFileName, |
|
177 const TDesC & aTargetFileName, |
|
178 CJpegRotator::TRotationMode aRotationMode, |
|
179 TBool aHandleExifData = ETrue, |
|
180 TBool aForceLossyMode = EFalse |
|
181 ); |
|
182 |
|
183 /** Cancel |
|
184 * |
|
185 * @param - |
|
186 * @return - |
|
187 */ |
|
188 IMPORT_C void Cancel (); |
|
189 |
|
190 //@} |
|
191 |
|
192 private: |
|
193 |
|
194 /** @name Methods:*/ |
|
195 //@{ |
|
196 |
|
197 /** Default constructor |
|
198 * @param - |
|
199 * @return - |
|
200 */ |
|
201 CJpegRotator (); |
|
202 |
|
203 /** Second phase constructor, may leave |
|
204 * |
|
205 * @param - aFsSession |
|
206 * @return - |
|
207 */ |
|
208 void ConstructL ( RFs& aFsSession ); |
|
209 |
|
210 //@} |
|
211 |
|
212 /** @name Members:*/ |
|
213 //@{ |
|
214 |
|
215 /// Internal representation |
|
216 CJpegRotatorImpl * iImplementation; |
|
217 |
|
218 //@} |
|
219 |
|
220 }; |
|
221 |
|
222 #endif |
|
223 |
|
224 |
|
225 // End of File |