imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimagedecoder.h
changeset 0 2014ca87e772
child 5 82749d516180
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Image thumbnail decoder.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILIMAGEDECODER_H
       
    20 #define THUMBNAILIMAGEDECODER_H
       
    21 
       
    22 #include "thumbnailprovider.h"
       
    23 
       
    24 class CImageDecoder;
       
    25 class CFbsBitmap;
       
    26 
       
    27 // Size of buffer to load from file start to get EXIF thumbnail
       
    28 const TInt KJpegLoadBufferSize = 64 * 1024;
       
    29 
       
    30 
       
    31 /**
       
    32  *  Image thumbnail decoder.
       
    33  *
       
    34  *  @since S60 v5.0
       
    35  */
       
    36 class CThumbnailImageDecoder: public CActive
       
    37     {
       
    38 public:
       
    39 
       
    40     /**
       
    41      * C++ default constructor
       
    42      *
       
    43      * @since S60 v5.0
       
    44      * @param aFs File server session
       
    45      * @return New image thumbnail decoder instance.
       
    46      */
       
    47     CThumbnailImageDecoder( RFs& aFs );
       
    48 
       
    49     /**
       
    50      * Destructor
       
    51      *
       
    52      * @since S60 v5.0
       
    53      */
       
    54     virtual ~CThumbnailImageDecoder();
       
    55 
       
    56     /**
       
    57      * Creates a decoder from the given image file and gets image
       
    58      * information
       
    59      *
       
    60      * @since S60 v5.0
       
    61      * @param aFile Source image file.
       
    62      * @param aObserver Observer to relay notifications about completed
       
    63      *                  operations.
       
    64      * @param aFlags Decoding option flags.
       
    65      * @param aMimeType Mime-type of image to be decoded.
       
    66      * @param aSize desired size of thumbnail.
       
    67      * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only)
       
    68      */
       
    69     void CreateL( RFile64& aFile, MThumbnailProviderObserver& aObserver, const
       
    70         CThumbnailManager::TThumbnailQualityPreference aFlags, const TDataType& aMimeType,
       
    71         const TSize& aSize );
       
    72 
       
    73     /**
       
    74      * Creates a decoder from the given image buffer and gets image
       
    75      * information
       
    76      *
       
    77      * @since S60 v5.0
       
    78      * @param aBuffer Source image buffer.
       
    79      * @param aObserver Observer to relay notifications about completed
       
    80      *                  operations.
       
    81      * @param aFlags Decoding option flags.
       
    82      * @param aMimeType Mime-type of image to be decoded.
       
    83      * @param aSize desired size of thumbnail.
       
    84      * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only)
       
    85      */    
       
    86     void CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver&
       
    87         aObserver, const CThumbnailManager::TThumbnailQualityPreference aFlags, const
       
    88         TDataType& aMimeType, const TSize& aSize);    
       
    89     
       
    90     /**
       
    91      * Decode image.
       
    92      *
       
    93      * @since S60 v5.0
       
    94      * @param aDisplayMode Preferred display mode.
       
    95      */
       
    96     void DecodeL( const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailFlags aFlags );
       
    97 
       
    98     /**
       
    99      * Returns the size of original image.
       
   100      *
       
   101      * @since S60 v5.0
       
   102      * @return Size of original image.
       
   103      */
       
   104     const TSize& OriginalSize()const;
       
   105 
       
   106 private:
       
   107     /**
       
   108      * Used to release reserved resources.
       
   109      *
       
   110      * @since S60 v5.0
       
   111      */
       
   112     void Release();
       
   113 
       
   114     /**
       
   115      * Implements cancellation of an outstanding request.
       
   116      *
       
   117      * @since S60 v5.0
       
   118      */
       
   119     void DoCancel();
       
   120 
       
   121     /**
       
   122      * Handles an active object's request completion event.
       
   123      *
       
   124      * @since S60 v5.0
       
   125      */
       
   126     void RunL();
       
   127 
       
   128     /**
       
   129      * Used to check if source is jpg/jpeg image.
       
   130      *
       
   131      * @since S60 v5.0
       
   132      * @return ETrue if image was jpg/jpeg format, otherwise EFalse
       
   133      */
       
   134     TBool IsJpeg();
       
   135 
       
   136     /**
       
   137      * Used to check if source is svg image.
       
   138      *
       
   139      * @since S60 v5.0
       
   140      * @return ETrue if image was in svg format, otherwise EFalse
       
   141      */
       
   142     TBool IsSvg();
       
   143 
       
   144     /**
       
   145      * Creates image decoder to be used.
       
   146      *
       
   147      * @since S60 v5.0
       
   148      */
       
   149     void CreateDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags );
       
   150 
       
   151     /**
       
   152      * Creates ExifDecoder.
       
   153      *
       
   154      * @since S60 v5.0
       
   155      */
       
   156     void CreateExifDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags );
       
   157 
       
   158 private:
       
   159     // data
       
   160 
       
   161     /**
       
   162      * Requested size.
       
   163      */
       
   164     TSize iSize;
       
   165 
       
   166     /**
       
   167      * Image decoder.
       
   168      * Own.
       
   169      */
       
   170     CImageDecoder* iDecoder;
       
   171 
       
   172     /**
       
   173      * Decoded bitmap.
       
   174      * Own.
       
   175      */
       
   176     CFbsBitmap* iBitmap;
       
   177 
       
   178     /**
       
   179      * Image info flags (from TFrameInfo)
       
   180      */
       
   181     TUint32 iFrameInfoFlags;
       
   182 
       
   183     /**
       
   184      * Original size of the image in pixels.
       
   185      */
       
   186     TSize iOriginalSize;
       
   187 
       
   188     /**
       
   189      * Buffer for reading the beginning of a JPEG file to get the
       
   190      * EXIF thumbnail data.
       
   191      */
       
   192     HBufC8* iJpegReadBuffer;
       
   193 
       
   194     /**
       
   195      * EXIF thumbnail image compressed as JPEG
       
   196      */
       
   197     HBufC8* iExifThumbImage;
       
   198 
       
   199     /**
       
   200      * Used fileserver.
       
   201      */
       
   202     RFs& iFs;
       
   203 
       
   204     /**
       
   205      * File from which thumbnail is to be created.
       
   206      */
       
   207     RFile64 iFile;
       
   208 
       
   209     /**
       
   210      * Buffer from which thumbnail is to be created.
       
   211      */    
       
   212     const TDesC8* iBuffer;
       
   213 
       
   214     /**
       
   215      * Observer.
       
   216      */
       
   217     MThumbnailProviderObserver* iObserver; // not own
       
   218 
       
   219     /**
       
   220      * Mime-type.
       
   221      */
       
   222     TDataType iMimeType;
       
   223 
       
   224      /**
       
   225      * Is origin EXIF
       
   226      */
       
   227     TBool iEXIF;
       
   228     
       
   229     /**
       
   230      * Portrait image
       
   231      */    
       
   232     TBool iPortrait;
       
   233 };
       
   234 
       
   235 #endif // THUMBNAILIMAGEDECODER_H