This topic provides an example of storing a picture in a direct file store (including the creation of a picture header).
_LIT(KFileName,"C:\\grpict.dat"); // Create (replace, if it exists) the direct file store CDirectFileStore* store = CDirectFileStore::ReplaceLC(fsSession,KFileName,EFileWrite); // Must say what kind of file store. iStore->SetTypeL(KDirectFileStoreLayoutUid); // Create picture header TPictureHeader header; header.iPicture = iPicture; header.iSize = TSize(iPicture->SpecToFactor()*40,iPicture->SpecToFactor()*40); header.iPictureType = KUidExampleSmileyPicture; // Store picture header and picture CStoreMap* map=CStoreMap::NewLC(*store); TStreamId id = iPicture->StoreL(*store); map->BindL(iPicture,id); RStoreWriteStream stream(*map); TStreamId headerId = stream.CreateLC(*store); header.ExternalizeL(stream); stream.CommitL(); map->Reset(); CleanupStack::PopAndDestroy(2); // stream, map // Make header stream the root stream store->SetRootL(headerId); // Close store CleanupStack::PopAndDestroy();
Create a direct file store into which to store the picture.
Create a picture header object and set its attributes: iPicture is assumed to be picture object, derived from CPicture.
Store the picture header and picture in the file store.
Store the picture data and picture header using a store map as a temporary repository for the stream ID of the picture data stream. Store the stream ID as an element of the picture header's externalized stream to link the picture header’s stream and the picture data’s stream.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.