imgeditor_plat/image_processing_engine_api/inc/ImageEditorEngineWrapper.h
changeset 1 edfc90759b9f
child 7 0505d60a93f7
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description: 
       
    16 * CEngineWrapper wraps functionality of Gonzales image 
       
    17 * processing engine architecture.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef IMAGEEDITORENGINEWRAPPER_H
       
    23 #define IMAGEEDITORENGINEWRAPPER_H
       
    24 
       
    25 /// INCLUDES
       
    26 #include <e32base.h>
       
    27 #include "commondefs.h"
       
    28 
       
    29 
       
    30 /**  Panic category */
       
    31 _LIT (KEnginePanic, "ENGINE PANIC");
       
    32 
       
    33 /**  Panic reasons */
       
    34 const TInt KEnginePanicAllocation = -1;
       
    35 const TInt KEnginePanicInternal = -2;
       
    36 const TInt KEnginePanicParameter = -3;
       
    37 
       
    38 /// FORWARD DECLARATIONS
       
    39 class CFbsBitmap;
       
    40 class CFilterStack;
       
    41 class CSystemParameters;
       
    42 class TFilter;
       
    43 class CExifParser;
       
    44 
       
    45 
       
    46 /**
       
    47  * CEngineWrapper wraps functionality of Gonzales image processing
       
    48  * engine architecture.
       
    49  *
       
    50  *  @code
       
    51  *   ?good_class_usage_example(s)
       
    52  *  @endcode
       
    53  *
       
    54  *  @lib EngineWrapper.lib
       
    55  *  @since S60 v5.0
       
    56  */
       
    57 class CEngineWrapper : public CBase
       
    58 {
       
    59 
       
    60 public:
       
    61 
       
    62 
       
    63     /**
       
    64      * Two-phased constructor.
       
    65      * @param -
       
    66      */
       
    67      IMPORT_C static CEngineWrapper * NewL ();
       
    68 
       
    69     /**
       
    70      * Destructor.
       
    71      */
       
    72      IMPORT_C ~CEngineWrapper ();
       
    73    
       
    74     /**
       
    75      * Creates JPEG source to engine.
       
    76      *
       
    77      * @since S60 v5.0
       
    78      * @param aFileName source image file name
       
    79      * @return -
       
    80      */   
       
    81      IMPORT_C void CreateJpegSourceL  (const TDesC & aFileName);
       
    82 
       
    83     /**
       
    84      * Creates JPEG target for engine.
       
    85      *
       
    86      * @since S60 v5.0
       
    87      * @param aFileName saved image file name
       
    88      * @param aQuality saved image quality
       
    89      * @param aSize image size (width and height)
       
    90      * @return -
       
    91      */
       
    92      IMPORT_C void CreateJpegTargetL (
       
    93 		                     const TDesC & 	aFileName,
       
    94                          const TInt     aQuality,
       
    95                          const TSize *   aSize = NULL
       
    96         );
       
    97 
       
    98     /**
       
    99      * Creates ICL source to engine.
       
   100      *
       
   101      * @since S60 v5.0
       
   102      * @param aFileName source image file name
       
   103      * @return /
       
   104      */
       
   105      IMPORT_C void CreateIclSourceL (const TDesC & aFileName);
       
   106     
       
   107     /**
       
   108      * Creates RGB888 buffer target to engine.
       
   109      *
       
   110      * @since S60 v5.0
       
   111      * @param -
       
   112      * @return -
       
   113      */    
       
   114      IMPORT_C void CreateRGB888TargetL ();
       
   115 
       
   116     /**
       
   117      * Sets screen size to engine.
       
   118      *
       
   119      * @since S60 v5.0
       
   120      * @param aSize screen size
       
   121      * @return -
       
   122      */
       
   123      IMPORT_C void SetScreenSizeL (const TSize & aSize);
       
   124 
       
   125     /**
       
   126      * Adds new filter to the engine.
       
   127      *
       
   128      * @since S60 v5.0
       
   129      * @param aFilterName filter plug-in name
       
   130      * @return -
       
   131      */
       
   132      IMPORT_C void AddFilterL (const TDesC & aFilterName);	
       
   133 
       
   134     /**
       
   135      * Sets filter parameters for the last (top) filter.
       
   136      *
       
   137      * @since S60 v5.0
       
   138      * @param aParam reference to parameter structure
       
   139      * @return -
       
   140      */
       
   141      IMPORT_C void SetParamsL (const TDesC & aParam);
       
   142 
       
   143     /**
       
   144      * Renders the engine graph.
       
   145      *
       
   146      * @since S60 v5.0
       
   147      * @param aMultiSessionBlockCount not used
       
   148      * @return -
       
   149      */
       
   150      IMPORT_C void RenderL (TInt* aMultiSessionBlockCount = NULL);
       
   151 
       
   152     /**
       
   153      * Renders a block
       
   154      *
       
   155      * @since S60 v5.0
       
   156      * @return return percentage of image data saved, 100 when ready
       
   157      */
       
   158      IMPORT_C TInt RenderBlockL ();
       
   159 
       
   160     /**
       
   161      * Aborts block rendering
       
   162      *
       
   163      * @since S60 v5.0
       
   164      * @param -
       
   165      * @return -
       
   166      */
       
   167     IMPORT_C void RenderAbortL ();
       
   168 
       
   169     /**
       
   170      * Initializes undo / redo stack.
       
   171      *
       
   172      * @since S60 v5.0
       
   173      * @param -
       
   174      * @return -
       
   175      */
       
   176      IMPORT_C void InitUndoRedo();
       
   177 
       
   178     /**
       
   179      * Sets a new undo / redo step.
       
   180      *
       
   181      * @since S60 v5.0
       
   182      * @param -
       
   183      * @return -
       
   184      */
       
   185      IMPORT_C void AddUndoRedoStepL();
       
   186 
       
   187     /**
       
   188      * Undoes the last operation.
       
   189      *
       
   190      * @since S60 v5.0
       
   191      * @param -
       
   192      * @return -
       
   193      */
       
   194      IMPORT_C void UndoL();
       
   195 
       
   196     /**
       
   197      * Checks if it is possible to undo.
       
   198      *
       
   199      * @since S60 v5.0
       
   200      * @param -
       
   201      * @return ETrue if undo possible, EFalse otherwise 
       
   202      */
       
   203      IMPORT_C TBool CanUndo ();
       
   204 
       
   205     /**
       
   206      * Checks if the image is changed after last saving.
       
   207      *
       
   208      * @since S60 v5.0
       
   209      * @param -
       
   210      * @return ETrue if image is changed, EFalse otherwise
       
   211      */
       
   212      IMPORT_C TBool IsImageChanged();
       
   213 
       
   214     /**
       
   215      * Stores current zoom value.
       
   216      *
       
   217      * @since S60 v5.0
       
   218      * @param -
       
   219      * @return -
       
   220      */
       
   221      IMPORT_C void StoreZoomL ();
       
   222 
       
   223     /**
       
   224      * Restores stored zoom value.
       
   225      *
       
   226      * @since S60 v5.0
       
   227      * @param -
       
   228      * @return -
       
   229      */
       
   230      IMPORT_C void RestoreZoomL();
       
   231 
       
   232     /** ZoomL
       
   233      * Zooms the image.
       
   234      *
       
   235      * @since S60 v5.0
       
   236      * @param aZoom zoom direction
       
   237      * @return -
       
   238      */
       
   239 	IMPORT_C void ZoomL (const TZoom aZoom);
       
   240 
       
   241     /** GetZoomMode
       
   242      * Returns current zoom mode.
       
   243      *
       
   244      * @since S60 v5.0
       
   245      * @param -
       
   246      * @return TZoomMode current zooming mode
       
   247      */
       
   248      IMPORT_C TZoomMode GetZoomMode();
       
   249      
       
   250     /**
       
   251      * Pans the image.
       
   252      *
       
   253      * @since S60 v5.0
       
   254      * @param aDir direction, see commondefs.h
       
   255      * @return -
       
   256      */
       
   257 	IMPORT_C void PanL (const TDirection aDir);
       
   258     
       
   259         
       
   260     /**
       
   261      * Pans the image. Used when panning is done with touch
       
   262      *
       
   263      * @since S60 v5.0
       
   264      * @param aXChange x-directional change on the screen
       
   265      * @param aYChange y-directional change on the screen
       
   266      * @return -
       
   267      */
       
   268      IMPORT_C void PanL( TInt aXChange, TInt aYChange );
       
   269     
       
   270 
       
   271     /**
       
   272      * Rotates the image.
       
   273      *
       
   274      * @since S60 v5.0
       
   275      * @param aRot rotation direction, see commodefs.h
       
   276      * @return -
       
   277      */
       
   278      IMPORT_C void RotateL (const TRotation aRot);
       
   279 
       
   280     /**
       
   281      * Gets system parameters
       
   282      *
       
   283      * @since S60 v5.0
       
   284      * @param -
       
   285      * @return pointer to the system parameters
       
   286      */
       
   287      IMPORT_C CSystemParameters * GetSystemPars ();
       
   288 
       
   289     /**
       
   290      * No functionality.
       
   291      *
       
   292      * @since S60 v5.0
       
   293      * @param aWidth width of the output image in pixels
       
   294      * @param aHeight height of the output image in pixels
       
   295      * @return -
       
   296      */
       
   297      IMPORT_C void GetOutputImageSize ( TInt& aWidth, TInt& aHeight ) const;
       
   298 
       
   299     /**
       
   300      * No functionality.
       
   301      *
       
   302      * @since S60 v5.0
       
   303      * @param aComment comment to be set
       
   304      * @return -
       
   305      */
       
   306      IMPORT_C void SetJpegCommentL (const TDesC8& aComment);
       
   307 
       
   308     /**
       
   309      * Sets the bitmap to member variable.
       
   310      *
       
   311      * @since S60 v5.0
       
   312      * @param aBitmap bitmap to be set
       
   313      * @return -
       
   314      */
       
   315      IMPORT_C void SetBitmap (CFbsBitmap * aBitmap);
       
   316     
       
   317     /**
       
   318      * Creates new EXIF thumbnail from the current filter stack.
       
   319      *
       
   320      * @since S60 v5.0
       
   321      * @param -
       
   322      * @param -
       
   323      * @return -
       
   324      */    
       
   325      IMPORT_C void CreateExifThumbNailL ();
       
   326     
       
   327 protected:
       
   328 
       
   329 private:
       
   330 
       
   331      CEngineWrapper ();
       
   332      
       
   333      void ConstructL ();
       
   334 
       
   335     /**
       
   336      * Checks if a file exists or not, on return has the correct
       
   337      * path to the checked file.
       
   338      *
       
   339      * @since S60 v5.0
       
   340      * @param aFileName file name, on return includes the correct path
       
   341      * @return KErrNone if file exists, system wide error code otherwise
       
   342      */
       
   343      TInt FileExists (TDes & aFileName) const;
       
   344 
       
   345     /**
       
   346      * Cleans up the engine, frees allocated memory. Does not delete
       
   347      * the engine itself.
       
   348      *
       
   349      * @since S60 v5.0
       
   350      * @param -
       
   351      * @return -
       
   352      */
       
   353      void Cleanup();
       
   354 
       
   355     /**
       
   356      * Computes current system parameters.
       
   357      *
       
   358      * @since S60 v5.0
       
   359      * @param -
       
   360      * @return -
       
   361      */
       
   362      void ComputeSystemParameters ();
       
   363 
       
   364     /**
       
   365      * No functionality.
       
   366      *
       
   367      * @since S60 v5.0
       
   368      * @param aStartInd view port start index, defaults to 2
       
   369      * @return the current view port
       
   370      */
       
   371      TRect ComputeViewPort( const TInt aStartInd = 2 );
       
   372 
       
   373     /**
       
   374      * No functionality.
       
   375      *
       
   376      * @since S60 v5.0
       
   377      * @param aViewPort the current view port
       
   378      * @return the current visible view port area
       
   379      */
       
   380      TRect ComputeVisibleViewPort (const TRect & aViewPort);
       
   381 
       
   382     /**
       
   383      * No functionality
       
   384      *
       
   385      * @since S60 v5.0
       
   386      * @param aVvpOld the old visible view port area
       
   387      * @return new pan value
       
   388      */
       
   389      TPoint ComputeNewPanValue (const TRect & aVvpOld);
       
   390 
       
   391     /**
       
   392      * Adds rotation filter to the engine.
       
   393      *
       
   394      * @since S60 v5.0
       
   395      * @param -
       
   396      * @return -
       
   397      */
       
   398      void AddRotateFilterL();
       
   399 
       
   400     /**
       
   401      * Copies rendered buffer from engine to screen bitmap.
       
   402      *
       
   403      * @since S60 v5.0
       
   404      * @param aBuffer pointer to engine buffer data
       
   405      * @return -
       
   406      */
       
   407      void CopyBufferL (TUint32 * aBuffer);
       
   408 	
       
   409     /**
       
   410      * Checks if two strings are equal.
       
   411      *
       
   412      * @since S60 v5.0
       
   413      * @param aString1 first string to be compared
       
   414      * @param aString2 second string to be compared
       
   415      * @return ETrue if equal, EFalse otherwise
       
   416      */
       
   417      TBool CEngineWrapper::IsSameString (
       
   418                              const TUint8 *		aString1, 
       
   419                              const TUint8 *		aString2
       
   420                              );
       
   421                              
       
   422     /**
       
   423      * Updates scale and pan to crop rectangle.
       
   424      *
       
   425      * @since S60 v5.0
       
   426      * @param -
       
   427      * @return -
       
   428      */ 
       
   429 	void UpdateCropRectL ();
       
   430 	
       
   431     /**
       
   432      * Updates thumbnail data to EXIF parser.
       
   433      *
       
   434      * @since S60 v5.0
       
   435      * @param -
       
   436      * @return -
       
   437      */	
       
   438      TPtrC8 UpdateExifThumbnailL ();
       
   439 
       
   440     /**
       
   441      * Handles tags that are always updated to the new image. If tags
       
   442      * do not exist, creates new ones.
       
   443      *
       
   444      * @since S60 v5.0
       
   445      * @param -
       
   446      * @return -
       
   447      */
       
   448      void UpdateExifTagsL();
       
   449 	
       
   450     /**
       
   451      * Gets current date and time as descriptor.
       
   452      *
       
   453      * @since S60 v5.0
       
   454      * @param aDateTimeBuf contains datetime on return
       
   455      * @return -
       
   456      */	
       
   457      void GetCurrentDateTime (TDes8 & aDateTimeBuf) const;
       
   458 
       
   459     /**
       
   460      * Computes current total rotation of the original image
       
   461      * in degrees.
       
   462      *
       
   463      * @since S60 v5.0
       
   464      * @param -
       
   465      * @return rotation in degrees
       
   466      */
       
   467      TInt ComputeRotationL ();
       
   468 	
       
   469 	    /**
       
   470      * Computes bounding rectangle used from global cropping.
       
   471      *
       
   472      * @since S60 v5.0
       
   473      * @param -
       
   474      * @return -
       
   475      */
       
   476      void ComputeBoundingRectL();
       
   477 	
       
   478     /**
       
   479      * Rendering mode
       
   480      */	
       
   481      enum TRenderingMode
       
   482      {
       
   483        // Invalid
       
   484        ERenderingModeMin = 0,
       
   485        // Render to jpeg
       
   486        ERenderingModeJpeg,
       
   487        // Render RGB888 buffer
       
   488        ERenderingModeRGB888,
       
   489        // Invalid
       
   490        ERenderingModeMax
       
   491       } iMode;
       
   492 
       
   493     /**
       
   494      * Main engine
       
   495      */
       
   496      CFilterStack * iMainEngine;
       
   497 
       
   498     /**
       
   499      * Engine command line
       
   500      */
       
   501      TBuf<256> iCmd;
       
   502 
       
   503     /**
       
   504      * Source image size
       
   505      */
       
   506      TSize iSourceSize;
       
   507 
       
   508     /**
       
   509      * Screen size
       
   510      */
       
   511      TSize iScreenSize;
       
   512 	
       
   513     /**
       
   514      * Screen data address
       
   515      */	
       
   516      CFbsBitmap * iScreenBitmap;					
       
   517 
       
   518     /**
       
   519      * Target image name
       
   520      */
       
   521      TFileName iTargetFile;
       
   522 	
       
   523     /**
       
   524      * System parameters
       
   525      */	
       
   526      CSystemParameters * iSysPars;
       
   527 
       
   528     /**
       
   529      * Undo points
       
   530      */
       
   531      RArray<TInt> iUndoPoints;
       
   532    
       
   533     /**
       
   534      * Undo buffer for scale parameter
       
   535      */   
       
   536      RArray<TReal> iScaleUndoBuf;
       
   537     
       
   538     /**
       
   539      * EXIF parser
       
   540      */
       
   541      CExifParser * iExifParser;
       
   542 	
       
   543     /**
       
   544      * EXIF thumbnail buffer
       
   545      */	
       
   546      TUint32 * iThumb;
       
   547 	
       
   548     /**
       
   549      * EXIF thumbnail dimensions
       
   550      */	
       
   551      TSize iThumbSize;
       
   552 
       
   553     /**
       
   554      * JPEG comment text
       
   555      */    
       
   556      HBufC8* iJpegComment;
       
   557 
       
   558     /**
       
   559      * Change counter, 0 if no changes after save
       
   560      */
       
   561      TInt iChangeCount;
       
   562 
       
   563     /**
       
   564      * Previous change counter
       
   565      */
       
   566      TInt iPrevChangeCount;
       
   567 	
       
   568     /**
       
   569      * Scale buffer changed
       
   570      */	
       
   571      TBool iRenderScaleBuffer;
       
   572 
       
   573     /**
       
   574      * Crop parameters
       
   575      */	
       
   576      TReal iScale;
       
   577      TReal iMinScale;
       
   578      TReal iMaxScale;
       
   579      TReal iPanX;
       
   580      TReal iPanY;
       
   581      TReal iPanStep;
       
   582      TRect iBoundingRect;
       
   583 	
       
   584     /**
       
   585      * Stored crop parameters
       
   586      */
       
   587      TReal iScaleSt;
       
   588      TReal iPanXSt;
       
   589      TReal iPanYSt;
       
   590      TRect iOldCropRect;
       
   591 
       
   592     /** 
       
   593      * Current zooming mode
       
   594      */
       
   595      TZoomMode iZoomMode;
       
   596 	
       
   597 };
       
   598 
       
   599 #endif // IMAGEEDITORENGINEWRAPPER_H
       
   600