class CThumbnailManager : public CBase |
Thumbnail engine.
This is the main interface class to thumbnail engine. Thumbnail engine can be used to request thumbnails for different kinds of media objects.
The client using thumbnail engine must implement the MThumbnailManagerObserver . The observer interface is used to provide thumbnail data when it is available.
creating an engine instance using NewL
setting thumbnail parameters using SetThumbnailSizeL() , SetFlags(), and so on
creating an object source ( CThumbnailObjectSource ) and using it to request thumbnails
handling MThumbnailManagerObserver callbacks when the thumbnail request is complete
Here is an example of how thumbnail engine could be used by a typical application:
#include <thumbnailmanagerobserver.h> #include <thumbnailmanager.h> class CMyThumbnailControl: public CCoeControl, public MThumbnailManagerObserver { public: CMyThumbnailControl(); ~CMyThumbnailControl(); ... // Callbacks from MThumbnailManagerObserver for getting thumbnails void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId ); void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ); private: void ConstructL(); CThumbnailManager* iManager; CFbsBitmap* iBitmap; } _LIT( KTestFilePath, "e:\\TestImage.jpg" ); _LIT( KTestFileType, "image/jpeg" ); void CMyThumbnailControl::ConstructL() { // Create Thumbnail Manager instance. This object is the observer. iManager = CThumbnailManager::NewL( *this ); // Set flags: If the aspect ratio of the media object does not match // 4:3 then we would like it to be cropped. We don t mind getting // smaller images than requested. iManager->SetFlagsL( CThumbnailManager::ECropToAspectRatio | CThumbnailManager::EAllowAnySize ); // Preferred size is 160x120 (or less) iManager->SetSizeL( TSize( 160, 120 ) ); // Get a preview thumbnail first, if available. // The preview thumbnail is delivered via a ThumbnailPreviewReady() // callback. iManager->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview ); // Create an object source representing a path to a file on local // file system. CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( KTestFilePath, // File path KTestFileType ); // Let Thumbnail Manager know it s a JPEG, so // it doesn t need to recognize the file format // Issue the request using default priority iManager->GetThumbnailL( *source ); // If GetThumbnailL() did not leave, the ThumbnailReady() callback is // now guaranteed to be called, unless the request is cancelled or // CThumbnailManager instance is deleted. // The source can be deleted immediately after issuing the request CleanupStack::PopAndDestroy( source ); } CMyThumbnailControl::~CMyThumbnailControl() { // Bitmap should be destroyed before Thumbnail Manager delete iBitmap; delete iManager; } void CMyThumbnailControl::ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ) { // This function must not leave. delete iBitmap; iBitmap = NULL; if ( !aError ) { // Claim ownership of the bitmap instance for later use iBitmap = aThumbnail.DetachBitmap(); // We can now use iBitmap in our Draw() method DrawDeferred(); } else { // An error occurred while getting the thumbnail. // Perhaps we should show a broken image icon to the user. } }
Public Member Enumerations | |
---|---|
enum | TThumbnailFlags { EDefaultFlags = 0, EAllowAnySize = 1, EDoNotCreate = 2, ECropToAspectRatio = 4 } |
enum | TThumbnailQualityPreference { EOptimizeForQuality , EOptimizeForPerformance , EOptimizeForQualityWithPreview } |
TInt | CancelRequest | ( | TThumbnailRequestId | aId | ) | [pure virtual] |
Cancel a thumbnail operation.
TThumbnailRequestId aId | Request ID for the operation to be cancelled. |
TInt | ChangePriority | ( | TThumbnailRequestId | aId, |
TInt | aNewPriority | |||
) | [pure virtual] |
Change the priority of a queued thumbnail operation.
TThumbnailRequestId aId | Request ID for the request which to assign a new priority. |
TInt aNewPriority | New priority value |
TThumbnailRequestId | CreateThumbnails | ( | CThumbnailObjectSource & | aObjectSource, |
TInt | aPriority = CActive::EPriorityIdle | |||
) | [pure virtual] |
Create thumbnail for a given object. This is an asynchronous operation, which always returns immediately. No callbacks are emitted.
CThumbnailObjectSource & aObjectSource | Source object or file |
TInt aPriority = CActive::EPriorityIdle | Priority for this operation |
void | DeleteThumbnails | ( | CThumbnailObjectSource & | aObjectSource | ) | [pure virtual] |
Delete all thumbnails for a given object. This is an asynchronous operation, which always returns immediately.
CThumbnailObjectSource & aObjectSource | Source object or file |
void | DeleteThumbnails | ( | const TThumbnailId | aItemId | ) | [pure virtual] |
Delete thumbnails by TThumbnailId. This is an asynchronous operation, which always returns immediately.
const TThumbnailId aItemId | TThumbnailId |
TDisplayMode | DisplayMode | ( | ) | const [pure virtual] |
Get the current display mode for thumbnail bitmaps.
TThumbnailFlags | Flags | ( | ) | const [pure virtual] |
Get current flags for thumbnail generation.
const CDesCArray & | GetSupportedMimeTypesL | ( | ) | [pure virtual] |
Get a list of supported file formats for object files.
The return value is a reference to a list that contains each supported MIME type. There may also be wildcards, such as "image/*".
The returned reference is valid until CThumbnailManager is destroyed or GetSupportedMimeTypesL() is called again.
TThumbnailRequestId | GetThumbnailL | ( | CThumbnailObjectSource & | aObjectSource, |
TAny * | aClientData = NULL, | |||
TInt | aPriority = CActive::EPriorityStandard | |||
) | [pure virtual] |
Get a thumbnail for an object file. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.
Current values for display mode, thumbnail size, flags and performance preference are used.
CThumbnailObjectSource & aObjectSource | Source object or file |
TAny * aClientData = NULL | Pointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback. |
TInt aPriority = CActive::EPriorityStandard | Priority for this operation |
TThumbnailRequestId | GetThumbnailL | ( | const TThumbnailId | aThumbnailId, |
TAny * | aClientData = NULL, | |||
TInt | aPriority = CActive::EPriorityStandard | |||
) | [pure virtual] |
Get a persistent thumbnail for an object file. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.
Current values for display mode, thumbnail size, flags and performance preference are used.
const TThumbnailId aThumbnailId | Thumbnail ID |
TAny * aClientData = NULL | Pointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback. |
TInt aPriority = CActive::EPriorityStandard | Priority for this operation |
TThumbnailRequestId | ImportThumbnailL | ( | CThumbnailObjectSource & | aObjectSource, |
const TDesC & | aTargetUri, | |||
TAny * | aClientData = NULL, | |||
TInt | aPriority = CActive::EPriorityIdle | |||
) | [pure virtual] |
Import an image to be used as thumbnail for an object. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.
Current values for display mode, thumbnail size, flags and performance preference are used.
CThumbnailObjectSource & aObjectSource | Source object or file |
const TDesC & aTargetUri | Target URI to which the imported thumbnail is linked. |
TAny * aClientData = NULL | Pointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback. |
TInt aPriority = CActive::EPriorityIdle | Priority for this operation |
IMPORT_C CThumbnailManager * | NewL | ( | MThumbnailManagerObserver & | aObserver | ) | [static] |
Two-phased constructor.
MThumbnailManagerObserver & aObserver | Observer to receive notifications about completed operations. |
IMPORT_C CThumbnailManager * | NewLC | ( | MThumbnailManagerObserver & | aObserver | ) | [static] |
Two-phased constructor.
MThumbnailManagerObserver & aObserver | Observer to receive notifications about completed operations. |
TThumbnailQualityPreference | QualityPreference | ( | ) | const [pure virtual] |
Get the current quality versus performance preference.
void | RemoveRequestObserver | ( | ) | [pure virtual] |
Remove optional request observer.
TThumbnailRequestId | RenameThumbnailsL | ( | const TDesC & | aCurrentPath, |
const TDesC & | aNewPath, | |||
TInt | aPriority = CActive::EPriorityIdle | |||
) | [pure virtual] |
Rename Thumbnails. This is an asynchronous operation, which always returns immediately.
void | SetDisplayModeL | ( | TDisplayMode | aDisplayMode | ) | [pure virtual] |
Set the current display mode for thumbnail bitmaps.
TDisplayMode aDisplayMode | New display mode value for the thumbnail bitmaps. |
void | SetFlagsL | ( | TThumbnailFlags | aFlags | ) | [pure virtual] |
Set flags for thumbnail generation. Several flags may be enabled by combining the values using bitwise or.
TThumbnailFlags aFlags | New flags. |
void | SetQualityPreferenceL | ( | TThumbnailQualityPreference | aQualityPreference | ) | [pure virtual] |
Set quality versus performance preference.
TThumbnailQualityPreference aQualityPreference | New quality versus performance preference value. |
void | SetRequestObserver | ( | MThumbnailManagerRequestObserver & | aObserver | ) | [pure virtual] |
Set optional request observer for getting information about completed requests that don't include a thumbnail.
MThumbnailManagerRequestObserver & aObserver | Observer to receive notifications. |
TThumbnailRequestId | SetThumbnailL | ( | CThumbnailObjectSource & | aObjectSource, |
TAny * | = NULL, | |||
TInt | aPriority = CActive::EPriorityIdle | |||
) | [pure virtual] |
Set a thumbnail for an object file generated from buffer delivered in source object. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.
Current values for display mode, thumbnail size, flags and performance preference are used.
CThumbnailObjectSource & aObjectSource | |
TAny * = NULL | |
TInt aPriority = CActive::EPriorityIdle | Priority for this operation |
void | SetThumbnailSizeL | ( | const TSize & | aThumbnailSize | ) | [pure virtual] |
Set desired size for thumbnail bitmaps.
const TSize & aThumbnailSize | New quality for the desired thumbnail size. |
void | SetThumbnailSizeL | ( | const TThumbnailSize | aThumbnailSize | ) | [pure virtual] |
Set desired size for thumbnail bitmaps.
const TThumbnailSize aThumbnailSize | Desired thumbnail size. |
const TSize & | ThumbnailSize | ( | ) | const [pure virtual] |
Get the current desired size for thumbnail bitmaps.
void | UpdateThumbnailsL | ( | const TThumbnailId | aItemId, |
const TDesC & | aPath, | |||
const TInt | aOrientation, | |||
const TInt64 | aModified, | |||
const TInt | aPriority | |||
) | [pure virtual] |
Update Thumbnails by TThumbnailId. This is an asynchronous operation, which always returns immediately.
const TThumbnailId aItemId | TThumbnailId |
const TDesC & aPath | (New) path for the Thumbnail |
const TInt aOrientation | Thumbnail orientation |
const TInt64 aModified | Last modified |
const TInt aPriority |
Flags for thumbnail creation. These can be combined using bitwise or.
EDefaultFlags = 0 |
Default flags. This means that:
|
EAllowAnySize = 1 |
Allow thumbnails which are smaller than requested are. Thumbnail bitmaps are never up scaled if this flag is set. |
EDoNotCreate = 2 |
New thumbnail images are not created if this flag is set. Only existing thumbnails may be returned. If a requested thumbnail does not exist, KErrNotFound error is returned in ThumbnailReady() callback. |
ECropToAspectRatio = 4 |
Thumbnail images are cropped to match requested aspect ratio. If this flag is set, the size of the resulting thumbnail always matches the requested size. |
Quality versus speed preference setting
EOptimizeForQuality |
Prefer thumbnails in the highest quality possible disregarding any negative impact on performance. |
EOptimizeForPerformance |
Get thumbnails as fast as possible, even if it means lower quality. |
EOptimizeForQualityWithPreview |
Get lower quality preview thumbnail as fast as possible first and then a higher quality thumbnail later. The preview thumbnail is provided in the ThumbnailPreviewReady() callback and the high quality thumbnail in ThumbnailReady(). ThumbnailPreviewReady() is not get called at all if a suitable existing thumbnail is not found or if a high quality version is already available. |
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.