activityfw/tsutils/inc/tsgraphicfilescalinghandler.h
changeset 83 156f692b1687
parent 80 397d00875918
--- a/activityfw/tsutils/inc/tsgraphicfilescalinghandler.h	Thu May 27 13:11:12 2010 +0300
+++ b/activityfw/tsutils/inc/tsgraphicfilescalinghandler.h	Fri Jun 11 13:58:37 2010 +0300
@@ -31,31 +31,70 @@
 class CImageDecoder;
 class CFbsBitmap;
 
+/**
+ * Interface to observer contain
+ * ImageReadyCallBack function return error code and scaled/resized bitmap.
+ */
 class MImageReadyCallBack
 {
 public:
-    virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap ) = 0;
+    virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap) = 0;
 };
 
+/**
+ * Class to scaling graphic file/s.
+ */
 class CTsGraphicFileScalingHandler : public CActive
 {
 public:
+    /**
+     * Kind of graphic file scaling.
+     * EIgnoreAspectRatio          - the file is scaled to size, aspect ratio isn't preserving.
+     * EKeepAspectRatio            - the file is scaled to a rectangle as large as possible inside size
+     *                               preserving the aspect ratio.
+     * EKeepAspectRatioByExpanding - the file is scaled to a rectangle as small as possible outside size
+     *                               preserving the aspect ratio.
+     */
+    enum TKindOfScaling
+    {
+       EIgnoreAspectRatio = 0,
+       EKeepAspectRatio = 1,
+       EKeepAspectRatioByExpanding = 2,
+    };
 
-enum TCurrentOperation{
+private:
+    /**
+     * Active object current operation.
+     */
+    enum TCurrentOperation{
         ENone = 0,
         EConvertBitmapFromFile = 1,
         EScale = 2
     };
 
-enum TKindOfScaling
-{
-   EIgnoreAspectRatio = 0,
-   EKeepAspectRatio = 1,
-   EKeepAspectRatioByExpanding = 2,
-};
-
+public:
+    /**
+    * Destructor.
+    */
     IMPORT_C ~CTsGraphicFileScalingHandler();
 
+    /**
+     * All constructors initialise active object asynchronous operation
+     * by calling ConstructL function.
+     * 1st group - decoding and scaling.
+     * 2nd group - scaling.
+     */
+
+    /**
+     * 1st group.
+     * Exported from dll constructors for activation graphic file scaling.
+     * aNotify        - reference to observer implementation.
+     * aFs            - reference to file server session.
+     * aFileName      - path to graphic file.
+     * aMimeType      - mime type of graphic file.
+     * aNewSize       - new size of output graphic file.
+     * aKindOfScaling - kind of graphic file scaling described above.
+     */
     IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify,
         RFs &aFs,
         const TDesC &aFileName,
@@ -69,27 +108,103 @@
         const TSize &aNewSize,
         TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
 
+    /**
+     * 2nd group.
+     * Exported from dll constructors for activation graphic file scaling.
+     * aNotify         - reference to observer implementation.
+     * aImputFbsBitmap - reference to pattern CFbsBitmap.
+     * aNewSize        - new size of output graphic file.
+     * aKindOfScaling  - kind of graphic file scaling described above.
+     */
+    IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify,
+        const CFbsBitmap &aImputFbsBitmap,
+        const TSize &aNewSize,
+        TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
+     IMPORT_C static CTsGraphicFileScalingHandler* NewLC(MImageReadyCallBack &aNotify,
+        const CFbsBitmap &aImputFbsBitmap,
+        const TSize &aNewSize,
+        TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
+
 protected:
+     /**
+      * Cancels the wait for completion of an outstanding request.
+      */
     void DoCancel();
+    /**
+     * Handles an active object’s request completion event.
+     */
     void RunL();
+    /**
+     * Handles a leave occurring in the request completion event handler RunL().
+     */
     TInt RunError(TInt);
 
 private:
+    /**
+     * Functions construct active objest instance and made asynchronous operation/s.
+     * Parameters - the same meaning as in appropriate NewL/NewLC functions.
+     */
     void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType);
+    void ConstructL(const CFbsBitmap &aImputFbsBitmap);
+    /**
+     * Private constructor.
+     * Parameters - the same meaning as in appropriate NewL/NewLC functions.
+     */
     CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify,
         const TSize &aNewSize,
         TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
-    TSize Scaling();
+    /**
+     * Action to made before decoding graphic file operation.
+     * Parameters - the same meaning as in appropriate NewL/NewLC functions.
+     */
+    void DecodingOperationL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType);
+    /**
+     * Action to made before scaling graphic file operation.
+     */
+    void ScalingOperationL();
+    /**
+     * Algorithm to determine output bitmap (returned in ImageReadyCallBack) size
+     * after scaling operation.
+     */
+    TSize NewSizeToScalingOperation();
+    /**
+     * Fix for TDisplayMode == EColor16MAP not supported by scaling operation!
+     * ! ! ! ADD OTHER NOT SUPPORTED DISPLAY MODES ! ! !
+     */
+    void FixForDisplayModeNotSupportedByScalingOperation();
 
 private:
+    /**
+     * Reference to observer implementation - return error code and output bitmap.
+     */
     MImageReadyCallBack &mNotify;
+    /**
+     * Pointer to decoder used by decoding graphic file algorithm.
+     */
     CImageDecoder *mImageDecoder;
-    CFbsBitmap *mBitmapFromFile;
-    CFbsBitmap *mBitmapOutput;
+    /**
+     * Pointer to input bitmap - before decoding/scaling operation/s.
+     */
+    CFbsBitmap *mInputBitmap;
+    /**
+     * Pointer to output bitmap - returned in mNotify object.
+     */
+    CFbsBitmap *mOutputBitmap;
+    /**
+     * Pointer to CBitmapScaler calss used by scaling graphic file algorithm.
+     */
     CBitmapScaler *mBitmapScaler;
+    /**
+     * New size of output graphic file.
+     */
     TSize mNewSize;
+    /**
+     * Kind of graphic file scaling described above.
+     */
     TBool mKindOfScaling;
-
+    /**
+     * Active object current operation.
+     */
     TCurrentOperation mCurrentOperation;
 };