uifw/AknGlobalUI/OldStyleNotif/Inc/AknPrivateImageLoader.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Private image loader to convert binary array into usable image
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAKNPRIVATEIMAGELOADER_H
       
    20 #define CAKNPRIVATEIMAGELOADER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 class CEikImage;
       
    28 class CImageDecoder;
       
    29 class CFbsBitmap;
       
    30 class CAknIcon;
       
    31 class MSvgError;
       
    32 class TFrameInfo;
       
    33 
       
    34 
       
    35 /**
       
    36  * Observer interface for CAknPrivateImageLoader.
       
    37  * 
       
    38  * @since S60 3.2
       
    39  * @lib AknOldStyleNotif.DLL
       
    40  */
       
    41 class MAknPrivateImageLoaderObserver
       
    42     {
       
    43 public:
       
    44     /**
       
    45      * Called when image loading has succeeded.
       
    46      * @param aImage Newly loaded image. Observer is responsible of
       
    47      *        taking the ownership of the image.
       
    48      */
       
    49     virtual void ImageLoadSuccess( CEikImage* aImage ) = 0;
       
    50     
       
    51     /**
       
    52      * Called when image loading has failed. 
       
    53      * @param aError General Symbian error code. 
       
    54      */
       
    55     virtual void ImageLoadError( TInt aError ) = 0;
       
    56     
       
    57 protected:
       
    58     /// virtual destructor
       
    59     virtual ~MAknPrivateImageLoaderObserver() {};
       
    60     };
       
    61 
       
    62 
       
    63 /**
       
    64  * Private image loader to convert binary array into usable image. Used by 
       
    65  * dynamic soft notification. Supports CImageDecoder formats + SVG images.
       
    66  * 
       
    67  * @since S60 3.2
       
    68  * @lib AknOldStyleNotif.DLL
       
    69  */
       
    70 NONSHARABLE_CLASS( CAknPrivateImageLoader ) : public CActive
       
    71     {
       
    72 public: // Construction & destruction
       
    73 
       
    74     /**
       
    75      * Constructor.
       
    76      * 
       
    77      * @param aFs Valid file server handle.
       
    78      * @param aObserver Image loader observer.
       
    79      */
       
    80     static CAknPrivateImageLoader* NewL( RFs& aFs,
       
    81         MAknPrivateImageLoaderObserver& aObserver );
       
    82 
       
    83     /**
       
    84      * Constructor.
       
    85      * 
       
    86      * @param aFs Valid file server handle.
       
    87      * @param aObserver Image loader observer.
       
    88      */
       
    89     static CAknPrivateImageLoader* NewLC( RFs& aFs,
       
    90         MAknPrivateImageLoaderObserver& aObserver );
       
    91 
       
    92     /**
       
    93      * Destructor.
       
    94      */
       
    95     virtual ~CAknPrivateImageLoader();
       
    96 
       
    97 
       
    98 public: // new methods
       
    99     
       
   100     /**
       
   101      * Create scalable bitmap from binary data. This operation is asynchronous.
       
   102      * When image loading is complete, it will be reported to observer.
       
   103      * 
       
   104      * @param aImageData Image data.
       
   105      *        - If image data is bitmap and it's bigger than 300x300, then 
       
   106      *          leave KErrTooBig will occur.
       
   107      * @param aSize Preferred size
       
   108      *        - will determine the size of svg images
       
   109      *        - bitmaps will be scaled down to as close as possible to this size
       
   110      */    
       
   111     void LoadIconL( const TDesC8& aImageData, TSize aSize );
       
   112     
       
   113 private: // From CActive
       
   114     void RunL();
       
   115     void DoCancel();
       
   116     TInt RunError( TInt aError ); 
       
   117     
       
   118 private: // new methods
       
   119 
       
   120     /**
       
   121      * Constructor.
       
   122      * 
       
   123      * @param aFs Valid file server handle.
       
   124      * @param aObserver Observer for image loader.
       
   125      */
       
   126     CAknPrivateImageLoader( RFs& aFs,
       
   127         MAknPrivateImageLoaderObserver& aObserver );
       
   128 
       
   129     /**
       
   130      * Constructor.
       
   131      */
       
   132     void ConstructL();
       
   133     
       
   134     /**
       
   135      * Inverts pixels of given image (bit operation).
       
   136      * @aBitmap Inverted image.
       
   137      */
       
   138     void InvertImageL( CFbsBitmap& aBitmap );
       
   139     
       
   140     /**
       
   141      * Creates a scalable icon from bitmap image.
       
   142      *  
       
   143      * @param aIcon Non-scalable bitmap and mask. mask is optional.
       
   144      *        Note! takes ownership of aIcon (leave safe)
       
   145      * @return New scalable icon instance.
       
   146      */
       
   147     CAknIcon* CreateIconL( CAknIcon* aIcon ); 
       
   148     
       
   149     /**
       
   150      * Create bitmap from binary data.
       
   151      * 
       
   152      * @param aImageData Image data.
       
   153      *        - If bitmap is bigger than 300x300, then 
       
   154      *          leave KErrTooBig will occur.
       
   155      * @param aSize Preferred load size. Loader will try to shrink the loaded 
       
   156      *        image to aSize or as close to it as possible.
       
   157      */    
       
   158     void LoadL( const TDesC8& aImageData, TSize aSize );
       
   159     
       
   160     /**
       
   161      * Create SVG image from binary data.
       
   162      * 
       
   163      * @param aImageData Image data.
       
   164      * @param aSize Preferred size of the new icon.
       
   165      */        
       
   166     void LoadSVGImageL(    
       
   167         const TDesC8& aImageData, 
       
   168         TSize aSize );
       
   169 
       
   170     /**
       
   171      * Leaves with KErrCorrupt if given svg engine error is actual error.
       
   172      * 
       
   173      * @param aError SVG engine error object.
       
   174      */
       
   175     void LeaveIfErrorL( MSvgError* aError );
       
   176 
       
   177     /**
       
   178      * Generate a fully transparent mask.
       
   179      * 
       
   180      * @param aSize Mask's size.
       
   181      * @return Created mask.
       
   182      */
       
   183     CFbsBitmap* GenerateMaskLC( TSize aSize );
       
   184 
       
   185     /**
       
   186      * Get decoder size for CImageDecoder. Returns the closest possible size to
       
   187      * aTargetSize for decoder. Image will not be scaled upwards.
       
   188      * 
       
   189      * @param aFrameInfo Decoded images frame info.
       
   190      * @param aTargetSize TargetSize to decode.
       
   191      * @return New size used to decoded image.
       
   192      */
       
   193     TSize DecodeSize( const TFrameInfo& aFrameInfo, const TSize& aTargetSize );
       
   194     
       
   195 private: // data
       
   196     /// Own. Currently loaded image
       
   197     CAknIcon* iIcon;
       
   198     /// Own. Image loader/decoder.
       
   199     CImageDecoder* iDecoder;
       
   200     /// Not own. Image loading observer.
       
   201     MAknPrivateImageLoaderObserver& iObserver;
       
   202     /// Not own. File system handle
       
   203     RFs& iFs;
       
   204     };
       
   205 
       
   206 #endif // CAKNPRIVATEIMAGELOADER_H