336 TBool thumbFound( EFalse ); |
336 TBool thumbFound( EFalse ); |
337 |
337 |
338 // If the image is in jpeg format, try to get thumbnail from EXIF data (if EOptimizeForQuality not set) |
338 // If the image is in jpeg format, try to get thumbnail from EXIF data (if EOptimizeForQuality not set) |
339 if ( IsJpeg() && !( aFlags == CThumbnailManager::EOptimizeForQuality )) |
339 if ( IsJpeg() && !( aFlags == CThumbnailManager::EOptimizeForQuality )) |
340 { |
340 { |
341 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() crete exif decoder" ); |
341 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() create exif decoder" ); |
342 TRAPD( err, CreateExifDecoderL( aFlags )); |
342 TRAPD( err, CreateExifDecoderL( aFlags )); |
343 thumbFound = ( err == KErrNone ); |
343 thumbFound = ( err == KErrNone ); |
344 iEXIF = ETrue; |
344 iEXIF = ETrue; |
345 } |
345 } |
346 |
346 |
347 if ( !thumbFound ) |
347 if ( !thumbFound ) |
348 { |
348 { |
349 iEXIF = EFalse; |
349 iEXIF = EFalse; |
350 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() crete normal decoder" ); |
350 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() create normal decoder" ); |
351 |
351 |
352 delete iDecoder; |
352 delete iDecoder; |
353 iDecoder = NULL; |
353 iDecoder = NULL; |
354 |
354 |
355 TFileName fullName; |
355 TFileName fullName; |
405 { |
405 { |
406 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); |
406 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); |
407 |
407 |
408 if ( decErr != KErrNone ) |
408 if ( decErr != KErrNone ) |
409 { |
409 { |
|
410 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder error %d", decErr ); |
|
411 LeaveIfCorruptL(decErr); |
|
412 |
410 // don't force any mime type |
413 // don't force any mime type |
411 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); |
414 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); |
|
415 |
412 if ( decErr != KErrNone ) |
416 if ( decErr != KErrNone ) |
413 { |
417 { |
414 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - error 2" ); |
418 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder no mime error %d", decErr ); |
415 |
419 |
416 User::Leave( decErr ); |
420 User::Leave( decErr ); |
417 } |
421 } |
418 } |
422 } |
419 |
423 |
420 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
424 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
421 } |
425 } |
422 } |
426 } |
423 else |
427 else |
424 { |
428 { |
425 |
|
426 if ( !iBuffer ) |
429 if ( !iBuffer ) |
427 { |
430 { |
428 TRAPD( decErr, iDecoder = CExtJpegDecoder::FileNewL( |
431 TRAPD( decErr, iDecoder = CExtJpegDecoder::FileNewL( |
429 CExtJpegDecoder::EHwImplementation, iFs, fullName, options) ); |
432 CExtJpegDecoder::EHwImplementation, iFs, fullName, options) ); |
430 |
433 |
431 if ( decErr != KErrNone ) |
434 if ( decErr != KErrNone ) |
432 { |
435 { |
|
436 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - HW CExtJpegDecoder failed %d", decErr); |
|
437 LeaveIfCorruptL(decErr); |
|
438 |
433 TRAP( decErr, iDecoder = CExtJpegDecoder::FileNewL( |
439 TRAP( decErr, iDecoder = CExtJpegDecoder::FileNewL( |
434 CExtJpegDecoder::ESwImplementation, iFs, fullName, options) ); |
440 CExtJpegDecoder::ESwImplementation, iFs, fullName, options) ); |
435 |
441 |
436 if ( decErr != KErrNone ) |
442 if ( decErr != KErrNone ) |
437 { |
443 { |
438 iDecoder = CImageDecoder::FileNewL( iFile, ContentAccess::EPeek, options ); |
444 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - SW CExtJpegDecoder failed %d", decErr); |
|
445 LeaveIfCorruptL(decErr); |
|
446 |
|
447 TRAP( decErr, iDecoder = CImageDecoder::FileNewL( iFile, ContentAccess::EPeek, options )); |
|
448 |
|
449 if( decErr != KErrNone) |
|
450 { |
|
451 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder failed %d", decErr); |
|
452 User::Leave( decErr ); |
|
453 } |
439 |
454 |
440 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
455 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
441 } |
456 } |
442 else |
457 else |
443 { |
458 { |
454 TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( |
469 TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( |
455 CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); |
470 CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); |
456 |
471 |
457 if ( decErr != KErrNone ) |
472 if ( decErr != KErrNone ) |
458 { |
473 { |
|
474 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - HW CExtJpegDecoder failed %d", decErr); |
|
475 LeaveIfCorruptL(decErr); |
|
476 |
459 TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( |
477 TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( |
460 CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); |
478 CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); |
461 |
479 |
462 if ( decErr != KErrNone ) |
480 if ( decErr != KErrNone ) |
463 { |
481 { |
|
482 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - SW CExtJpegDecoder failed %d", decErr); |
|
483 LeaveIfCorruptL(decErr); |
464 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); |
484 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); |
465 |
485 |
466 if ( decErr != KErrNone ) |
486 if ( decErr != KErrNone ) |
467 { |
487 { |
|
488 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder failed %d", decErr); |
|
489 LeaveIfCorruptL(decErr); |
468 // don't force any mime type |
490 // don't force any mime type |
469 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); |
491 TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); |
|
492 |
470 if ( decErr != KErrNone ) |
493 if ( decErr != KErrNone ) |
471 { |
494 { |
472 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - error 3" ); |
495 TN_DEBUG2( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder no mime failed %d", decErr); |
473 |
|
474 User::Leave( decErr ); |
496 User::Leave( decErr ); |
475 } |
497 } |
476 } |
498 } |
477 |
499 |
478 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
500 TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); |
538 iDecoder = NULL; |
560 iDecoder = NULL; |
539 |
561 |
540 CImageDecoder::TOptions options; |
562 CImageDecoder::TOptions options; |
541 if ( aFlags == CThumbnailManager::EOptimizeForQuality ) |
563 if ( aFlags == CThumbnailManager::EOptimizeForQuality ) |
542 { |
564 { |
543 options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither ); |
565 options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither | CImageDecoder::EOptionAlwaysThread ); |
544 } |
566 } |
545 else |
567 else |
546 { |
568 { |
547 options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither | |
569 options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither | |
548 CImageDecoder::EPreferFastDecode ); |
570 CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionAlwaysThread ); |
549 } |
571 } |
550 |
572 |
551 TRAPD( err, iDecoder = CExtJpegDecoder::DataNewL( iFs, * iExifThumbImage, |
573 TRAPD( err, iDecoder = CExtJpegDecoder::DataNewL( iFs, * iExifThumbImage, |
552 options )); |
574 options )); |
553 |
575 |
586 const TSize& CThumbnailImageDecoder::OriginalSize()const |
608 const TSize& CThumbnailImageDecoder::OriginalSize()const |
587 { |
609 { |
588 return iOriginalSize; |
610 return iOriginalSize; |
589 } |
611 } |
590 |
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // CThumbnailImageDecoder::LeaveIfCorruptL() |
|
615 // Leave is image is corrupted |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 void CThumbnailImageDecoder::LeaveIfCorruptL(const TInt aError ) |
|
619 { |
|
620 //no sense to try other codecs if image is corrupted |
|
621 if( aError == KErrCorrupt || aError == KErrUnderflow) |
|
622 { |
|
623 User::Leave( aError ); |
|
624 } |
|
625 } |
|
626 |
591 //End of file |
627 //End of file |