|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
|
3 <title>TB10.1 Example Applications: examples/Multimedia/ICL/ICLExample/icljpgtoolsandsqueezeexample.cpp Source File</title> |
|
4 <link href="doxygen.css" rel="stylesheet" type="text/css"> |
|
5 <link href="tabs.css" rel="stylesheet" type="text/css"> |
|
6 </head><body> |
|
7 <!-- Generated by Doxygen 1.5.3 --> |
|
8 <h1>examples/Multimedia/ICL/ICLExample/icljpgtoolsandsqueezeexample.cpp</h1><a href="icljpgtoolsandsqueezeexample_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).</span> |
|
9 <a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span> |
|
10 <a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span> |
|
11 <a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span> |
|
12 <a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span> |
|
13 <a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span> |
|
14 <a name="l00007"></a>00007 <span class="comment">//</span> |
|
15 <a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span> |
|
16 <a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span> |
|
17 <a name="l00010"></a>00010 <span class="comment">//</span> |
|
18 <a name="l00011"></a>00011 <span class="comment">// Contributors:</span> |
|
19 <a name="l00012"></a>00012 <span class="comment">//</span> |
|
20 <a name="l00013"></a>00013 <span class="comment">// Description:</span> |
|
21 <a name="l00014"></a>00014 <span class="comment">// This code demonstrates various imagetransformations available in Jpeg Tools and Squeeze </span> |
|
22 <a name="l00015"></a>00015 <span class="comment">// modules of ICL </span> |
|
23 <a name="l00016"></a>00016 <span class="comment">// Note 1: For demonstration purposes we create a client side active object which can </span> |
|
24 <a name="l00017"></a>00017 <span class="comment">// handle the asynchronous request to transform the image. In a standard application the asynchronous</span> |
|
25 <a name="l00018"></a>00018 <span class="comment">// call would be made passing in a TRequestStatus object associate with an active object</span> |
|
26 <a name="l00019"></a>00019 <span class="comment">// which is part of that application. We would return to the main UI processing thread in </span> |
|
27 <a name="l00020"></a>00020 <span class="comment">// which an active scheduler is running and wait for the asynchronous request to complete. In </span> |
|
28 <a name="l00021"></a>00021 <span class="comment">// this demonstration we need to manually start the active scheduler.</span> |
|
29 <a name="l00022"></a>00022 <span class="comment">// Note 2: Starts the active scheduler - this is for demonstration purposes. See Note 1:</span> |
|
30 <a name="l00023"></a>00023 <span class="comment">//</span> |
|
31 <a name="l00024"></a>00024 |
|
32 <a name="l00025"></a>00025 |
|
33 <a name="l00026"></a>00026 |
|
34 <a name="l00027"></a>00027 |
|
35 <a name="l00028"></a>00028 |
|
36 <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="iclexample_8h.html">iclexample.h</a>"</span> |
|
37 <a name="l00034"></a>00034 |
|
38 <a name="l00035"></a>00035 <span class="preprocessor">#include <imagetransform.h></span> |
|
39 <a name="l00036"></a>00036 <span class="preprocessor">#include <icl/squeezetransformextension.h></span> |
|
40 <a name="l00037"></a>00037 <span class="preprocessor">#include <icl/orientationtransformextension.h></span> |
|
41 <a name="l00038"></a>00038 <span class="preprocessor">#include <icl/overlaytransformextension.h></span> |
|
42 <a name="l00039"></a>00039 <span class="preprocessor">#include <iclexifimageframe.h></span> |
|
43 <a name="l00040"></a>00040 <span class="preprocessor">#include <imageframe.h></span> |
|
44 <a name="l00041"></a>00041 <span class="preprocessor">#include <imageconversion.h></span> |
|
45 <a name="l00042"></a>00042 |
|
46 <a name="l00043"></a>00043 |
|
47 <a name="l00044"></a><a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">00044</a> <span class="keyword">const</span> TUid <a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">KImageFramePluginUid</a> = {0x101F7C60}; |
|
48 <a name="l00045"></a>00045 |
|
49 <a name="l00056"></a><a class="code" href="class_c_icl_example.html#01e8b801b449b110507d038fd29c0465">00056</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#01e8b801b449b110507d038fd29c0465">CIclExample::SqueezeJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
50 <a name="l00057"></a>00057 { |
|
51 <a name="l00058"></a>00058 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
52 <a name="l00059"></a>00059 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
53 <a name="l00060"></a>00060 CleanupStack::PushL(imageTransform); |
|
54 <a name="l00061"></a>00061 |
|
55 <a name="l00062"></a>00062 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
56 <a name="l00063"></a>00063 imageTransform->SetDestFilenameL(aDestFileName); |
|
57 <a name="l00064"></a>00064 imageTransform->SetTransformationsL(CImageTransform::ESqueeze); |
|
58 <a name="l00065"></a>00065 imageTransform->SetOptionsL(CImageTransform::EIgnoreExifMetadataProcessing); |
|
59 <a name="l00066"></a>00066 imageTransform->SetupL(); |
|
60 <a name="l00067"></a>00067 |
|
61 <a name="l00068"></a>00068 TUid lSqUid = {KUidSqueezeTransformExtension }; |
|
62 <a name="l00069"></a>00069 TInt err = KErrNone; |
|
63 <a name="l00070"></a>00070 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err)); |
|
64 <a name="l00071"></a>00071 <span class="keywordflow">if</span>(!lSqExt) |
|
65 <a name="l00072"></a>00072 { |
|
66 <a name="l00073"></a>00073 User::Leave(err); |
|
67 <a name="l00074"></a>00074 } |
|
68 <a name="l00075"></a>00075 |
|
69 <a name="l00076"></a>00076 <span class="comment">// Squeeze by 20% of size in bytes</span> |
|
70 <a name="l00077"></a>00077 TInt squeezeRate = 20; |
|
71 <a name="l00078"></a>00078 RFile file; |
|
72 <a name="l00079"></a>00079 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead)); |
|
73 <a name="l00080"></a>00080 TInt filesize; |
|
74 <a name="l00081"></a>00081 User::LeaveIfError(file.Size(filesize)); |
|
75 <a name="l00082"></a>00082 file.Close(); |
|
76 <a name="l00083"></a>00083 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 ); |
|
77 <a name="l00084"></a>00084 |
|
78 <a name="l00085"></a>00085 <span class="comment">// Set the desired max size of the squeezed file on the squeeze extension</span> |
|
79 <a name="l00086"></a>00086 lSqExt->SetDestSizeInBytes(maxdestsize); |
|
80 <a name="l00087"></a>00087 |
|
81 <a name="l00088"></a>00088 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
82 <a name="l00089"></a>00089 <span class="comment">// See Note 1</span> |
|
83 <a name="l00090"></a>00090 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
84 <a name="l00091"></a>00091 |
|
85 <a name="l00092"></a>00092 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
86 <a name="l00093"></a>00093 imageTransform->Transform(activeListener->iStatus); |
|
87 <a name="l00094"></a>00094 |
|
88 <a name="l00095"></a>00095 <span class="comment">// See Note 2</span> |
|
89 <a name="l00096"></a>00096 CActiveScheduler::Start(); |
|
90 <a name="l00097"></a>00097 User::LeaveIfError(activeListener->iStatus.Int()); |
|
91 <a name="l00098"></a>00098 |
|
92 <a name="l00099"></a>00099 |
|
93 <a name="l00100"></a>00100 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span> |
|
94 <a name="l00101"></a>00101 } |
|
95 <a name="l00102"></a>00102 |
|
96 <a name="l00103"></a>00103 |
|
97 <a name="l00114"></a><a class="code" href="class_c_icl_example.html#5a2b4947cd5af165546515ee95742419">00114</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#5a2b4947cd5af165546515ee95742419">CIclExample::SqueezeJpgBufferToBufferL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
98 <a name="l00115"></a>00115 { |
|
99 <a name="l00116"></a>00116 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aSrcFileName); |
|
100 <a name="l00117"></a>00117 HBufC8* destData = NULL; |
|
101 <a name="l00118"></a>00118 |
|
102 <a name="l00119"></a>00119 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
103 <a name="l00120"></a>00120 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
104 <a name="l00121"></a>00121 CleanupStack::PushL(imageTransform); |
|
105 <a name="l00122"></a>00122 |
|
106 <a name="l00123"></a>00123 imageTransform->SetSourceDataL(imageFromFilePtr); |
|
107 <a name="l00124"></a>00124 imageTransform->SetDestDataL(destData); |
|
108 <a name="l00125"></a>00125 imageTransform->SetTransformationsL(CImageTransform::ESqueeze); |
|
109 <a name="l00126"></a>00126 imageTransform->SetupL(); |
|
110 <a name="l00127"></a>00127 |
|
111 <a name="l00128"></a>00128 TUid lSqUid = {KUidSqueezeTransformExtension }; |
|
112 <a name="l00129"></a>00129 TInt err = KErrNone; |
|
113 <a name="l00130"></a>00130 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err)); |
|
114 <a name="l00131"></a>00131 <span class="keywordflow">if</span>(!lSqExt) |
|
115 <a name="l00132"></a>00132 { |
|
116 <a name="l00133"></a>00133 User::Leave(err); |
|
117 <a name="l00134"></a>00134 } |
|
118 <a name="l00135"></a>00135 |
|
119 <a name="l00136"></a>00136 <span class="comment">// Squeeze by 5% of size in bytes</span> |
|
120 <a name="l00137"></a>00137 TInt squeezeRate = 5; |
|
121 <a name="l00138"></a>00138 RFile file; |
|
122 <a name="l00139"></a>00139 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead)); |
|
123 <a name="l00140"></a>00140 TInt filesize; |
|
124 <a name="l00141"></a>00141 User::LeaveIfError(file.Size(filesize)); |
|
125 <a name="l00142"></a>00142 file.Close(); |
|
126 <a name="l00143"></a>00143 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 ); |
|
127 <a name="l00144"></a>00144 |
|
128 <a name="l00145"></a>00145 <span class="comment">// Set the desired max size of the squeezed file on the squeeze extension</span> |
|
129 <a name="l00146"></a>00146 lSqExt->SetDestSizeInBytes(maxdestsize); |
|
130 <a name="l00147"></a>00147 |
|
131 <a name="l00148"></a>00148 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
132 <a name="l00149"></a>00149 <span class="comment">// See Note 1</span> |
|
133 <a name="l00150"></a>00150 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
134 <a name="l00151"></a>00151 |
|
135 <a name="l00152"></a>00152 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
136 <a name="l00153"></a>00153 imageTransform->Transform(activeListener->iStatus); |
|
137 <a name="l00154"></a>00154 |
|
138 <a name="l00155"></a>00155 <span class="comment">// See Note 2</span> |
|
139 <a name="l00156"></a>00156 CActiveScheduler::Start(); |
|
140 <a name="l00157"></a>00157 User::LeaveIfError(activeListener->iStatus.Int()); |
|
141 <a name="l00158"></a>00158 |
|
142 <a name="l00159"></a>00159 <span class="comment">// write the descriptor to the output file</span> |
|
143 <a name="l00160"></a>00160 User::LeaveIfError(file.Replace(iFs, aDestFileName, EFileWrite)); |
|
144 <a name="l00161"></a>00161 file.Write(*destData); |
|
145 <a name="l00162"></a>00162 file.Close(); |
|
146 <a name="l00163"></a>00163 <span class="keyword">delete</span> destData; |
|
147 <a name="l00164"></a>00164 |
|
148 <a name="l00165"></a>00165 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, imageTransform, image </span> |
|
149 <a name="l00166"></a>00166 } |
|
150 <a name="l00167"></a>00167 |
|
151 <a name="l00168"></a>00168 |
|
152 <a name="l00179"></a><a class="code" href="class_c_icl_example.html#ad1303bafe8aac71274efa90558f29ff">00179</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#ad1303bafe8aac71274efa90558f29ff">CIclExample::AutoSqueezeJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
153 <a name="l00180"></a>00180 { |
|
154 <a name="l00181"></a>00181 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
155 <a name="l00182"></a>00182 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
156 <a name="l00183"></a>00183 CleanupStack::PushL(imageTransform); |
|
157 <a name="l00184"></a>00184 |
|
158 <a name="l00185"></a>00185 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
159 <a name="l00186"></a>00186 imageTransform->SetDestFilenameL(aDestFileName); |
|
160 <a name="l00187"></a>00187 imageTransform->SetTransformationsL(CImageTransform::ESqueeze); |
|
161 <a name="l00188"></a>00188 imageTransform->SetupL(); |
|
162 <a name="l00189"></a>00189 |
|
163 <a name="l00190"></a>00190 TUid lSqUid = {KUidSqueezeTransformExtension }; |
|
164 <a name="l00191"></a>00191 TInt err = KErrNone; |
|
165 <a name="l00192"></a>00192 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err)); |
|
166 <a name="l00193"></a>00193 <span class="keywordflow">if</span>(!lSqExt) |
|
167 <a name="l00194"></a>00194 { |
|
168 <a name="l00195"></a>00195 User::Leave(err); |
|
169 <a name="l00196"></a>00196 } |
|
170 <a name="l00197"></a>00197 |
|
171 <a name="l00198"></a>00198 <span class="comment">// Squeeze by 5% of size in bytes</span> |
|
172 <a name="l00199"></a>00199 TInt squeezeRate = 5; |
|
173 <a name="l00200"></a>00200 RFile file; |
|
174 <a name="l00201"></a>00201 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead)); |
|
175 <a name="l00202"></a>00202 TInt filesize; |
|
176 <a name="l00203"></a>00203 User::LeaveIfError(file.Size(filesize)); |
|
177 <a name="l00204"></a>00204 file.Close(); |
|
178 <a name="l00205"></a>00205 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 ); |
|
179 <a name="l00206"></a>00206 |
|
180 <a name="l00207"></a>00207 <span class="comment">// Get the pixel size of the image</span> |
|
181 <a name="l00208"></a>00208 CJPEGImageFrameDecoder *decoder = NULL; |
|
182 <a name="l00209"></a>00209 decoder= <span class="keyword">static_cast<</span>CJPEGImageFrameDecoder*<span class="keyword">></span> (CImageDecoder::FileNewL(iFs, aSrcFileName, CImageDecoder::EOptionNone, KNullUid, KNullUid, <a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">KImageFramePluginUid</a>)); |
|
183 <a name="l00210"></a>00210 <span class="keyword">const</span> TFrameInfo* frameInfo = &decoder->FrameInfo();; |
|
184 <a name="l00211"></a>00211 TSize imgSizeInPixels = frameInfo->iOverallSizeInPixels; |
|
185 <a name="l00212"></a>00212 <span class="keyword">delete</span> decoder; |
|
186 <a name="l00213"></a>00213 |
|
187 <a name="l00214"></a>00214 <span class="comment">// Max pixel size may be 10% of the original size</span> |
|
188 <a name="l00215"></a>00215 TSize maxImageSizeInPixels; |
|
189 <a name="l00216"></a>00216 maxImageSizeInPixels.iWidth = imgSizeInPixels.iWidth - (imgSizeInPixels.iWidth *10) /100; |
|
190 <a name="l00217"></a>00217 maxImageSizeInPixels.iHeight = imgSizeInPixels.iHeight - (imgSizeInPixels.iHeight *10) /100; |
|
191 <a name="l00218"></a>00218 |
|
192 <a name="l00219"></a>00219 <span class="comment">// Min pixel size may be 30% of the original size</span> |
|
193 <a name="l00220"></a>00220 TSize minImageSizeInPixels; |
|
194 <a name="l00221"></a>00221 minImageSizeInPixels.iWidth = imgSizeInPixels.iWidth - (imgSizeInPixels.iWidth *30) /100; |
|
195 <a name="l00222"></a>00222 minImageSizeInPixels.iHeight = imgSizeInPixels.iHeight - (imgSizeInPixels.iHeight *30) /100; |
|
196 <a name="l00223"></a>00223 |
|
197 <a name="l00224"></a>00224 <span class="comment">// Set the various desired parmas for the auto squeeze</span> |
|
198 <a name="l00225"></a>00225 TAdvancedSqueezeParams squeezeAutoResizeParams; |
|
199 <a name="l00226"></a>00226 squeezeAutoResizeParams.iMaxDestSizeInBytes = maxdestsize; |
|
200 <a name="l00227"></a>00227 squeezeAutoResizeParams.iResizeAction = TAdvancedSqueezeParams::EAutoResizeActionPrioritizeLargeImageSize; |
|
201 <a name="l00228"></a>00228 squeezeAutoResizeParams.iMinImageSize = minImageSizeInPixels; |
|
202 <a name="l00229"></a>00229 squeezeAutoResizeParams.iMaxImageSize = maxImageSizeInPixels; |
|
203 <a name="l00230"></a>00230 squeezeAutoResizeParams.iSamplingUid = KUidSamplingColor422; |
|
204 <a name="l00231"></a>00231 squeezeAutoResizeParams.iMinEncodingQuality = 0.8f; |
|
205 <a name="l00232"></a>00232 <span class="comment">// Set the advance params to the squeeze extension</span> |
|
206 <a name="l00233"></a>00233 lSqExt->SetAdvancedSqueezeModeL(&squeezeAutoResizeParams); |
|
207 <a name="l00234"></a>00234 |
|
208 <a name="l00235"></a>00235 |
|
209 <a name="l00236"></a>00236 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
210 <a name="l00237"></a>00237 <span class="comment">// See Note 1</span> |
|
211 <a name="l00238"></a>00238 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
212 <a name="l00239"></a>00239 |
|
213 <a name="l00240"></a>00240 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
214 <a name="l00241"></a>00241 imageTransform->Transform(activeListener->iStatus); |
|
215 <a name="l00242"></a>00242 |
|
216 <a name="l00243"></a>00243 <span class="comment">// See Note 2</span> |
|
217 <a name="l00244"></a>00244 CActiveScheduler::Start(); |
|
218 <a name="l00245"></a>00245 User::LeaveIfError(activeListener->iStatus.Int()); |
|
219 <a name="l00246"></a>00246 |
|
220 <a name="l00247"></a>00247 |
|
221 <a name="l00248"></a>00248 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span> |
|
222 <a name="l00249"></a>00249 } |
|
223 <a name="l00250"></a>00250 |
|
224 <a name="l00261"></a><a class="code" href="class_c_icl_example.html#0afdb26ddecd25134d6c33109f9ce99f">00261</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#0afdb26ddecd25134d6c33109f9ce99f">CIclExample::RotateJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
225 <a name="l00262"></a>00262 { |
|
226 <a name="l00263"></a>00263 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
227 <a name="l00264"></a>00264 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
228 <a name="l00265"></a>00265 CleanupStack::PushL(imageTransform); |
|
229 <a name="l00266"></a>00266 |
|
230 <a name="l00267"></a>00267 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
231 <a name="l00268"></a>00268 imageTransform->SetDestFilenameL(aDestFileName); |
|
232 <a name="l00269"></a>00269 imageTransform->SetTransformationsL(CImageTransform::EOrientation); |
|
233 <a name="l00270"></a>00270 imageTransform->SetupL(); |
|
234 <a name="l00271"></a>00271 |
|
235 <a name="l00272"></a>00272 TUid lRotateUid = {KUidOrientationTransformExtension }; |
|
236 <a name="l00273"></a>00273 TInt err = KErrNone; |
|
237 <a name="l00274"></a>00274 COrientationTransformExtension* lRotateExt = <span class="keyword">static_cast<</span>COrientationTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err)); |
|
238 <a name="l00275"></a>00275 <span class="keywordflow">if</span>(!lRotateExt) |
|
239 <a name="l00276"></a>00276 { |
|
240 <a name="l00277"></a>00277 User::Leave(err); |
|
241 <a name="l00278"></a>00278 } |
|
242 <a name="l00279"></a>00279 <span class="comment">// Rotate by 90 degree of size in bytes</span> |
|
243 <a name="l00280"></a>00280 lRotateExt->SetOrientationL(COrientationTransformExtension::ERotation90DegreesClockwise); |
|
244 <a name="l00281"></a>00281 |
|
245 <a name="l00282"></a>00282 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
246 <a name="l00283"></a>00283 <span class="comment">// See Note 1</span> |
|
247 <a name="l00284"></a>00284 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
248 <a name="l00285"></a>00285 |
|
249 <a name="l00286"></a>00286 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
250 <a name="l00287"></a>00287 imageTransform->Transform(activeListener->iStatus); |
|
251 <a name="l00288"></a>00288 |
|
252 <a name="l00289"></a>00289 <span class="comment">// See Note 2</span> |
|
253 <a name="l00290"></a>00290 CActiveScheduler::Start(); |
|
254 <a name="l00291"></a>00291 User::LeaveIfError(activeListener->iStatus.Int()); |
|
255 <a name="l00292"></a>00292 |
|
256 <a name="l00293"></a>00293 |
|
257 <a name="l00294"></a>00294 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span> |
|
258 <a name="l00295"></a>00295 } |
|
259 <a name="l00296"></a>00296 |
|
260 <a name="l00297"></a>00297 |
|
261 <a name="l00309"></a><a class="code" href="class_c_icl_example.html#5a9a18e5cb34223269cf92d0367d7dd2">00309</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#5a9a18e5cb34223269cf92d0367d7dd2">CIclExample::OverlayJpgDataToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
262 <a name="l00310"></a>00310 { |
|
263 <a name="l00311"></a>00311 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
264 <a name="l00312"></a>00312 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
265 <a name="l00313"></a>00313 CleanupStack::PushL(imageTransform); |
|
266 <a name="l00314"></a>00314 |
|
267 <a name="l00315"></a>00315 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
268 <a name="l00316"></a>00316 imageTransform->SetDestFilenameL(aDestFileName); |
|
269 <a name="l00317"></a>00317 imageTransform->SetTransformationsL(CImageTransform::EOverlay); |
|
270 <a name="l00318"></a>00318 imageTransform->SetupL(); |
|
271 <a name="l00319"></a>00319 |
|
272 <a name="l00320"></a>00320 TUid lRotateUid = {KUidOverlayTransformExtension }; |
|
273 <a name="l00321"></a>00321 TInt err = KErrNone; |
|
274 <a name="l00322"></a>00322 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err)); |
|
275 <a name="l00323"></a>00323 <span class="keywordflow">if</span>(!lOverlayExt) |
|
276 <a name="l00324"></a>00324 { |
|
277 <a name="l00325"></a>00325 User::Leave(err); |
|
278 <a name="l00326"></a>00326 } |
|
279 <a name="l00327"></a>00327 <span class="comment">// Set the position</span> |
|
280 <a name="l00328"></a>00328 TPoint position(0,0); |
|
281 <a name="l00329"></a>00329 lOverlayExt->SetPosition(position); |
|
282 <a name="l00330"></a>00330 |
|
283 <a name="l00331"></a>00331 <span class="comment">// Set the overlay file</span> |
|
284 <a name="l00332"></a>00332 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aOverlayFileName); |
|
285 <a name="l00333"></a>00333 lOverlayExt->SetOverlayDataL(imageFromFilePtr, KImageTypeJPGUid); |
|
286 <a name="l00334"></a>00334 |
|
287 <a name="l00335"></a>00335 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
288 <a name="l00336"></a>00336 <span class="comment">// See Note 1</span> |
|
289 <a name="l00337"></a>00337 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
290 <a name="l00338"></a>00338 |
|
291 <a name="l00339"></a>00339 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
292 <a name="l00340"></a>00340 imageTransform->Transform(activeListener->iStatus); |
|
293 <a name="l00341"></a>00341 |
|
294 <a name="l00342"></a>00342 <span class="comment">// See Note 2</span> |
|
295 <a name="l00343"></a>00343 CActiveScheduler::Start(); |
|
296 <a name="l00344"></a>00344 User::LeaveIfError(activeListener->iStatus.Int()); |
|
297 <a name="l00345"></a>00345 |
|
298 <a name="l00346"></a>00346 |
|
299 <a name="l00347"></a>00347 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, overlay image, imageTransform </span> |
|
300 <a name="l00348"></a>00348 } |
|
301 <a name="l00349"></a>00349 |
|
302 <a name="l00361"></a><a class="code" href="class_c_icl_example.html#dfaa0ee7346aa45a9ef50d9fe7295404">00361</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#dfaa0ee7346aa45a9ef50d9fe7295404">CIclExample::OverlayPngFileToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
303 <a name="l00362"></a>00362 { |
|
304 <a name="l00363"></a>00363 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
305 <a name="l00364"></a>00364 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
306 <a name="l00365"></a>00365 CleanupStack::PushL(imageTransform); |
|
307 <a name="l00366"></a>00366 |
|
308 <a name="l00367"></a>00367 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
309 <a name="l00368"></a>00368 imageTransform->SetDestFilenameL(aDestFileName); |
|
310 <a name="l00369"></a>00369 imageTransform->SetTransformationsL(CImageTransform::EOverlay); |
|
311 <a name="l00370"></a>00370 imageTransform->SetupL(); |
|
312 <a name="l00371"></a>00371 |
|
313 <a name="l00372"></a>00372 TUid lOverlayUid = {KUidOverlayTransformExtension }; |
|
314 <a name="l00373"></a>00373 TInt err = KErrNone; |
|
315 <a name="l00374"></a>00374 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lOverlayUid, err)); |
|
316 <a name="l00375"></a>00375 <span class="keywordflow">if</span>(!lOverlayExt) |
|
317 <a name="l00376"></a>00376 { |
|
318 <a name="l00377"></a>00377 User::Leave(err); |
|
319 <a name="l00378"></a>00378 } |
|
320 <a name="l00379"></a>00379 <span class="comment">// Set the position</span> |
|
321 <a name="l00380"></a>00380 TPoint position(0,0); |
|
322 <a name="l00381"></a>00381 lOverlayExt->SetPosition(position); |
|
323 <a name="l00382"></a>00382 |
|
324 <a name="l00383"></a>00383 <span class="comment">// Set the overlay data</span> |
|
325 <a name="l00384"></a>00384 TUid pngUid = KImageTypePNGUid; |
|
326 <a name="l00385"></a>00385 lOverlayExt->SetOverlayFileL(aOverlayFileName, pngUid); |
|
327 <a name="l00386"></a>00386 |
|
328 <a name="l00387"></a>00387 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
329 <a name="l00388"></a>00388 <span class="comment">// See Note 1</span> |
|
330 <a name="l00389"></a>00389 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
331 <a name="l00390"></a>00390 |
|
332 <a name="l00391"></a>00391 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
333 <a name="l00392"></a>00392 imageTransform->Transform(activeListener->iStatus); |
|
334 <a name="l00393"></a>00393 |
|
335 <a name="l00394"></a>00394 <span class="comment">// See Note 2</span> |
|
336 <a name="l00395"></a>00395 CActiveScheduler::Start(); |
|
337 <a name="l00396"></a>00396 User::LeaveIfError(activeListener->iStatus.Int()); |
|
338 <a name="l00397"></a>00397 |
|
339 <a name="l00398"></a>00398 |
|
340 <a name="l00399"></a>00399 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, overlay image, imageTransform </span> |
|
341 <a name="l00400"></a>00400 } |
|
342 <a name="l00401"></a>00401 |
|
343 <a name="l00402"></a>00402 |
|
344 <a name="l00414"></a><a class="code" href="class_c_icl_example.html#3c18c273d702e32b9d4e196e38edfa46">00414</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#3c18c273d702e32b9d4e196e38edfa46">CIclExample::OverlayBmpDataToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
345 <a name="l00415"></a>00415 { |
|
346 <a name="l00416"></a>00416 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
347 <a name="l00417"></a>00417 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
348 <a name="l00418"></a>00418 CleanupStack::PushL(imageTransform); |
|
349 <a name="l00419"></a>00419 |
|
350 <a name="l00420"></a>00420 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
351 <a name="l00421"></a>00421 imageTransform->SetDestFilenameL(aDestFileName); |
|
352 <a name="l00422"></a>00422 imageTransform->SetTransformationsL(CImageTransform::EOverlay); |
|
353 <a name="l00423"></a>00423 imageTransform->SetupL(); |
|
354 <a name="l00424"></a>00424 |
|
355 <a name="l00425"></a>00425 TUid lRotateUid = {KUidOverlayTransformExtension }; |
|
356 <a name="l00426"></a>00426 TInt err = KErrNone; |
|
357 <a name="l00427"></a>00427 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err)); |
|
358 <a name="l00428"></a>00428 <span class="keywordflow">if</span>(!lOverlayExt) |
|
359 <a name="l00429"></a>00429 { |
|
360 <a name="l00430"></a>00430 User::Leave(err); |
|
361 <a name="l00431"></a>00431 } |
|
362 <a name="l00432"></a>00432 <span class="comment">// Set the position</span> |
|
363 <a name="l00433"></a>00433 TPoint position(0,0); |
|
364 <a name="l00434"></a>00434 lOverlayExt->SetPosition(position); |
|
365 <a name="l00435"></a>00435 |
|
366 <a name="l00436"></a>00436 <span class="comment">// Set the overlay bitmap</span> |
|
367 <a name="l00437"></a>00437 CFbsBitmap* overlayBitmap = <span class="keyword">new</span> (ELeave) CFbsBitmap; |
|
368 <a name="l00438"></a>00438 CleanupStack::PushL(overlayBitmap); |
|
369 <a name="l00439"></a>00439 User::LeaveIfError(overlayBitmap->Load(aOverlayFileName)); |
|
370 <a name="l00440"></a>00440 lOverlayExt->SetOverlayImageL(*overlayBitmap); |
|
371 <a name="l00441"></a>00441 |
|
372 <a name="l00442"></a>00442 |
|
373 <a name="l00443"></a>00443 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
374 <a name="l00444"></a>00444 <span class="comment">// See Note 1</span> |
|
375 <a name="l00445"></a>00445 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
376 <a name="l00446"></a>00446 |
|
377 <a name="l00447"></a>00447 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
378 <a name="l00448"></a>00448 imageTransform->Transform(activeListener->iStatus); |
|
379 <a name="l00449"></a>00449 |
|
380 <a name="l00450"></a>00450 <span class="comment">// See Note 2</span> |
|
381 <a name="l00451"></a>00451 CActiveScheduler::Start(); |
|
382 <a name="l00452"></a>00452 User::LeaveIfError(activeListener->iStatus.Int()); |
|
383 <a name="l00453"></a>00453 |
|
384 <a name="l00454"></a>00454 |
|
385 <a name="l00455"></a>00455 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, overlay bitmap, imageTransform </span> |
|
386 <a name="l00456"></a>00456 } |
|
387 <a name="l00457"></a>00457 |
|
388 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:59 2010 for TB10.1 Example Applications by |
|
389 <a href="http://www.doxygen.org/index.html"> |
|
390 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> |
|
391 </body> |
|
392 </html> |