00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00025 #include "iclexample.h"
00026 #include <f32file.h>
00027
00032 CActiveListener* CActiveListener::NewLC()
00033 {
00034 CActiveListener* self = new(ELeave) CActiveListener();
00035 CleanupStack::PushL(self);
00036 return self;
00037 }
00038
00042 CActiveListener::CActiveListener() : CActive(EPriorityLow)
00043 {
00044 CActiveScheduler::Add(this);
00045 }
00046
00050 CActiveListener::~CActiveListener()
00051 {
00052 }
00053
00058 void CActiveListener::RunL()
00059 {
00060 CActiveScheduler::Stop();
00061 }
00062
00067 void CActiveListener::DoCancel()
00068 {
00069 }
00070
00074 void CActiveListener::Initialize()
00075 {
00076 iStatus = KRequestPending;
00077 SetActive();
00078 }
00079
00084 TBool CActiveListener::IsRequestCancelled()
00085 {
00086 return (iStatus == KErrCancel);
00087 }
00088
00089
00090
00096 CIclExample* CIclExample::NewLC()
00097 {
00098 CIclExample* self = new(ELeave) CIclExample();
00099 CleanupStack::PushL(self);
00100 self->ConstructL();
00101 return self;
00102 }
00103
00107 CIclExample::CIclExample()
00108 {
00109 }
00110
00111 void CIclExample::ConstructL()
00112 {
00113 User::LeaveIfError(iFs.Connect());
00114 User::LeaveIfError(RFbsSession::Connect());
00115 }
00116
00120 CIclExample::~CIclExample()
00121 {
00122 RFbsSession::Disconnect();
00123 iFs.Close();
00124
00125
00126 REComSession::FinalClose();
00127 }
00128
00129
00136 TPtr8 CIclExample::LoadImageIntoMemoryLC(const TDesC& aFileName)
00137 {
00138 RFile file;
00139 TInt fileSize = 0;
00140
00141
00142 User::LeaveIfError(file.Open(iFs, aFileName, EFileRead));
00143 CleanupClosePushL(file);
00144 User::LeaveIfError(file.Size(fileSize));
00145
00146 HBufC8* imageInMemory = HBufC8::NewMaxL(fileSize);
00147 TPtr8 imageInMemoryPtr = imageInMemory->Des();
00148
00149
00150 CleanupStack::Pop();
00151 CleanupStack::PushL(imageInMemory);
00152 CleanupClosePushL(file);
00153
00154 if (file.SubSessionHandle())
00155 {
00156 User::LeaveIfError(file.Read(imageInMemoryPtr));
00157 }
00158
00159 CleanupStack::PopAndDestroy();
00160 return imageInMemoryPtr;
00161 }
00162
00163
00168 CActiveListener* CIclExample::CreateAndInitializeActiveListenerLC()
00169 {
00170
00171 CActiveListener* activeListener = CActiveListener::NewLC();
00172 activeListener->Initialize();
00173 return activeListener;
00174 }
00175
00176
00177 LOCAL_C void MainL()
00178 {
00179
00180 CConsoleBase* gConsole = Console::NewL(KTitle, TSize(KConsFullScreen, KConsFullScreen));
00181 CleanupStack::PushL(gConsole);
00182
00183
00184 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler();
00185 CleanupStack::PushL(scheduler);
00186 CActiveScheduler::Install(scheduler);
00187
00188 CIclExample* app = CIclExample::NewLC();
00189 app->SetConsole(gConsole);
00190
00191 gConsole->Printf(KWelcomeMessage);
00192 gConsole->Printf(KPressAKeyMsg);
00193 gConsole->Getch();
00194
00195
00196 gConsole->Printf(KPanoramaStitching);
00197
00198
00199 _LIT(KPath,"z:\\resource\\plugins\\");
00200 _LIT(KFile,"panoramaplugin.rsc");
00201
00202
00203
00204
00205 RFs fsSession;
00206 User::LeaveIfError(fsSession.Connect());
00207
00208 TFindFile file(fsSession);
00209 TInt panoramaPluginSupport;
00210 panoramaPluginSupport = file.FindByPath(KFile(),&KPath());
00211
00212 if(panoramaPluginSupport == KErrNone)
00213 {
00214 app->BasicPanoramaStitchingL();
00215 gConsole->Printf(KBPStitching);
00216
00217 app->ViewFinderImageTrackingL();
00218 gConsole->Printf(KVFTStitching);
00219 }
00220
00221 gConsole->Printf(KPressAKey);
00222 gConsole->Getch();
00223
00224
00225
00226
00227 gConsole->Printf(KDecode);
00228
00229
00230 app->DecodeFromDescriptorToBitmapL(KBitmapFile);
00231 gConsole->Printf(KDecodeFromDescriptorToBitmap);
00232
00233
00234 app->DecodeFromFileToBitmapL(KBitmapFile);
00235 gConsole->Printf(KDecodeFromDescriptorAndFile, &KBitmapFile);
00236
00237
00238 app->DecodeToYuvFrameL(KYuvBitmap);
00239 gConsole->Printf(KDecodeToYuv, &KYuvBitmap);
00240
00241
00242 app->DecodeToHalfFourthAndEighthSizedBitmapL(KBitmapFile);
00243 gConsole->Printf(KDecodeToHalfFourthAndEighthSizedBmp, &KBitmapFile);
00244
00245
00246 app->DecodeUsingImageMaskL(KMultiFrameClock);
00247 gConsole->Printf(KDecodeUsingImageMask);
00248
00249
00250 app->MultiFrameImageDecodeL(KMultiFrameClock);
00251 gConsole->Printf(KImageMaskAndMultiFrameImageDecode, &KMultiFrameClock);
00252
00253
00254 app->DecodeUsingSepThreadL(KBitmapFile);
00255 gConsole->Printf(KDecodeUsingSepThread);
00256
00257
00258 app->DecodeUsingContinueConvertL(KBitmapFile);
00259 gConsole->Printf(KSeparateThreadAndCancelAndContinueConvert, &KBitmapFile);
00260
00261
00262 app->AccessThumbnailToDecodeL(KThumbFile);
00263 gConsole->Printf(KAccessThumbnailToDecode);
00264
00265
00266 app->AccessExifMetadataL(KBitmapExif);
00267 gConsole->Printf(KAccessExifMetadata);
00268
00269
00270 app->DecodeTheThumbnailL(KThumbFile);
00271 gConsole->Printf(KAccessExifThumbnailAndDecodeThumbnail, &KThumbFile);
00272
00273
00274 app->DisplayingImageCommentsL(KBitmapComment);
00275 gConsole->Printf(KDisplayingImageComments);
00276
00277
00278 app->DisplayingFrameCommentsL(KBitmapFrameComment);
00279 gConsole->Printf(KImageAndFrameComment);
00280
00281
00282 app->GettingMimeTypeOfSourceDescriptorL(KBitmapFile);
00283 gConsole->Printf(KGettingMimeTypeOfSourceDescriptor);
00284
00285
00286 app->GettingMimeTypeOfSourceFileL(KBitmapFile);
00287 gConsole->Printf(KGettingMimeTypeFromSourceAndFile, &KBitmapFile);
00288
00289
00290 app->DecodeWithRotateL(KBitmapFile);
00291 gConsole->Printf(KFileRotateAfterDecode, &KBitmapFile);
00292
00293
00294 app->LoadPluginByUidL(KBitmapExif, KImageTypeJPGUid);
00295 gConsole->Printf(KPluginLoadedSpecificToUID);
00296
00297
00298 app->BlockStreamDecodeAndEncodeYuvFrameL(KYuvBitmap, KDestStreamFile);
00299 gConsole->Printf(KStreamYuv, &KYuvBitmap);
00300
00301
00302 app->ClipAndRotateDuringDecodeL();
00303
00304 gConsole->Printf(KPressAKey);
00305 gConsole->Getch();
00306
00307
00308
00309
00310
00311 gConsole->Printf(KEncode);
00312
00313
00314 app->EncodeBitmapToDescriptorL(KSourceBitmap);
00315 gConsole->Printf(KFileEncode, &KSourceBitmap);
00316
00317
00318 app->EncodeImageWithThumbnailL(KSourceBitmap);
00319 gConsole->Printf(KEncodeImageWithThumbnail);
00320
00321
00322 app->SettingExifMetadataL(KSourceBitmap);
00323 gConsole->Printf(KAccessToThumbnailAndExifSetting);
00324
00325
00326 app->RotateBitmapL(KSourceBitmap);
00327 gConsole->Printf(KFileRotate);
00328
00329
00330 app->ScaleBitmapL(KSourceBitmap);
00331 gConsole->Printf(KScaleBitmap);
00332
00333
00334 app->SetSourceDestinationandResizeL(KBitmapExif);
00335 gConsole->Printf(KSetSourceDestinationandResize);
00336
00337
00338 app->SettingWithUseOfPreserveImageDataL(KYuvBitmap,KYuvDestBitmap);
00339 gConsole->Printf(KSetSourceAndDestinationAndResize);
00340
00341
00342 app->AddThumbnailToJpegFileL(KBitmapExif, KYuvDestBitmap);
00343 gConsole->Printf(KAddThumbnailToJpegFile);
00344
00345
00346 app->AddExifDataToJpegFileL(KSourceBitmap);
00347 gConsole->Printf(KExifAndThumbnailAdded);
00348
00349
00350 app->EncodeBitmapToFileUsingOperationExtensionL(KBitmapRotateWhileEncodeToJpeg, KDestRotateFile);
00351 gConsole->Printf(KEncodeRotate, &KDestRotateFile);
00352
00353 gConsole->Printf(KPressAKey);
00354 gConsole->Getch();
00355
00356
00357
00358 gConsole->Printf(KGeneratingSpmo);
00359 app->GeneratingSpmoL();
00360
00361
00362 gConsole->Printf(KGeneratingSpmoIteratively);
00363 app->GeneratingSpmoIterativelyL();
00364
00365 gConsole->Printf(KPressAKey);
00366 gConsole->Getch();
00367
00368
00369
00370 _LIT(KFile1,"capsimageprocessorplugin.rsc");
00371 TInt imageProcessorPluginSupport;
00372 imageProcessorPluginSupport = file.FindByPath(KFile1(),&KPath());
00373 if(imageProcessorPluginSupport == KErrNone)
00374 {
00375 gConsole->Printf(KBasicImageProcessing);
00376 app->BasicImageProcessingL();
00377
00378 gConsole->Printf(KBasicEffectImageProcessing);
00379 app->BasicEffectImageProcessingL();
00380
00381 gConsole->Printf(KEffectImageProcessingWithUndo);
00382 app->EffectImageProcessingWithUndoL();
00383
00384 gConsole->Printf(KEffectImageProcessingWithPreview);
00385 app->EffectImageProcessingWithPreviewL();
00386
00387 gConsole->Printf(KEffectImageProcessingWithOverlay);
00388 app->EffectImageProcessingWithOverlayL();
00389
00390 gConsole->Printf(KImageProcessingWithSpmo);
00391 app->ImageProcessingWithSpmoL();
00392 }
00393
00394
00395 gConsole->Printf(KImageTransform);
00396
00397 _LIT(KFile2,"capsimagetransformplugin.rsc");
00398 TInt imageTransformPluginSupport;
00399 imageTransformPluginSupport = file.FindByPath(KFile2(),&KPath());
00400 if(imageTransformPluginSupport == KErrNone)
00401 {
00402 gConsole->Printf(KSqueezeFileToFile);
00403 app->SqueezeJpgFileToFileL(KSourceJpgDatetree, KSqueezeDestJpgDatetreeFileToFile);
00404
00405 gConsole->Printf(KSqueezeBufferToBuffer);
00406 app->SqueezeJpgBufferToBufferL(KSourceJpgDatetree, KSqueezeDestJpgDatetreeBufferToBuffer);
00407
00408 gConsole->Printf(KAutoSqueezeFileToFile);
00409 app->AutoSqueezeJpgFileToFileL(KSourceJpgCapstest, KAutoSqueezeDestJpgCapstest);
00410
00411 gConsole->Printf(KRotateFileToFile);
00412 app->RotateJpgFileToFileL(KSourceJpgCapstest, KRotate90DestJpgCapstest);
00413
00414 gConsole->Printf(KOverlayJpgDataFileToFile);
00415 app->OverlayJpgDataToJpgFileToFileL(KSourceJpgDatetree, KSourceJpgOverlay, KOverlayDestJpgDataFileToFile);
00416
00417 gConsole->Printf(KOverlayBmpDataFileToFile);
00418 app->OverlayBmpDataToJpgFileToFileL(KSourceJpgCapstest, KSourceMbmOverlay, KOverlayDestBitmapFileToFile);
00419
00420 gConsole->Printf(KOverlayPngFileToFile);
00421 app->OverlayPngFileToJpgFileToFileL(KSourceJpgCapstest, KSourcePngOverlay, KOverlayDestPngFileToFile);
00422 }
00423 gConsole->Printf(KExitMsg);
00424 gConsole->Getch();
00425 fsSession.Close();
00426 CleanupStack::PopAndDestroy(3);
00427 }
00428
00429
00430 GLDEF_C TInt E32Main()
00431 {
00432 __UHEAP_MARK;
00433
00434 CTrapCleanup* cleanup = CTrapCleanup::New();
00435 if (cleanup == NULL)
00436 {
00437 return KErrNoMemory;
00438 }
00439
00440 TRAPD(err, MainL());
00441
00442 delete cleanup;
00443 __UHEAP_MARKEND;
00444
00445 return err;
00446 }