photosgallery/collectionframework/thumbnailcreator/src/glxtnimagedecoderfactory.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:    Implementation of GlxtnImageDecoderFactory
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxtnimagedecoderfactory.h"
       
    22 
       
    23 #include <glxtracer.h>
       
    24 #include <IclExtJpegApi.h>  // For CExtJpegDecoder
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // NewL
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CImageDecoder* GlxtnImageDecoderFactory::NewL( RFs& aFs,
       
    31                                                 const TDesC& aFilename )
       
    32     {
       
    33     TRACER("CImageDecoder* GlxtnImageDecoderFactory::NewL()");
       
    34     CImageDecoder* decoder = NULL;
       
    35     TBool aIsExtDecoderUsed = EFalse;
       
    36     decoder = GlxtnImageDecoderFactory::NewL(aFs, aFilename, aIsExtDecoderUsed);
       
    37     return decoder;
       
    38     }
       
    39 // ---------------------------------------------------------------------------
       
    40 // NewL
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CImageDecoder* GlxtnImageDecoderFactory::NewL( RFs& aFs,
       
    44                                                 const TDesC& aFilename, TBool& aIsExtDecoderUsed )
       
    45     {
       
    46     TRACER("CImageDecoder* GlxtnImageDecoderFactory::NewL()");
       
    47     CImageDecoder* decoder = NULL;
       
    48     aIsExtDecoderUsed = ETrue; //setting decoder type to CExtJpegDecoder
       
    49     // Use extended JPEG decoder
       
    50     TRAPD( err, decoder = CExtJpegDecoder::FileNewL(
       
    51                 CExtJpegDecoder::EHwImplementation, aFs, aFilename, CImageDecoder::EOptionNone ) );
       
    52     if ( KErrNone != err )
       
    53         {
       
    54         TRAP(err,decoder = CExtJpegDecoder::FileNewL(
       
    55                 CExtJpegDecoder::ESwImplementation, aFs, aFilename, CImageDecoder::EOptionNone ) );
       
    56         if ( KErrNone != err )
       
    57             {
       
    58             // Not a JPEG - use standard decoder
       
    59             decoder = CImageDecoder::FileNewL( aFs, aFilename, CImageDecoder::EOptionNone );
       
    60             aIsExtDecoderUsed = EFalse;
       
    61             }
       
    62         }
       
    63 
       
    64     return decoder;
       
    65     }
       
    66 // ---------------------------------------------------------------------------
       
    67 // NewL
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CImageDecoder* GlxtnImageDecoderFactory::NewL( RFs& aFs, const TDesC8& aData )
       
    71     {
       
    72     TRACER("CImageDecoder* GlxtnImageDecoderFactory::NewL()");
       
    73     CImageDecoder* decoder = NULL;
       
    74 
       
    75     TRAPD( err, decoder = CExtJpegDecoder::DataNewL(
       
    76                         CExtJpegDecoder::EHwImplementation, aFs, aData ) );
       
    77     if ( KErrNone != err )
       
    78         {
       
    79         TRAP(err, decoder = CExtJpegDecoder::DataNewL(
       
    80                         CExtJpegDecoder::ESwImplementation, aFs, aData ) );
       
    81         if ( KErrNone != err )
       
    82             {
       
    83             // Not a JPEG - use standard decoder
       
    84             decoder = CImageDecoder::DataNewL( aFs, aData, CImageDecoder::EOptionNone );
       
    85             }
       
    86         }
       
    87 
       
    88     return decoder;
       
    89     }