imagingandcamerafws/imagingfws/src/ImageData.cpp
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 #include "icl/ImageData.h"
       
    17 #include "icl/ImageCodecData.h"
       
    18 #include "ImageData.inl"
       
    19 
       
    20 /**
       
    21 Constructs and initialises the TFrameDataBlock object to the data type specified by aDataType.
       
    22 
       
    23 @param  aDataType
       
    24         The data type.
       
    25 
       
    26 @see ImageCodecData.h
       
    27  */
       
    28 EXPORT_C TFrameDataBlock::TFrameDataBlock(TUid aDataType)
       
    29 : iDataType(aDataType)
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34 Returns the data type of the current TFrameDataBlock object.
       
    35 
       
    36 @return The data type.
       
    37 
       
    38 @see ImageCodecData.h
       
    39 */
       
    40 EXPORT_C TUid TFrameDataBlock::DataType() const
       
    41 	{
       
    42 	return iDataType;
       
    43 	}
       
    44 
       
    45 
       
    46 /**
       
    47 Constructs and initialises the TImageDataBlock object to the data type specified by aDataType.
       
    48 
       
    49 @param  aDataType
       
    50         The data type.
       
    51 
       
    52 @see ImageCodecData.h
       
    53 */
       
    54 EXPORT_C TImageDataBlock::TImageDataBlock(TUid aDataType)
       
    55 : iDataType(aDataType)
       
    56 	{
       
    57 	}
       
    58 
       
    59 /**
       
    60 Returns the data type of the current TImageDataBlock object.
       
    61 
       
    62 @return The data type.
       
    63 
       
    64 @see ImageCodecData.h
       
    65 */
       
    66 EXPORT_C TUid TImageDataBlock::DataType() const
       
    67 	{
       
    68 	return iDataType;
       
    69 	}
       
    70 
       
    71 
       
    72 /**
       
    73  *
       
    74  * Default constructor for this class.
       
    75  */
       
    76 EXPORT_C TBmpImageData::TBmpImageData()
       
    77 	: TImageDataBlock(KBMPImageDataUid)
       
    78 	{
       
    79 	}
       
    80 
       
    81 TImageDataBlock* TBmpImageData::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
    82 	{
       
    83 	TBmpImageData* bmpImageData = new(ELeave) TBmpImageData(*this);
       
    84 	return bmpImageData;
       
    85 	}
       
    86 
       
    87 /**
       
    88  *
       
    89  * Default constructor for this class.
       
    90  */
       
    91 EXPORT_C TBmpCompression::TBmpCompression()
       
    92 	: TImageDataBlock(KBMPCompressionUid)
       
    93 	{
       
    94 	}
       
    95 
       
    96 TImageDataBlock* TBmpCompression::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
    97 	{
       
    98 	TBmpCompression* bmpCompression = new(ELeave) TBmpCompression(*this);
       
    99 	return bmpCompression;
       
   100 	}
       
   101 
       
   102 
       
   103 /**
       
   104  *
       
   105  * Default constructor for this class.
       
   106  */
       
   107 EXPORT_C TJpegImageData::TJpegImageData()
       
   108 	: TImageDataBlock(KJPGImageDataUid),
       
   109 	iSampleScheme(EColor420),
       
   110 	iQualityFactor(75)
       
   111 	{
       
   112 	}
       
   113 
       
   114 TImageDataBlock* TJpegImageData::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   115 	{
       
   116 	TJpegImageData* jpegImageData = new(ELeave) TJpegImageData(*this);
       
   117 	return jpegImageData;
       
   118 	}
       
   119 
       
   120 /**
       
   121  *
       
   122  * Default constructor for this class.
       
   123  */
       
   124 EXPORT_C TJpegQTable::TJpegQTable():
       
   125 	TImageDataBlock(KJPGQTableUid),
       
   126 	iTableIndex(ELumaTable),
       
   127 	iEntries(KJpgQTableEntries)
       
   128 	{
       
   129 	}
       
   130 
       
   131 TImageDataBlock* TJpegQTable::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   132 	{
       
   133 	TJpegQTable* jpegQTable = new(ELeave) TJpegQTable(*this);
       
   134 	return jpegQTable;
       
   135 	}
       
   136 
       
   137 /**
       
   138  *
       
   139  * Default constructor for this class.
       
   140  */
       
   141 EXPORT_C TJpegComment::TJpegComment():
       
   142 	TImageDataBlock(KJPGCommentUid),
       
   143 	iComment(NULL)
       
   144 	{
       
   145 	}
       
   146 
       
   147 TImageDataBlock* TJpegComment::DuplicateL(CFrameImageData& aFrameImageData) const
       
   148 	{
       
   149 	TJpegComment* jpegComment = new(ELeave) TJpegComment(*this);
       
   150 	CleanupStack::PushL(jpegComment);
       
   151 
       
   152 	jpegComment->iComment = jpegComment->iComment->AllocLC();
       
   153 
       
   154 	User::LeaveIfError(aFrameImageData.AppendImageBuffer(jpegComment->iComment));
       
   155 	CleanupStack::Pop(2); // jpegComment, jpegComment->iComment;
       
   156 	return jpegComment;
       
   157 	}
       
   158 
       
   159 
       
   160 /**
       
   161  *
       
   162  * Default constructor for this class.
       
   163  */
       
   164 EXPORT_C TGifBackgroundColor::TGifBackgroundColor()
       
   165 	: TImageDataBlock(KGIFBackgroundColorUid)
       
   166 	{
       
   167 	}
       
   168 
       
   169 TImageDataBlock* TGifBackgroundColor::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   170 	{
       
   171 	TGifBackgroundColor* gifBackgroundColor = new(ELeave) TGifBackgroundColor(*this);
       
   172 	return gifBackgroundColor;
       
   173 	}
       
   174 
       
   175 /**
       
   176  *
       
   177  * Default constructor for this class.
       
   178  */
       
   179 EXPORT_C TGifImageDescriptor::TGifImageDescriptor()
       
   180 	: TFrameDataBlock(KGIFImageDescriptorUid)
       
   181 	{
       
   182 	}
       
   183 
       
   184 TFrameDataBlock* TGifImageDescriptor::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   185 	{
       
   186 	TGifImageDescriptor* gifImageDescriptor = new(ELeave) TGifImageDescriptor(*this);
       
   187 	return gifImageDescriptor;
       
   188 	}
       
   189 
       
   190 /**
       
   191  * Constructor for this class.
       
   192  * Set the data type for this class to KGIFColorTableUid
       
   193  */
       
   194 EXPORT_C TGifColorTable::TGifColorTable()
       
   195 	: TFrameDataBlock(KGIFColorTableUid)
       
   196 	{
       
   197 	}
       
   198 
       
   199 /**
       
   200 Create a copy of this class.
       
   201 
       
   202 @param	aFrameImageData
       
   203 	Not used
       
   204 @return	A copy of the class. Ownership is passed to the caller.
       
   205 */
       
   206 TFrameDataBlock* TGifColorTable::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   207 	{
       
   208 	TGifColorTable* gifColorTable = new(ELeave) TGifColorTable(*this);
       
   209 	return gifColorTable;
       
   210 	}
       
   211 
       
   212 /**
       
   213  *
       
   214  * Default constructor for this class.
       
   215  */
       
   216 EXPORT_C TGifImageControl::TGifImageControl()
       
   217 	: TFrameDataBlock(KGIFImageControlUid)
       
   218 	{
       
   219 	}
       
   220 
       
   221 TFrameDataBlock* TGifImageControl::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   222 	{
       
   223 	TGifImageControl* gifImageControl = new(ELeave) TGifImageControl(*this);
       
   224 	return gifImageControl;
       
   225 	}
       
   226 
       
   227 /**
       
   228  *
       
   229  * Default constructor for this class.
       
   230  */
       
   231 EXPORT_C TGifLZWInfo::TGifLZWInfo()
       
   232 	: TFrameDataBlock(KGIFLZWInfoUid),
       
   233 	iCompressedBytes(0)
       
   234 	{
       
   235 	}
       
   236 
       
   237 TFrameDataBlock* TGifLZWInfo::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   238 	{
       
   239 	TGifLZWInfo* gifLZWInfo = new(ELeave) TGifLZWInfo(*this);
       
   240 	return gifLZWInfo;
       
   241 	}
       
   242 
       
   243 /**
       
   244  *
       
   245  * Default constructor for this class.
       
   246  */
       
   247 EXPORT_C TGifComment::TGifComment()
       
   248 	: TImageDataBlock(KGIFCommentUid),
       
   249 	iComment(NULL)
       
   250 	{
       
   251 	}
       
   252 
       
   253 TImageDataBlock* TGifComment::DuplicateL(CFrameImageData& aFrameImageData) const
       
   254 	{
       
   255 	TGifComment* gifComment = new(ELeave) TGifComment(*this);
       
   256 	CleanupStack::PushL(gifComment);
       
   257 
       
   258 	gifComment->iComment = gifComment->iComment->AllocLC();
       
   259 
       
   260 	User::LeaveIfError(aFrameImageData.AppendImageBuffer(gifComment->iComment));
       
   261 	CleanupStack::Pop(2); // gifComment, gifComment->iComment;
       
   262 	return gifComment;
       
   263 	}
       
   264 
       
   265 /**
       
   266  *
       
   267  * Default constructor for this class.
       
   268  */
       
   269 EXPORT_C TGifLoopIterations::TGifLoopIterations()
       
   270     : TImageDataBlock(KGIFLoopIterationsUid),
       
   271     iLoopIterations(0)
       
   272     {
       
   273     }
       
   274 
       
   275 TImageDataBlock* TGifLoopIterations::DuplicateL(CFrameImageData& /*aFrameImageData*/) const
       
   276     {
       
   277     TGifLoopIterations* gifIterations = new(ELeave) TGifLoopIterations(*this);
       
   278     return gifIterations;
       
   279     }
       
   280 
       
   281 /**
       
   282  *
       
   283  * Default constructor for this class.
       
   284  */
       
   285 EXPORT_C TMbmDecodeData::TMbmDecodeData()
       
   286 	: TFrameDataBlock(KMBMDecodeDataUid)
       
   287 	{
       
   288 	}
       
   289 
       
   290 TFrameDataBlock* TMbmDecodeData::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   291 	{
       
   292 	TMbmDecodeData* mbmDecodeData = new(ELeave) TMbmDecodeData(*this);
       
   293 	return mbmDecodeData;
       
   294 	}
       
   295 
       
   296 /**
       
   297  *
       
   298  * Default constructor for this class.
       
   299  */
       
   300 EXPORT_C TMbmEncodeData::TMbmEncodeData()
       
   301 	: TFrameDataBlock(KMBMEncodeDataUid)
       
   302 	{
       
   303 	}
       
   304 
       
   305 TFrameDataBlock* TMbmEncodeData::DuplicateL(CFrameImageData& /* aFrameImageData */ ) const
       
   306 	{
       
   307 	TMbmEncodeData* mbmEncodeData = new(ELeave) TMbmEncodeData(*this);
       
   308 	return mbmEncodeData;
       
   309 	}
       
   310 
       
   311 /**
       
   312  *
       
   313  * Default constructor for this class.
       
   314  */
       
   315 EXPORT_C TPngEncodeData::TPngEncodeData()
       
   316 	: TFrameDataBlock(KPNGEncodeDataUid)
       
   317 	{
       
   318 	}
       
   319 
       
   320 TFrameDataBlock* TPngEncodeData::DuplicateL(CFrameImageData& /* aFrameImageData */) const
       
   321 	{
       
   322 	TPngEncodeData* pngEncodeData = new(ELeave) TPngEncodeData(*this);
       
   323 	return pngEncodeData;
       
   324 	}
       
   325 
       
   326 /**
       
   327  *
       
   328  * Default constructor for this class.
       
   329  */
       
   330 EXPORT_C TTiffImageData::TTiffImageData():
       
   331 	TFrameDataBlock(KTIFFImageDataUid),
       
   332 	iStripInfo(NULL)
       
   333 	{
       
   334 	}
       
   335 
       
   336 TFrameDataBlock* TTiffImageData::DuplicateL(CFrameImageData& aFrameImageData) const
       
   337 	{
       
   338 	TTiffImageData* tiffImageData = new(ELeave) TTiffImageData(*this);
       
   339 	CleanupStack::PushL(tiffImageData);
       
   340 
       
   341 	tiffImageData->iStripInfo = tiffImageData->iStripInfo->AllocLC();
       
   342 
       
   343 	User::LeaveIfError(aFrameImageData.AppendImageBuffer(tiffImageData->iStripInfo));
       
   344 	CleanupStack::Pop(2); // tiffImageData, tiffImageData->iStripInfo;
       
   345 	return tiffImageData;
       
   346 	}
       
   347 
       
   348 //
       
   349 // TFrameInfo
       
   350 //
       
   351 
       
   352 /**
       
   353 Returns the current frame state.
       
   354 
       
   355 @return The frame state.
       
   356 */
       
   357 EXPORT_C TFrameInfo::TFrameInfoState TFrameInfo::CurrentFrameState() const
       
   358 	{
       
   359 	return iCurrentFrameState;
       
   360 	}
       
   361 
       
   362 /**
       
   363 Sets the current frame state to the supplied value.
       
   364 
       
   365 @param  aFrameInfoState
       
   366         The frame state.
       
   367 */
       
   368 EXPORT_C void TFrameInfo::SetCurrentFrameState(TFrameInfoState aFrameInfoState)
       
   369 	{
       
   370 	iCurrentFrameState = aFrameInfoState;
       
   371 	}
       
   372 
       
   373 /**
       
   374 Returns the current data offset.
       
   375 
       
   376 @return The data offset.
       
   377 */
       
   378 EXPORT_C TInt TFrameInfo::CurrentDataOffset() const
       
   379 	{
       
   380 	return iCurrentDataOffset;
       
   381 	}
       
   382 
       
   383 /**
       
   384 Sets the current data offset to the supplied value.
       
   385 
       
   386 @param  aOffset
       
   387         The data offset.
       
   388 */
       
   389 EXPORT_C void TFrameInfo::SetCurrentDataOffset(TInt aOffset)
       
   390 	{
       
   391 	iCurrentDataOffset = aOffset;
       
   392 	}
       
   393 
       
   394 /**
       
   395 Returns the frame data offset.
       
   396 
       
   397 @return The frame data offset.
       
   398 */
       
   399 EXPORT_C TInt TFrameInfo::FrameDataOffset() const
       
   400 	{
       
   401 	return iFrameDataOffset;
       
   402 	}
       
   403 
       
   404 /**
       
   405 Sets the frame data offset to the supplied value.
       
   406 
       
   407 @param  aOffset
       
   408         The frame data offset.
       
   409 */
       
   410 EXPORT_C void TFrameInfo::SetFrameDataOffset(TInt aOffset)
       
   411 	{
       
   412 	iFrameDataOffset = aOffset;
       
   413 	}