internetradio2.0/uicontrolsinc/irimageconverter.h
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2008-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:  Image converter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCIRIMAGECONVERTER_H
       
    20 #define CCIRIMAGECONVERTER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class CFbsBitmap;
       
    25 class MIRImageConverterObserver;
       
    26 
       
    27 /**
       
    28  * Image converter.
       
    29  * 
       
    30  * This class is used to convert raw image data to more Symbian-friendly CFbsBitmap format, also
       
    31  * providing scaling support at the same time.
       
    32  * 
       
    33  * Supported image types include, but are not limited to, BMP, GIF, JPEG, TIFF, PNG and SVG-T.
       
    34  * 
       
    35  * Full animation support is available for GIF and SVG-T image types.
       
    36  */
       
    37 NONSHARABLE_CLASS( CIRImageConverter ) : public CBase
       
    38     {
       
    39 
       
    40 public:
       
    41 
       
    42     /**
       
    43      * Two-phased constructor.
       
    44      * 
       
    45      * By default, enables animations and maintains aspect ratio for all conversions.
       
    46      * 
       
    47      * @return  The created object. Ownership is transferred to the caller.
       
    48      */
       
    49     static CIRImageConverter* NewL();
       
    50 
       
    51     /**
       
    52      * Destructor.
       
    53      * 
       
    54      * Cancels any conversions currently in progress without notifying the observer.
       
    55      */
       
    56     ~CIRImageConverter();
       
    57 
       
    58     /**
       
    59      * Sets the raw image data to be converted.
       
    60      * 
       
    61      * Does not make a copy of the data supplied, so care must be taken to ensure its
       
    62      * existence until image conversion is completed.
       
    63      */
       
    64     void SetDataL( const TDesC8& aData );
       
    65     
       
    66     /**
       
    67      * Sets the image conversion observer.
       
    68      * 
       
    69      * If set, the observer is notified of all pertinent conversion events.
       
    70      * 
       
    71      * @param   aObserver           Observer to set.
       
    72      */
       
    73     void SetObserver( MIRImageConverterObserver* aObserver );
       
    74     
       
    75     /**
       
    76      * Enables or disables animations.
       
    77      * 
       
    78      * Must be used before starting the conversion. Trying to toggle the animation
       
    79      * state while the conversion is in progress will result in a panic in debug builds.
       
    80      * 
       
    81      * @param   aEnable             Flag to enable or disable animations. 
       
    82      */
       
    83     void EnableAnimations( TBool aEnable );
       
    84 
       
    85     /**
       
    86      * Return a flag indicating whether the current raw image data is animated.
       
    87      * 
       
    88      * @return  Flag indicating whether the current raw image data is animated.
       
    89      */
       
    90     TBool IsAnimated() const;
       
    91     
       
    92     /**
       
    93      * Enables or disables maintaining the aspect ratio when scaling.
       
    94      * 
       
    95      * Must be used before starting the conversion. Trying to toggle the animation
       
    96      * state while the conversion is in progress will result in a panic in debug builds.
       
    97      *
       
    98      * @param   aMaintain           Flag to enable or disable maintaining the aspect ratio. 
       
    99      */
       
   100     void MaintainAspectRatio( TBool aMaintain );
       
   101     
       
   102     /**
       
   103      * Starts the image conversion.
       
   104      * 
       
   105      * Must be called after SetDataL has been successfully called to initiate the
       
   106      * actual conversion. Trying to start a conversion when one is already in progress
       
   107      * will cause a leave, so calling Stop beforehand is advisable.
       
   108      * 
       
   109      * @param   aTarget             Image target size in pixels.
       
   110      * @param   aId                 Identifier used to notify the observer with. 
       
   111      */
       
   112     void StartL( const TSize& aTarget, TInt aId = KErrUnknown );
       
   113 
       
   114     /**
       
   115      * Stops the conversion.
       
   116      * 
       
   117      * Does nothing if no conversions are currently in progress. Notifies the observer
       
   118      * with KErrCancel if a conversion was cancelled.
       
   119      */
       
   120     void Stop();
       
   121 
       
   122     /**
       
   123      * Returns the converted bitmap.
       
   124      * 
       
   125      * Returns a NULL pointer when a conversion has not yet completed successfully.
       
   126      * 
       
   127      * @return  The converted bitmap. Ownership is not transferred to the caller.
       
   128      */
       
   129     const CFbsBitmap* Bitmap() const;
       
   130     
       
   131     /**
       
   132      * Returns the converted mask.
       
   133      * 
       
   134      * Returns a NULL pointer when a conversion has not yet completed successfully.
       
   135      * 
       
   136      * @return  The converted mask. Ownership is not transferred to the caller.
       
   137      */
       
   138     const CFbsBitmap* Mask() const;
       
   139     
       
   140     /**
       
   141      * Transfers ownership of the converted bitmap and mask to the caller.
       
   142      * 
       
   143      * NULL pointers are returned if a conversion has not yet completed successfully.
       
   144      * 
       
   145      * Any calls to either Bitmap or Mask methods after this will return a NULL pointer
       
   146      * until another conversion has been completed successfully.
       
   147      * 
       
   148      * @param   aBitmap             On return, contains the converted bitmap.
       
   149      *                              Ownership is tranferred to the caller.
       
   150      * @param   aBitmap             On return, contains the converted mask.
       
   151      *                              Ownership is tranferred to the caller.
       
   152      */
       
   153     void TransferBitmapOwnership( CFbsBitmap*& aBitmap, CFbsBitmap*& aMask );
       
   154     
       
   155 private:
       
   156 
       
   157     /**
       
   158      * Constructor.
       
   159      */
       
   160     CIRImageConverter();
       
   161     
       
   162     /**
       
   163      * Second-phase constructor.
       
   164      */
       
   165     void ConstructL();
       
   166 
       
   167 private:
       
   168 
       
   169     /**
       
   170      * Image converter private data.
       
   171      * Owned.
       
   172      */
       
   173     struct TIRImageConverterPrivateData;
       
   174     TIRImageConverterPrivateData* iData;
       
   175     
       
   176     };
       
   177 
       
   178 #endif // CCIRIMAGECONVERTER_H