summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/slave/jpeg_slave.cpp52
1 files changed, 30 insertions, 22 deletions
diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
index fb7d5de..1bb81d9 100644
--- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
@@ -13,7 +13,7 @@ using namespace Opie::Core;
13#include <qimage.h> 13#include <qimage.h>
14 14
15/** 15/**
16 exif.h 16 exif.h
17*/ 17*/
18 18
19#include <stdio.h> 19#include <stdio.h>
@@ -266,7 +266,7 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
266 266
267 if (a >= 6){ 267 if (a >= 6){
268 268
269 owarn << "too many padding bytes" << oendl; 269 owarn << "too many padding bytes" << oendl;
270 return false; 270 return false;
271 271
272 } 272 }
@@ -331,14 +331,14 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
331 return true; 331 return true;
332 332
333 case M_EOI: // in case it's a tables-only JPEG stream 333 case M_EOI: // in case it's a tables-only JPEG stream
334 owarn << "No image in jpeg!" << oendl; 334 owarn << "No image in jpeg!" << oendl;
335 return false; 335 return false;
336 336
337 case M_COM: // Comment section 337 case M_COM: // Comment section
338 // pieczy 2002-02-12 338 // pieczy 2002-02-12
339 // now the User comment goes to UserComment 339 // now the User comment goes to UserComment
340 // so we can store a Comment section also in READ_EXIF mode 340 // so we can store a Comment section also in READ_EXIF mode
341 process_COM(Data, itemlen); 341 process_COM(Data, itemlen);
342 break; 342 break;
343 343
344 case M_JFIF: 344 case M_JFIF:
@@ -547,14 +547,14 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
547 547
548 case TAG_MODEL: 548 case TAG_MODEL:
549 ExifData::CameraModel = QString((char*)ValuePtr); 549 ExifData::CameraModel = QString((char*)ValuePtr);
550 break; 550 break;
551 551
552 case TAG_ORIENTATION: 552 case TAG_ORIENTATION:
553 Orientation = (int)ConvertAnyFormat(ValuePtr, Format); 553 Orientation = (int)ConvertAnyFormat(ValuePtr, Format);
554 break; 554 break;
555 555
556 case TAG_DATETIME_ORIGINAL: 556 case TAG_DATETIME_ORIGINAL:
557 DateTime = QString((char*)ValuePtr); 557 DateTime = QString((char*)ValuePtr);
558 break; 558 break;
559 559
560 case TAG_USERCOMMENT: 560 case TAG_USERCOMMENT:
@@ -589,7 +589,7 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
589 case TAG_FNUMBER: 589 case TAG_FNUMBER:
590 // Simplest way of expressing aperture, so I trust it the most. 590 // Simplest way of expressing aperture, so I trust it the most.
591 // (overwrite previously computd value if there is one) 591 // (overwrite previously computd value if there is one)
592 ExifData::ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format); 592 ExifData::ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format);
593 break; 593 break;
594 594
595 case TAG_APERTURE: 595 case TAG_APERTURE:
@@ -666,12 +666,12 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
666 // Remaining cases contributed by: Volker C. Schoech (schoech@gmx.de) 666 // Remaining cases contributed by: Volker C. Schoech (schoech@gmx.de)
667 667
668 case TAG_EXPOSURE_BIAS: 668 case TAG_EXPOSURE_BIAS:
669 ExifData::ExposureBias = (float)ConvertAnyFormat(ValuePtr, Format); 669 ExifData::ExposureBias = (float)ConvertAnyFormat(ValuePtr, Format);
670 break; 670 break;
671 671
672 case TAG_WHITEBALANCE: 672 case TAG_WHITEBALANCE:
673 ExifData::Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format); 673 ExifData::Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format);
674 break; 674 break;
675 675
676 case TAG_METERING_MODE: 676 case TAG_METERING_MODE:
677 ExifData::MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format); 677 ExifData::MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format);
@@ -720,17 +720,17 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
720 720
721 if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){ 721 if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){
722 Offset = Get32u(DIR_ENTRY_ADDR(DirStart, NumDirEntries)); 722 Offset = Get32u(DIR_ENTRY_ADDR(DirStart, NumDirEntries));
723 // There is at least one jpeg from an HP camera having an Offset of almost MAXUINT. 723 // There is at least one jpeg from an HP camera having an Offset of almost MAXUINT.
724 // Adding OffsetBase to it produces an overflow, so compare with ExifLength here. 724 // Adding OffsetBase to it produces an overflow, so compare with ExifLength here.
725 // See http://bugs.kde.org/show_bug.cgi?id=54542 725 // See http://bugs.kde.org/show_bug.cgi?id=54542
726 if (Offset && Offset < ExifLength){ 726 if (Offset && Offset < ExifLength){
727 SubdirStart = OffsetBase + Offset; 727 SubdirStart = OffsetBase + Offset;
728 if (SubdirStart > OffsetBase+ExifLength){ 728 if (SubdirStart > OffsetBase+ExifLength){
729 if (SubdirStart < OffsetBase+ExifLength+20){ 729 if (SubdirStart < OffsetBase+ExifLength+20){
730 // Jhead 1.3 or earlier would crop the whole directory! 730 // Jhead 1.3 or earlier would crop the whole directory!
731 // As Jhead produces this form of format incorrectness, 731 // As Jhead produces this form of format incorrectness,
732 // I'll just let it pass silently 732 // I'll just let it pass silently
733 owarn << "Thumbnail removed with Jhead 1.3 or earlier" << oendl; 733 owarn << "Thumbnail removed with Jhead 1.3 or earlier" << oendl;
734 }else{ 734 }else{
735 return; 735 return;
736 } 736 }
@@ -748,7 +748,7 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
748 if (ThumbnailSize && ThumbnailOffset){ 748 if (ThumbnailSize && ThumbnailOffset){
749 if (ThumbnailSize + ThumbnailOffset <= ExifLength){ 749 if (ThumbnailSize + ThumbnailOffset <= ExifLength){
750 // The thumbnail pointer appears to be valid. Store it. 750 // The thumbnail pointer appears to be valid. Store it.
751 Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG"); 751 Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG");
752 } 752 }
753 } 753 }
754} 754}
@@ -917,7 +917,7 @@ bool ExifData::scan(const QString & path)
917 ret = ReadJpegSections(f, READ_EXIF); 917 ret = ReadJpegSections(f, READ_EXIF);
918 918
919 if (ret == false){ 919 if (ret == false){
920 owarn << "Not JPEG file!" << oendl; 920 owarn << "Not JPEG file!" << oendl;
921 DiscardData(); 921 DiscardData();
922 f.close(); 922 f.close();
923 return false; 923 return false;
@@ -1415,11 +1415,19 @@ QString JpegSlave::fullImageInfo( const QString& path) {
1415 1415
1416QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) { 1416QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) {
1417 ExifData ImageInfo; 1417 ExifData ImageInfo;
1418 /*
1419 */
1418 if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) { 1420 if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) {
1419 QImage img; 1421 QImage img;
1420 QImageIO iio( path, 0l ); 1422 QImageIO iio( path, 0l );
1421 QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); 1423 if (wid < ImageInfo.getWidth() || hei<ImageInfo.getHeight()) {
1422 iio.setParameters( str.latin1() );// will be strdupped anyway 1424 odebug << "Scaling "<<ImageInfo.getWidth()<<"x"<<ImageInfo.getHeight()
1425 << " to "<<wid<<"x"<<hei<< " ("<<path<<")"<<oendl;
1426 QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei );
1427 iio.setParameters( str.latin1() );// will be strdupped anyway
1428 } else {
1429 odebug << "Not scaling "<<ImageInfo.getWidth()<<"x"<<ImageInfo.getHeight()<< " ("<<path<<")"<<oendl;
1430 }
1423 img = iio.read() ? iio.image() : QImage(); 1431 img = iio.read() ? iio.image() : QImage();
1424 return ThumbNailTool::scaleImage( img, wid,hei ); 1432 return ThumbNailTool::scaleImage( img, wid,hei );
1425 }else{ 1433 }else{