diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/iclspmoexample_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/iclspmoexample_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ - -
-00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -00002 // All rights reserved. -00003 // This component and the accompanying materials are made available -00004 // under the terms of "Eclipse Public License v1.0" -00005 // which accompanies this distribution, and is available -00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". -00007 // -00008 // Initial Contributors: -00009 // Nokia Corporation - initial contribution. -00010 // -00011 // Contributors: -00012 // -00013 // Description: -00014 // iclimageprocessorexample.cpp -00015 // The code demonstrates Caps Spmo Utility functionality -00016 // -00017 -00018 -00019 -00024 #include "iclexample.h" -00025 #include <capsspmoutility/capsspmoutility.h> -00026 -00027 using namespace CapsSpmoUtility; -00028 -00029 void CIclExample::GeneratingSpmoL() -00030 { -00031 // Start new spmo optimized for QVGA screen size. -00032 CCapsSpmo* spmo = CapsSpmoUtility::CCapsSpmoUtility::NewSpmoL(TSize(320, 240)); -00033 CleanupStack::PushL(spmo); -00034 -00035 // Generate spmo data from the input file -00036 spmo->SetInputL(KInputFileName); -00037 spmo->GenerateFromInputL(); -00038 -00039 // Add the generated Spmo data to the output file. -00040 spmo->AddToFileL(KInputWithSpmoFileName); -00041 -00042 CleanupStack::PopAndDestroy(spmo); -00043 } -00044 -00045 #define CHUNK_SIZE 8192 -00046 void CIclExample::GeneratingSpmoIterativelyL() -00047 { -00048 // Start new spmo optimized for QVGA screen size. -00049 CCapsSpmo* spmo = CapsSpmoUtility::CCapsSpmoUtility::NewSpmoL(TSize(320, 240)); -00050 CleanupStack::PushL(spmo); -00051 -00052 RFile file; -00053 TInt fileSize = 0; -00054 -00055 // Open the file for reading. -00056 User::LeaveIfError(file.Open(iFs, KInputFileName, EFileRead)); -00057 CleanupClosePushL(file); -00058 -00059 User::LeaveIfError(file.Size(fileSize)); -00060 -00061 // Prepare memory buffer for 8K chunk -00062 HBufC8* chunk = HBufC8::NewMaxL(CHUNK_SIZE); -00063 TPtr8 chunkPtr = chunk->Des(); -00064 -00065 // We must reorder the cleanupstack. -00066 CleanupStack::Pop(); // file -00067 CleanupStack::PushL(chunk); -00068 CleanupClosePushL(file); -00069 -00070 if (file.SubSessionHandle()) -00071 { -00072 // Begin spmo streaming -00073 spmo->BeginInputStreamL(); -00074 -00075 TInt leftToRead = fileSize; -00076 while (leftToRead >= CHUNK_SIZE) -00077 { -00078 leftToRead -= CHUNK_SIZE; -00079 User::LeaveIfError(file.Read(chunkPtr, CHUNK_SIZE)); -00080 spmo->ContinueInputStreamL(chunkPtr); -00081 } -00082 -00083 if (leftToRead != 0) -00084 { -00085 User::LeaveIfError(file.Read(chunkPtr, leftToRead)); -00086 spmo->ContinueInputStreamL(chunkPtr); -00087 } -00088 -00089 spmo->EndInputStreamL(); -00090 } -00091 -00092 // Generate spmo data from the processed input stream. -00093 spmo->GenerateFromInputL(); -00094 -00095 CleanupStack::PopAndDestroy(2); // file chunk -00096 -00097 // Get just generated spmo data and save it to a binary file. -00098 TPtr8 spmoData = spmo->BufferL(); -00099 -00100 // Open the file for writing. -00101 User::LeaveIfError(file.Replace(iFs, KSpmoFileName, EFileWrite)); -00102 CleanupClosePushL(file); -00103 -00104 User::LeaveIfError(file.Write(spmoData)); -00105 -00106 CleanupStack::PopAndDestroy(2,spmo); // file spmo -00107 } -