imagingandcamerafws/imagingfws/inc/icl/ImagePlugin.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef ImageConversionPlugin_h
       
    17 #define ImageConversionPlugin_h
       
    18 
       
    19 #include <icl/imagedata.h>
       
    20 #include <icl/imagecodec.h>
       
    21 #include <imageconversion.h>
       
    22 #include <icl/imageconversionextension.h>
       
    23 
       
    24 class CImageDecoderPriv;
       
    25 class CImageEncoderPriv;
       
    26 class CImageReadCodec;
       
    27 class CImageWriteCodec;
       
    28 class TBufPtr8;
       
    29 
       
    30 /**
       
    31 @publishedAll
       
    32 @released
       
    33 
       
    34 The PluginAPI for Image Converter Library decoder plugins. 
       
    35 
       
    36 Intended for use by plugin writers only.
       
    37 */
       
    38 class CImageDecoderPlugin : public CBase
       
    39 	{
       
    40 friend class CImageDecoderPriv;
       
    41 
       
    42 public:
       
    43 	IMPORT_C ~CImageDecoderPlugin();
       
    44 
       
    45 	IMPORT_C virtual TInt NumberOfImageComments() const;
       
    46 	IMPORT_C virtual HBufC* ImageCommentL(TInt aCommentNumber) const;
       
    47 	IMPORT_C virtual TInt NumberOfFrameComments(TInt aFrameNumber) const;
       
    48 	IMPORT_C virtual HBufC* FrameCommentL(TInt aFrameNumber, TInt aCommentNumber) const;
       
    49 
       
    50 	/**
       
    51 	Returns the image type and sub-type for a given frame of the image that
       
    52 	has just been opened.
       
    53 
       
    54 	This is a virtual function that each individual plugin must implement.
       
    55 
       
    56 	@param  aFrameNumber
       
    57 	        The frame index for type and sub-type information should be returned.
       
    58 	@param  aImageType
       
    59 	        On return contains the image type UID for the specified frame.
       
    60 	@param  aImageSubType
       
    61 	        On return contains the image sub-type UID for the specified frame. If the sub-type does
       
    62 			not exist KNullUid is returned.
       
    63 	*/
       
    64 	virtual void ImageType(TInt aFrameNumber, TUid& aImageType, TUid& aImageSubType) const = 0;
       
    65 
       
    66 protected:
       
    67 	IMPORT_C CImageDecoderPlugin();
       
    68 	IMPORT_C virtual void Cleanup();
       
    69 	IMPORT_C virtual void ReadFrameHeadersL();
       
    70 
       
    71 	/**
       
    72 	Invokes the ReadFrameHeadersL() method of the supplied plugin.
       
    73 
       
    74 	The plugin's version of ReadFrameHeadersL() should read the image header information, create
       
    75 	the required codec and read the frame headers.
       
    76 
       
    77 	This is a virtual function that each individual plugin must implement.
       
    78 	*/
       
    79 	virtual void ScanDataL() = 0;
       
    80 
       
    81 
       
    82 	IMPORT_C virtual TInt FrameHeaderBlockSize(TInt aFrameNumber) const;
       
    83 	IMPORT_C virtual TInt FrameBlockSize(TInt aFrameNumber) const;
       
    84 
       
    85 	/**
       
    86 	Returns the codec specific frame information stored in resource files.
       
    87 
       
    88 	This is a virtual function that each individual plugin must implement.
       
    89 
       
    90 	@param  aFs
       
    91 	        A handle to a file server session.
       
    92 	@param  aFrameNumber
       
    93 	        The frame number to which the codec specific frame information
       
    94 	        applies (optional, defaults to zero).
       
    95 
       
    96 	@return A pointer to a newly allocated CFrameInfoStrings object.
       
    97 	        Ownership is transferred to the caller.
       
    98 	*/
       
    99 	IMPORT_C virtual CFrameInfoStrings* FrameInfoStringsL(RFs& aFs, TInt aFrameNumber = 0) = 0;
       
   100 
       
   101 	IMPORT_C void OpenExtraResourceFileLC(RFs& aFs, const TUid aUid, RResourceFile& aResourceFile) const;
       
   102 	IMPORT_C void ReadDataL(TInt aPosition, TPtrC8& aReadBuffer, TInt aLength);
       
   103 	IMPORT_C virtual void InitConvertL();
       
   104 
       
   105 	IMPORT_C void RequestInitL(TInt aFrameNumber);
       
   106 
       
   107 	IMPORT_C virtual void DoConvert();
       
   108 	IMPORT_C void PrepareForProcessFrameL();
       
   109 	IMPORT_C void HandleProcessFrameResult(TInt aErrCode, TFrameState aCodecState);
       
   110 	IMPORT_C TBufPtr8& SourceData();
       
   111 
       
   112 	IMPORT_C void RequestComplete(TInt aReason);
       
   113 	IMPORT_C void SelfComplete(TInt aReason);
       
   114 	IMPORT_C void SetSelfPending();
       
   115 
       
   116 	IMPORT_C TBool IsImageHeaderProcessingComplete() const;
       
   117 
       
   118 	IMPORT_C CImageReadCodec* ImageReadCodec() const;
       
   119 	IMPORT_C void SetImageReadCodec(CImageReadCodec* aImageReadCodec);
       
   120 
       
   121 	IMPORT_C const TFrameInfo& ImageInfo() const;
       
   122 	IMPORT_C void SetImageInfo(const TFrameInfo& aImageInfo);
       
   123 
       
   124 	IMPORT_C TInt NumberOfFrames() const;
       
   125 
       
   126 	IMPORT_C const TImageDataBlock* ImageData(TInt aIndex) const;
       
   127 	IMPORT_C TInt InsertImageData(const TImageDataBlock* aEntry, TInt aPos);
       
   128 	IMPORT_C TInt AppendImageData(const TImageDataBlock* aEntry);
       
   129 	IMPORT_C void RemoveImageData(TInt aPos);
       
   130 	IMPORT_C TInt ImageDataCount() const;
       
   131 	IMPORT_C TInt AppendImageDataBuffer(const HBufC8* aImageBuffer);
       
   132 
       
   133 	IMPORT_C TInt DataLength() const;
       
   134 	IMPORT_C void SetDataLength(TInt aDataLength);
       
   135 	IMPORT_C TInt Position() const;
       
   136 	IMPORT_C void SetPosition(const TInt aPosition);
       
   137 	IMPORT_C TInt StartPosition() const;
       
   138 	IMPORT_C void SetStartPosition(TInt aDataLength);
       
   139 
       
   140 	IMPORT_C const CFbsBitmap& Destination() const;
       
   141 	IMPORT_C TBool ValidDestination() const;
       
   142 	IMPORT_C const CFbsBitmap& DestinationMask() const;
       
   143 	IMPORT_C TBool ValidDestinationMask() const;
       
   144 
       
   145 	IMPORT_C const TFrameInfo& FrameInfo(TInt aFrameNumber = 0) const;
       
   146 	IMPORT_C const CFrameImageData& FrameData(TInt aFrameNumber = 0) const;
       
   147 
       
   148 	IMPORT_C TInt SourceLength() const;
       
   149 
       
   150 	IMPORT_C virtual void HandleCustomSyncL(TInt aParam);
       
   151 	IMPORT_C virtual void InitCustomAsyncL(TInt aParam);
       
   152 	IMPORT_C virtual void NotifyComplete();
       
   153 	IMPORT_C TBool AmInThread() const;
       
   154 	IMPORT_C TBool ShouldAbort() const;
       
   155 	IMPORT_C void SetThumbnailData(HBufC8* aThumbnailData);
       
   156 	
       
   157 	IMPORT_C CImageDecoder::TOptions DecoderOptions() const;
       
   158 	
       
   159 private:
       
   160 	TBool ValidProperties() const;
       
   161 
       
   162 	IMPORT_C virtual void EnableMaskGeneration();
       
   163 	IMPORT_C virtual void NotifyImageTypeChangeL(TInt aImageType);
       
   164 	
       
   165 	// Future proofing
       
   166 	IMPORT_C virtual void ReservedVirtual1();
       
   167 
       
   168 public:
       
   169 	/**
       
   170 	@publishedAll
       
   171 	@released
       
   172 	
       
   173 	Called by the framework to obtain a pointer to a codec implemented extension.
       
   174 
       
   175 	@param aExtUid Extension UID normally prefixed KUidImageConv. @see icl_uids.hrh .
       
   176 	@param aExtPtr Returns a ptr to the extension implemented by the codec plugin.
       
   177 	*/
       
   178 	IMPORT_C virtual void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr);
       
   179 	/**
       
   180 	@publishedAll
       
   181 	@released
       
   182 	
       
   183 	Called by the framework on the plugin to apply a clipping rectangle to the image.
       
   184 
       
   185 	Sets the area of interest of the image to be decoded.
       
   186 
       
   187 	@param aClipRect	A pointer to a TRect that specifies the
       
   188 						location and size of the region to be decoded.  This
       
   189 						rectangle must have positive width and height values as
       
   190 						per TRect::IsNormalized() and TRect::Normalize().
       
   191 						Passing in a NULL value will clear the clipping rectangle.
       
   192 						Note that a clipping rectangle may not be valid for all frames of an image.
       
   193 						
       
   194 	@leave  KErrNotSupported if clipping is not supported by the codec plugin.
       
   195 	@leave  Other system-wide error codes.
       
   196 	*/
       
   197 	IMPORT_C virtual void SetClippingRectL(const TRect* aClipRect);
       
   198 	/**
       
   199 	@publishedAll
       
   200 	@released
       
   201 	
       
   202 	Called by framework on plugin to get the size of decoded image.
       
   203 
       
   204 	Get the size of the decoded image for the given frame. The calculation will account for any clipping rectangle set,
       
   205 	scaling applied through the TImageConvScaler extension and any operation applied through TImageConvOperation.
       
   206 	If TImageConvScaler::SetScalingL(.. has been called then the size of the bitmap passed to CImageDecoder::Convert must match the size returned from
       
   207 	this function.
       
   208 
       
   209 	@param aSize 
       
   210 		   Returns the size of the decoded image.
       
   211 	@param aFrameNumber
       
   212 		   The frame number.
       
   213 		   
       
   214 	@return KErrArgument if an error in calculation is detected e.g. if clipping rectangle is outside of the overall frame boundary.
       
   215 	@return Other system wide errors.
       
   216 	*/
       
   217 	IMPORT_C virtual TInt GetDestinationSize(TSize& aSize, TInt aFrameNumber = 0);
       
   218 
       
   219 private:
       
   220 	CImageDecoderPriv* iProperties; // not owned
       
   221 
       
   222 friend class RCImageDecoderPrivTestBase;
       
   223 	};
       
   224 
       
   225 /**
       
   226 @publishedAll
       
   227 @released
       
   228 
       
   229 The plugin API for Image Converter Library encoder plugins.
       
   230 
       
   231 Intended for use by plugin writers only.
       
   232 */
       
   233 class CImageEncoderPlugin : public CBase
       
   234 	{
       
   235 friend class CImageEncoderPriv;
       
   236 
       
   237 public:
       
   238 	IMPORT_C ~CImageEncoderPlugin();
       
   239 
       
   240 protected:
       
   241 	IMPORT_C CImageEncoderPlugin();
       
   242 	IMPORT_C virtual void Cleanup();
       
   243 	IMPORT_C virtual void InitConvertL();
       
   244 	IMPORT_C void RequestInitL();
       
   245 	IMPORT_C virtual void DoConvert();
       
   246 	IMPORT_C void HandleProcessFrameResult(TInt aErrCode, TFrameState aCodecState);
       
   247 	IMPORT_C TBufPtr8& DestinationData();
       
   248 	IMPORT_C void FinishConvertL();
       
   249 	IMPORT_C void WriteDataL(TInt aPosition,const TDesC8& aDes);
       
   250 	IMPORT_C void WriteDataPositionIncL(TInt aPosition,const TDesC8& aDes);
       
   251 	IMPORT_C const CFbsBitmap& Source() const;
       
   252 	IMPORT_C TBool ValidSource() const;
       
   253 
       
   254 	IMPORT_C CImageWriteCodec* ImageWriteCodec() const;
       
   255 	IMPORT_C void SetImageWriteCodec(CImageWriteCodec* aImageWriteCodec) const;
       
   256 	IMPORT_C TInt& StartPosition() const;
       
   257 	IMPORT_C TInt& Position() const;
       
   258 	IMPORT_C const TSize& FrameInfoOverallSizeInPixels() const;
       
   259 
       
   260 	/**
       
   261 	Allocates the specific codec used for the encoding and passes
       
   262 	ownership to the plugin.
       
   263 
       
   264 	This is a pure virtual function that each individual plugin must implement.
       
   265 
       
   266 	@param  aFrameImageData
       
   267 	        The parameters which can be passed on to the encoding algorithm.
       
   268 	        This data might be used to determine the exact codec created.
       
   269 
       
   270 	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   271 	        another of the system-wide error codes.
       
   272 	*/
       
   273 	virtual void PrepareEncoderL(const CFrameImageData* aFrameImageData) = 0;
       
   274 
       
   275 	/**
       
   276 	May be used to fill in additional fields at the end of the encoding
       
   277 	process, which it may not have been possible to do earlier.
       
   278 
       
   279 	This is a pure virtual function that each individual plugin must implement.
       
   280 	*/
       
   281 	virtual void UpdateHeaderL() = 0;
       
   282 
       
   283 	IMPORT_C TInt CurrentImageSizeL() const;
       
   284 
       
   285 	IMPORT_C void RequestComplete(TInt aReason);
       
   286 	IMPORT_C void SelfComplete(TInt aReason);
       
   287 	IMPORT_C void SetSelfPending();
       
   288 
       
   289 	IMPORT_C virtual void HandleCustomSyncL(TInt aParam);
       
   290 	IMPORT_C virtual void InitCustomAsyncL(TInt aParam);
       
   291 	IMPORT_C virtual void NotifyComplete();
       
   292 	IMPORT_C TBool AmInThread() const;
       
   293 	IMPORT_C TBool ShouldAbort() const;
       
   294 
       
   295 	IMPORT_C CImageEncoder::TOptions EncoderOptions() const;
       
   296 
       
   297 private:
       
   298 	TBool ValidProperties() const;
       
   299 
       
   300 	IMPORT_C virtual void WriteThumbnailL();
       
   301 	
       
   302 	/**
       
   303 	Originally only used by the jpeg codec, but now in use as a generic pre-convert async step
       
   304 	*/	
       
   305 	IMPORT_C virtual void WriteExifDataL(TRequestStatus*& aScaleCompletionStatus);
       
   306 	
       
   307 	IMPORT_C virtual void SetThumbnail(TBool aDoGenerateThumbnail);
       
   308 	IMPORT_C virtual void ReservedVirtual1();
       
   309 	IMPORT_C virtual void ReservedVirtual2();
       
   310 	IMPORT_C virtual void ReservedVirtual3();
       
   311 	
       
   312 public:
       
   313 	/**
       
   314 	@publishedAll
       
   315 	@released
       
   316 	
       
   317 	Called by the framework to obtain a pointer to a codec implemented extension.
       
   318 
       
   319 	@param aExtUid Extension UID normally prefixed KUidImageConv. @see icl_uids.hrh .
       
   320 	@param aExtPtr. Returns a ptr to the extension implemented by the codec plugin.
       
   321 	*/
       
   322 	IMPORT_C virtual void GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr);
       
   323 
       
   324 private:
       
   325 	CImageEncoderPriv* iProperties; // not owned
       
   326 	};
       
   327 
       
   328 
       
   329 #endif //ImageConversionPlugin_h
       
   330