engine/collectionframework/thumbnailcreator/inc/glxtnimageutility.h
changeset 71 27f2d7aec52a
parent 69 45459746d5e8
child 72 0a8e959402e5
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
     1 /*
       
     2 * Copyright (c) 2008-2009 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:   Utility for creating bitmaps from image files
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @internal reviewed 30/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #ifndef GLXTNIMAGEUTILITY_H
       
    25 #define GLXTNIMAGEUTILITY_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <gdi.h>        // For TDisplayMode
       
    29 
       
    30 class MIHLScaler;
       
    31 class CFbsBitmap;
       
    32 class CFbsBitGc;
       
    33 class CImageDecoder;
       
    34 class RFs;
       
    35 
       
    36 /**
       
    37  * Utility for creating bitmaps from image files
       
    38  *
       
    39  * @ingroup glx_thumbnail_creator
       
    40  */
       
    41 NONSHARABLE_CLASS(CGlxtnImageUtility) : public CBase
       
    42     {
       
    43 public:
       
    44     CGlxtnImageUtility(RFs& aFs);
       
    45     ~CGlxtnImageUtility();
       
    46 
       
    47     void Cancel();
       
    48 
       
    49     /**
       
    50     * Reduce target size to same aspect ratio as source image.
       
    51     */
       
    52     void AdjustSize(TSize& aTargetSize, const TSize& aSourceSize);
       
    53 
       
    54     /**
       
    55     * Start asynchronous decoding process for a high quality thumbnail.
       
    56     * @param aStatus Request status for the asynchronous operation.
       
    57     * @param aFileName Full path of image file.
       
    58     * @param aTargetSize Size for the image - modified by this function to
       
    59     *           preserve the aspect ratio.
       
    60     * @param aMode Display mode for the image.
       
    61     */
       
    62     CFbsBitmap* DecodeImageL(TRequestStatus& aStatus, const TDesC& aFileName,
       
    63                                 RArray<TSize>& aTargetSizes, TDisplayMode aMode);
       
    64 
       
    65     /**
       
    66     * Free resources used by decoding.
       
    67     */
       
    68     void FreeDecoder();
       
    69 
       
    70     /**
       
    71     * Get the original size of the image decoded.
       
    72     */
       
    73     const TSize& OriginalSize() const;
       
    74 
       
    75     /**
       
    76     * Start asynchronous filtering process for a high quality thumbnail.
       
    77     * @param aStatus Request status for the asynchronous operation.
       
    78     * @param aSource Source image bitmap.
       
    79     * @param aFilteredSource Filtered  image bitmap.
       
    80     * @param aTarget Target thumbnail bitmap.
       
    81     */
       
    82     void FilterImageL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, CFbsBitmap* aTarget);
       
    83     
       
    84     /**
       
    85     * Start asynchronous scaling process for a high quality thumbnail.
       
    86     * @param aStatus Request status for the asynchronous operation.
       
    87     * @param aSrcBitmap Source image bitmap.
       
    88     * @param aSrcRect Source image rectangle.
       
    89     * @param aDstBitmap Destination thumbnail bitmap.
       
    90     * @param aDstRect Destination image rectangle.
       
    91     */
       
    92 	void ScaleImageL(TRequestStatus& aStatus, CFbsBitmap& aSrcBitmap, const TRect& aSrcRect, CFbsBitmap& aDstBitmap, const TRect& aDstRect);
       
    93 
       
    94     /**
       
    95     * Start asynchronous scaling process for a high quality thumbnail.
       
    96     * @param aStatus Request status for the asynchronous operation.
       
    97     * @param aSource Source image bitmap.
       
    98     * @param aFilteredSource Filtered Source image bitmap.
       
    99     * @param aTarget Target thumbnail bitmap.
       
   100     */
       
   101     void ScaleImage64kL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap* aFilteredSource, CFbsBitmap* aTarget);
       
   102 
       
   103 private:
       
   104     
       
   105     void ScaleColor64K( TUint16* aSrc, TInt aSrcStride, TInt aSrcCols, TInt aSrcRows,
       
   106 	  								TInt aX, TInt aY, TInt aW, TInt aH,
       
   107           		      TUint16* aDst, TInt aDstStride, TInt aDstCols, TInt aDstRows );
       
   108           		      
       
   109     void FilterL( CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, TInt aFilterPercent );
       
   110 
       
   111     void FIRFiltering(
       
   112 		TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows );
       
   113 
       
   114     void FIRFiltering4(
       
   115 		TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows );
       
   116 
       
   117     void FIRFiltering8(
       
   118 		TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows );
       
   119 
       
   120 private:
       
   121     // File server session
       
   122     RFs& iFs;
       
   123     // Decoder used to read image from file
       
   124     CImageDecoder* iDecoder;
       
   125     // Bitmap scaler
       
   126     MIHLScaler* iScaler;
       
   127     /** Size of the image in the file being decoded */
       
   128     TSize iOriginalSize;
       
   129     CFbsBitmap* iImage;
       
   130     TUint16* iAddress;
       
   131     CFbsBitGc* iBitGc;
       
   132     };
       
   133 
       
   134 #endif  // GLXTNIMAGEUTILITY_H