diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder + * +*/ + + +//INCLUDE FILES +#include +#include +#include + +#include +#include "thumbnailimagedecoderv2.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" +#include "thumbnailmanagerconstants.h" + +// ============================ MEMBER FUNCTIONS =============================== +//------------------------------------------------------------------------ +// CThumbnailImageDecoder::CThumbnailImageDecoder() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv2::CThumbnailImageDecoderv2( RFs& aFs): CActive( + EPriorityStandard ), iFs( aFs ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoder::~CThumbnailImageDecoder() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv2::~CThumbnailImageDecoderv2() + { + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateL() +// Creates thumbnail of image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::CreateL(TDesC8& aBuffer, MThumbnailProviderObserver& aObserver) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateL() start" ); + + iBuffer = &aBuffer; + iObserver = &aObserver; + + CreateDecoderL(); + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateL() end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DecodeL() +// Decode the thumbnail image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::DecodeL( ) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::DecodeL() start" ); + + // Create the bitmap + if ( !iBitmap ) + { + iBitmap = new( ELeave )CFbsBitmap(); + } + + //set displaymode from global constants + User::LeaveIfError( iBitmap->Create( iDecoder->FrameInfo().iOverallSizeInPixels, iDecoder->FrameInfo().iFrameDisplayMode) ); + + iDecoder->Convert( &iStatus, * iBitmap ); + while ( iStatus == KErrUnderflow ) + { + iDecoder->ContinueConvert( &iStatus ); + } + SetActive(); + + TN_DEBUG1( "CThumbnailImageDecoderv2::DecodeL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::Release() +// Releases resources +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::Release() + { + Cancel(); + delete iDecoder; + iDecoder = NULL; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DoCancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::DoCancel() + { + if ( iDecoder ) + { + iDecoder->Cancel(); + delete iDecoder; + iDecoder = NULL; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::RunL() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::RunL() + { + // This call takes ownership of iBitmap + // EXIF always false + // Rotated always false + iObserver->ThumbnailProviderReady( iStatus.Int(), iBitmap, iOriginalSize, EFalse, EFalse); + + iBitmap = NULL; // owned by server now + iBuffer = NULL; + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateDecoderL +// Creates image decoder +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::CreateDecoderL() + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() start" ); + + delete iDecoder; + iDecoder = NULL; + + CImageDecoder::TOptions options = ( CImageDecoder::TOptions )( + CImageDecoder::EOptionNoDither | CImageDecoder::EPreferFastDecode ); + + TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, KJpegMime(), options ) ); + + if ( decErr != KErrNone ) + { + // don't force any mime type + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); + if ( decErr != KErrNone ) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - error" ); + + User::Leave( decErr ); + } + } + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv2:CreateDecoderL() - SW CExtJpegDecoder created" ); + } + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - HW CExtJpegDecoder created" ); + } + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() end" ); + } + +//End of file