-rw-r--r-- | noncore/graphics/opie-eye/config.in | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp | 14 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_lister.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/slavemaster.cpp | 12 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/phunk_view.pro | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/jpeg_slave.cpp | 18 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/main.cpp | 16 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/slave.pro | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/slavereciever.cpp | 22 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/thumbnailtool.cpp | 11 |
10 files changed, 68 insertions, 45 deletions
diff --git a/noncore/graphics/opie-eye/config.in b/noncore/graphics/opie-eye/config.in index 996dcf3..d7f9963 100644 --- a/noncore/graphics/opie-eye/config.in +++ b/noncore/graphics/opie-eye/config.in @@ -1,9 +1,9 @@ config OPIE_EYE boolean "opie-eye The Image Viewer and Browser" default "y" - depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI + depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI config OPIE_EYE_SLAVE boolean default "y" if OPIE_EYE - depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI + depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI diff --git a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp index 79f4510..5599ad1 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp @@ -1,47 +1,51 @@ /* * GPLv2 * zecke@handhelds.org */ +#include "dir_ifaceinfo.h" + +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/config.h> +using namespace Opie::Core; + +/* QT */ #include <qwidget.h> #include <qcheckbox.h> #include <qhbox.h> #include <qlabel.h> -#include <qpe/config.h> - -#include "dir_ifaceinfo.h" - namespace { class DirImageWidget : public QHBox { public: DirImageWidget() { chkbox = new QCheckBox( QObject::tr("Show all files"), this ); } ~DirImageWidget() {} QCheckBox* chkbox; }; } DirInterfaceInfo::DirInterfaceInfo() { } DirInterfaceInfo::~DirInterfaceInfo() { } QString DirInterfaceInfo::name()const { return QString::fromLatin1(QObject::tr("DirView" )); } QWidget* DirInterfaceInfo::configWidget(const Config& cfg) { DirImageWidget* wid = new DirImageWidget(); wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) ); return wid; } void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) { - qWarning( "Write Config" ); + owarn << "Write Config" << oendl; DirImageWidget* wid = static_cast<DirImageWidget*>(_wid); cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() ); } diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp index ffea29e..0a5cff4 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp @@ -1,69 +1,71 @@ /* * GPLv2 zecke@handhelds.org */ #include "dir_lister.h" #include <lib/slavemaster.h> - +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; +/* QT */ #include <qdir.h> #include <qfileinfo.h> - Dir_DirLister::Dir_DirLister( bool list ) : PDirLister( "dir_dir_lister" ) { m_allFiles = list; - qWarning("All Files %d", m_allFiles ); + owarn << "All Files " << m_allFiles << "" << oendl; SlaveMaster* master = SlaveMaster::self(); connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), this, SIGNAL(sig_thumbInfo(const QString&, const QString&)) ); connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), this, SIGNAL(sig_fullInfo(const QString&, const QString&)) ); connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), this, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)) ); } QString Dir_DirLister::defaultPath()const { return QPEApplication::documentDir(); } QString Dir_DirLister::setStartPath( const QString& path ) { m_currentDir.cd( path ); if (!m_currentDir.exists() ) m_currentDir.cd(defaultPath()); return m_currentDir.absPath(); } QString Dir_DirLister::currentPath()const { return m_currentDir.absPath(); } QStringList Dir_DirLister::folders()const { return m_currentDir.entryList( QDir::Dirs ); } QStringList Dir_DirLister::files()const { if ( m_allFiles ) return m_currentDir.entryList( QDir::Files ); else { QStringList out; QStringList list = m_currentDir.entryList( QDir::Files | QDir::Readable ); for (QStringList::Iterator it = list.begin(); it != list.end();++it ) { QFileInfo inf( *it ); QString ext = inf.extension(false).lower(); if( ext == QString::fromLatin1("jpg") || ext == QString::fromLatin1("jpeg" ) || ext == QString::fromLatin1("png" ) || ext == QString::fromLatin1("gif" ) ) diff --git a/noncore/graphics/opie-eye/lib/slavemaster.cpp b/noncore/graphics/opie-eye/lib/slavemaster.cpp index 4e28535..5bb7ab8 100644 --- a/noncore/graphics/opie-eye/lib/slavemaster.cpp +++ b/noncore/graphics/opie-eye/lib/slavemaster.cpp @@ -1,150 +1,154 @@ #include "slavemaster.h" +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> +using namespace Opie::Core; +/* QT */ #include <qcopchannel_qws.h> #include <qtimer.h> QDataStream & operator << (QDataStream & str, bool b) { str << Q_INT8(b); return str; } QDataStream & operator >> (QDataStream & str, bool & b) { Q_INT8 l; str >> l; b = bool(l); return str; } /* * ! We don't put a Pixmap in!!!! */ QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { - qWarning( "Image request is %s %d %d", inf.file.latin1(), inf.width, inf.height ); + owarn << "Image request is " << inf.file.latin1() << " " << inf.width << " " << inf.height << "" << oendl; return s << inf.file << inf.width << inf.height; } QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { s >> inf.file >> inf.pixmap >> inf.width >> inf.height; return s; } QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { return s << i.kind << i.file << i.info; } QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { s >> i.kind >> i.file >> i.info; return s; } SlaveMaster* SlaveMaster::m_master = 0; SlaveMaster::SlaveMaster() : m_started( false ) { QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this ); connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(recieve(const QCString&,const QByteArray&)) ); } SlaveMaster::~SlaveMaster() { } SlaveMaster* SlaveMaster::self() { if ( !m_master ) m_master = new SlaveMaster; return m_master; } void SlaveMaster::thumbInfo( const QString& str) { m_inThumbInfo.append( str ); if ( !m_started ) { QTimer::singleShot( 0, this, SLOT(slotTimerStart())); m_started = true; } } void SlaveMaster::imageInfo( const QString& str ) { m_inImageInfo.append( str ); if ( !m_started ) { QTimer::singleShot( 0, this, SLOT(slotTimerStart())); m_started = true; } } void SlaveMaster::thumbNail( const QString& str, int w, int h ) { if ( str.isEmpty() ) { - qWarning( "Asking for empty nail" ); + owarn << "Asking for empty nail" << oendl; return; } - qWarning( "Asking for thumbNail in size %d %d" + str, w,h ); + owarn << "Asking for thumbNail in size " << w << " " << h << "" + str << oendl; PixmapInfo item; item.file = str; item.width = w; item.height = h; item.pixmap = QPixmap(); m_inThumbNail.append( item ); if ( !m_started ) { QTimer::singleShot( 0, this, SLOT(slotTimerStart())); m_started = true; } } void SlaveMaster::recieve( const QCString& str, const QByteArray& at) { ImageInfos infos; PixmapInfos pixinfos; QDataStream stream( at, IO_ReadOnly ); if ( str == "pixmapsHandled(PixmapList)" ) stream >> pixinfos; else if ( str == "pixmapsHandled(StringList)" ) stream >> infos; - qWarning( "PixInfos %d", pixinfos.count() ); + owarn << "PixInfos " << pixinfos.count() << "" << oendl; bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() ); if ( got_data ) { emit sig_start(); for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) { if ( (*_it).kind ) emit sig_fullInfo( (*_it).file, (*_it).info ); else emit sig_thumbInfo( (*_it).file, (*_it).info ); } for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) emit sig_thumbNail( (*it).file, (*it).pixmap ); emit sig_end(); } } void SlaveMaster::slotTimerStart() { m_started = false; if ( !m_inThumbInfo.isEmpty() ) { QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" ); env << m_inThumbInfo; } if ( !m_inImageInfo.isEmpty() ) { QCopEnvelope env("QPE/opie-eye_slave", "fullInfos(QStringList)" ); env << m_inImageInfo; } if ( !m_inThumbNail.isEmpty() ) { QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); env << m_inThumbNail; } m_inThumbInfo.clear(); m_inImageInfo.clear(); m_inThumbNail.clear(); } QImage SlaveMaster::image( const QString& str, PDirLister::Factor, int ) { return QImage(); } diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro index 17fa22c..0e2202a 100644 --- a/noncore/graphics/opie-eye/phunk_view.pro +++ b/noncore/graphics/opie-eye/phunk_view.pro @@ -1,36 +1,36 @@ CONFIG += qt warn_on quick-app DESTDIR = $(OPIEDIR)/bin TEMPLATE = app TARGET = opie-eye # the name of the resulting object HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \ lib/imagecache.h impl/dir/dir_dirview.h \ iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \ impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \ lib/slavemaster.h \ iface/slaveiface.h \ gui/imageinfoui.h # A list header files SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \ lib/imagecache.cpp lib/viewmap.cpp \ impl/dir/dir_dirview.cpp iface/dirlister.cpp \ iface/dirview.cpp impl/dir/dir_lister.cpp \ impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \ gui/imageinfoui.cpp # A list of source files INTERFACES = # list of ui files INCLUDEPATH += . $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopieui2 +LIBS += -lqpe -lopiecore2 -lopieui2 include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp index 086b47f..fb7d5de 100644 --- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp +++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp @@ -1,55 +1,59 @@ #include "jpeg_slave.h" - #include "thumbnailtool.h" PHUNK_VIEW_INTERFACE( "JPEG", JpegSlave ) -#include <qtopia/timestring.h> +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/timestring.h> +using namespace Opie::Core; + +/* QT */ #include <qobject.h> #include <qimage.h> /** exif.h */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <qstring.h> #include <qfile.h> #include <qimage.h> typedef enum { READ_EXIF = 1, READ_IMAGE = 2, READ_ALL = 3 }ReadMode_t; //-------------------------------------------------------------------------- // This structure is used to store jpeg file sections in memory. typedef struct { uchar * Data; int Type; unsigned Size; }Section_t; typedef unsigned char uchar; typedef struct { unsigned short Tag; const char*const Desc; }TagTable_t; #define MAX_SECTIONS 20 #define PSEUDO_IMAGE_MARKER 0x123; // Extra value. class ExifData { Section_t Sections[MAX_SECTIONS]; QString CameraMake; QString CameraModel; QString DateTime; int Orientation; int Height, Width; @@ -74,97 +78,97 @@ class ExifData { int ReadJpegSections (QFile & infile, ReadMode_t ReadMode); void DiscardData(void); int Get16u(void * Short); int Get32s(void * Long); unsigned Get32u(void * Long); double ConvertAnyFormat(void * ValuePtr, int Format); void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength); void process_COM (const uchar * Data, int length); void process_SOFn (const uchar * Data, int marker); int Get16m(const void * Short); void process_EXIF(unsigned char * CharBuf, unsigned int length); int Exif2tm(struct tm * timeptr, char * ExifTime); public: ExifData(); bool scan(const QString &); QString getCameraMake() { return CameraMake; } QString getCameraModel() { return CameraModel; } QString getDateTime() { return DateTime; } int getOrientation() { return Orientation; } int getHeight() { return Height; } int getWidth() { return Width; } int getIsColor() { return IsColor; } int getProcess() { return Process; } int getFlashUsed() { return FlashUsed; } float getFocalLength() { return FocalLength; } float getExposureTime() { return ExposureTime; } float getApertureFNumber() { return ApertureFNumber; } float getDistance() { return Distance; } int getWhitebalance() { return Whitebalance; } int getMeteringMode() { return MeteringMode; } float getCCDWidth() { return CCDWidth; } float getExposureBias() { return ExposureBias; } int getExposureProgram() { return ExposureProgram; } int getISOequivalent() { return ISOequivalent; } int getCompressionLevel() { return CompressionLevel; } QString getUserComment() { return UserComment; } QString getComment() { return Comment; } QImage getThumbnail(); bool isThumbnailSane(); bool isNullThumbnail() { return !isThumbnailSane(); } }; class FatalError { const char* ex; public: FatalError(const char* s) { ex = s; } - void debug_print() const { qWarning("exception: %s", ex ); } + void debug_print() const { owarn << "exception: " << ex << "" << oendl; } }; static unsigned char * LastExifRefd; static int ExifSettingsLength; static double FocalplaneXRes; static double FocalplaneUnits; static int MotorolaOrder = 0; static int SectionsRead; //static int HaveAll; //-------------------------------------------------------------------------- // Table of Jpeg encoding process names #define M_SOF0 0xC0 // Start Of Frame N #define M_SOF1 0xC1 // N indicates which compression process #define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use #define M_SOF3 0xC3 #define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers #define M_SOF6 0xC6 #define M_SOF7 0xC7 #define M_SOF9 0xC9 #define M_SOF10 0xCA #define M_SOF11 0xCB #define M_SOF13 0xCD #define M_SOF14 0xCE #define M_SOF15 0xCF #define M_SOI 0xD8 // Start Of Image (beginning of datastream) #define M_EOI 0xD9 // End Of Image (end of datastream) #define M_SOS 0xDA // Start Of Scan (begins compressed data) #define M_JFIF 0xE0 // Jfif marker #define M_EXIF 0xE1 // Exif marker #define M_COM 0xFE // COMment TagTable_t ProcessTable[] = { { M_SOF0, "Baseline"}, { M_SOF1, "Extended sequential"}, { M_SOF2, "Progressive"}, { M_SOF3, "Lossless"}, { M_SOF5, "Differential sequential"}, { M_SOF6, "Differential progressive"}, { M_SOF7, "Differential lossless"}, { M_SOF9, "Extended sequential, arithmetic coding"}, { M_SOF10, "Progressive, arithmetic coding"}, { M_SOF11, "Lossless, arithmetic coding"}, { M_SOF13, "Differential sequential, arithmetic coding"}, @@ -217,162 +221,162 @@ static int BytesPerFormat[] = {0,1,1,2,4,8,1,1,2,4,8,4,8}; #define TAG_SUBJECT_DISTANCE 0x9206 #define TAG_FLASH 0x9209 #define TAG_FOCALPLANEXRES 0xa20E #define TAG_FOCALPLANEUNITS 0xa210 #define TAG_EXIF_IMAGEWIDTH 0xA002 #define TAG_EXIF_IMAGELENGTH 0xA003 // the following is added 05-jan-2001 vcs #define TAG_EXPOSURE_BIAS 0x9204 #define TAG_WHITEBALANCE 0x9208 #define TAG_METERING_MODE 0x9207 #define TAG_EXPOSURE_PROGRAM 0x8822 #define TAG_ISO_EQUIVALENT 0x8827 #define TAG_COMPRESSION_LEVEL 0x9102 #define TAG_THUMBNAIL_OFFSET 0x0201 #define TAG_THUMBNAIL_LENGTH 0x0202 //-------------------------------------------------------------------------- // Parse the marker stream until SOS or EOI is seen; //-------------------------------------------------------------------------- int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode) { int a; a = infile.getch(); if (a != 0xff || infile.getch() != M_SOI) { SectionsRead = 0; return false; } for(SectionsRead = 0; SectionsRead < MAX_SECTIONS-1; ){ int marker = 0; int got; unsigned int ll,lh; unsigned int itemlen; uchar * Data; for (a=0;a<7;a++){ marker = infile.getch(); if (marker != 0xff) break; if (a >= 6){ - qWarning( "too many padding bytes" ); + owarn << "too many padding bytes" << oendl; return false; } } if (marker == 0xff){ // 0xff is legal padding, but if we get that many, something's wrong. return false; } Sections[SectionsRead].Type = marker; // Read the length of the section. lh = (uchar) infile.getch(); ll = (uchar) infile.getch(); itemlen = (lh << 8) | ll; if (itemlen < 2) { return false;; } Sections[SectionsRead].Size = itemlen; Data = (uchar *)malloc(itemlen+1); // Add 1 to allow sticking a 0 at the end. Sections[SectionsRead].Data = Data; // Store first two pre-read bytes. Data[0] = (uchar)lh; Data[1] = (uchar)ll; got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section. if (( unsigned ) got != itemlen-2){ return false; } SectionsRead++; switch(marker){ case M_SOS: // stop before hitting compressed data // If reading entire image is requested, read the rest of the data. if (ReadMode & READ_IMAGE){ unsigned long size; size = QMAX( 0ul, infile.size()-infile.at() ); Data = (uchar *)malloc(size); if (Data == NULL){ return false; } got = infile.readBlock((char*)Data, size); if (( unsigned ) got != size){ return false; } Sections[SectionsRead].Data = Data; Sections[SectionsRead].Size = size; Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER; SectionsRead ++; //HaveAll = 1; } return true; case M_EOI: // in case it's a tables-only JPEG stream - qWarning( "No image in jpeg!" ); + owarn << "No image in jpeg!" << oendl; return false; case M_COM: // Comment section // pieczy 2002-02-12 // now the User comment goes to UserComment // so we can store a Comment section also in READ_EXIF mode process_COM(Data, itemlen); break; case M_JFIF: // Regular jpegs always have this tag, exif images have the exif // marker instead, althogh ACDsee will write images with both markers. // this program will re-create this marker on absence of exif marker. // hence no need to keep the copy from the file. free(Sections[--SectionsRead].Data); break; case M_EXIF: // Seen files from some 'U-lead' software with Vivitar scanner // that uses marker 31 for non exif stuff. Thus make sure // it says 'Exif' in the section before treating it as exif. if ((ReadMode & READ_EXIF) && memcmp(Data+2, "Exif", 4) == 0){ process_EXIF((uchar *)Data, itemlen); }else{ // Discard this section. free(Sections[--SectionsRead].Data); } break; case M_SOF0: case M_SOF1: case M_SOF2: case M_SOF3: case M_SOF5: case M_SOF6: case M_SOF7: case M_SOF9: case M_SOF10: case M_SOF11: case M_SOF13: case M_SOF14: case M_SOF15: process_SOFn(Data, marker); default: break; break; } } @@ -681,97 +685,97 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa ExifData::ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format); if ( ExifData::ISOequivalent < 50 ) ExifData::ISOequivalent *= 200; break; case TAG_COMPRESSION_LEVEL: ExifData::CompressionLevel = (int)ConvertAnyFormat(ValuePtr, Format); break; case TAG_THUMBNAIL_OFFSET: ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format); break; case TAG_THUMBNAIL_LENGTH: ThumbnailSize = (unsigned)ConvertAnyFormat(ValuePtr, Format); break; } if (Tag == TAG_EXIF_OFFSET || Tag == TAG_INTEROP_OFFSET){ unsigned char * SubdirStart; SubdirStart = OffsetBase + Get32u(ValuePtr); if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){ return; } ProcessExifDir(SubdirStart, OffsetBase, ExifLength); continue; } } { // In addition to linking to subdirectories via exif tags, // there's also a potential link to another directory at the end of each // directory. this has got to be the result of a comitee! unsigned char * SubdirStart; unsigned Offset; if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){ Offset = Get32u(DIR_ENTRY_ADDR(DirStart, NumDirEntries)); // There is at least one jpeg from an HP camera having an Offset of almost MAXUINT. // Adding OffsetBase to it produces an overflow, so compare with ExifLength here. // See http://bugs.kde.org/show_bug.cgi?id=54542 if (Offset && Offset < ExifLength){ SubdirStart = OffsetBase + Offset; if (SubdirStart > OffsetBase+ExifLength){ if (SubdirStart < OffsetBase+ExifLength+20){ // Jhead 1.3 or earlier would crop the whole directory! // As Jhead produces this form of format incorrectness, // I'll just let it pass silently - qWarning( "Thumbnail removed with Jhead 1.3 or earlier" ); + owarn << "Thumbnail removed with Jhead 1.3 or earlier" << oendl; }else{ return; } }else{ if (SubdirStart <= OffsetBase+ExifLength){ ProcessExifDir(SubdirStart, OffsetBase, ExifLength); } } } }else{ // The exif header ends before the last next directory pointer. } } if (ThumbnailSize && ThumbnailOffset){ if (ThumbnailSize + ThumbnailOffset <= ExifLength){ // The thumbnail pointer appears to be valid. Store it. Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG"); } } } //-------------------------------------------------------------------------- // Process a COM marker. We want to leave the bytes unchanged. The // progam that displays this text may decide to remove blanks, convert // newlines, or otherwise modify the text. In particular we want to be // safe for passing utf-8 text. //-------------------------------------------------------------------------- void ExifData::process_COM (const uchar * Data, int length) { QChar ch; int a; for (a=2;a<length;a++){ ch = Data[a]; if (ch == '\000') continue; // Remove nulls Comment.append(ch); } } //-------------------------------------------------------------------------- // Process a SOFn marker. This is useful for the image dimensions //-------------------------------------------------------------------------- void ExifData::process_SOFn (const uchar * Data, int marker) { int data_precision, num_components; @@ -868,97 +872,97 @@ int ExifData::Exif2tm(struct tm * timeptr, char * ExifTime) if (a == 6){ timeptr->tm_isdst = -1; timeptr->tm_mon -= 1; // Adjust for unix zero-based months timeptr->tm_year -= 1900; // Adjust for year starting at 1900 return true; // worked. } return false; // Wasn't in Exif date format. } //-------------------------------------------------------------------------- // Contructor for initialising //-------------------------------------------------------------------------- ExifData::ExifData() { ExifData::Whitebalance = -1; ExifData::MeteringMode = -1; ExifData::FlashUsed = -1; Orientation = 0; Height = 0; Width = 0; IsColor = 0; Process = 0; FocalLength = 0; ExposureTime = 0; ApertureFNumber = 0; Distance = 0; CCDWidth = 0; ExposureBias = 0; ExposureProgram = 0; ISOequivalent = 0; CompressionLevel = 0; } //-------------------------------------------------------------------------- // process a EXIF jpeg file //-------------------------------------------------------------------------- bool ExifData::scan(const QString & path) { int ret; QFile f(path); f.open(IO_ReadOnly); // Scan the JPEG headers. ret = ReadJpegSections(f, READ_EXIF); if (ret == false){ - qWarning( "Not JPEG file!" ); + owarn << "Not JPEG file!" << oendl; DiscardData(); f.close(); return false; } f.close(); DiscardData(); //now make the strings clean, // for exmaple my Casio is a "QV-4000 " CameraMake = CameraMake.stripWhiteSpace(); CameraModel = CameraModel.stripWhiteSpace(); UserComment = UserComment.stripWhiteSpace(); Comment = Comment.stripWhiteSpace(); return true; } //-------------------------------------------------------------------------- // Does the embedded thumbnail match the jpeg image? //-------------------------------------------------------------------------- #ifndef JPEG_TOL #define JPEG_TOL 0.02 #endif bool ExifData::isThumbnailSane() { if (Thumbnail.isNull()) return false; // check whether thumbnail dimensions match the image // not foolproof, but catches some altered images (jpegtran -rotate) if (ExifImageLength != 0 && ExifImageLength != Height) return false; if (ExifImageWidth != 0 && ExifImageWidth != Width) return false; if (Thumbnail.width() == 0 || Thumbnail.height() == 0) return false; if (Height == 0 || Width == 0) return false; double d = (double)Height/Width*Thumbnail.width()/Thumbnail.height(); return (1-JPEG_TOL < d) && (d < 1+JPEG_TOL); } static QImage flip_image( const QImage& img ); static QImage rotate_90( const QImage& img ); static QImage rotate_180( const QImage& ); static QImage rotate_270( const QImage& ); //-------------------------------------------------------------------------- // return a thumbnail that respects the orientation flag // only if it seems sane //-------------------------------------------------------------------------- QImage ExifData::getThumbnail() { if (!isThumbnailSane()) return NULL; diff --git a/noncore/graphics/opie-eye/slave/main.cpp b/noncore/graphics/opie-eye/slave/main.cpp index 37020e6..5b90483 100644 --- a/noncore/graphics/opie-eye/slave/main.cpp +++ b/noncore/graphics/opie-eye/slave/main.cpp @@ -1,59 +1,59 @@ /* * GPLv2 Slave Main */ #include "gif_slave.h" #include "png_slave.h" #include "jpeg_slave.h" #include "thumbnailtool.h" #include "slavereciever.h" #include <qpixmap.h> #include <qcopchannel_qws.h> #include <qtopia/qpeapplication.h> int main( int argc, char* argv[] ) { QPEApplication app( argc, argv ); SlaveReciever rec( 0 ); QCopChannel chan( "QPE/opie-eye_slave" ); QObject::connect(&chan,SIGNAL(received(const QCString&, const QByteArray&)), &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&))); QObject::connect(qApp,SIGNAL(appMessage(const QCString&, const QByteArray&)), &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&))); return app.exec(); } #ifdef DEBUG_IT int main( int argc, char* argv[] ) { QString str = QString::fromLatin1(argv[2] ); QApplication app( argc, argv ); GifSlave slave; - qWarning( str +" "+slave.iconViewName(str ) ); - qWarning( str+" "+slave.fullImageInfo( str ) ); + owarn << str +" "+slave.iconViewName(str ) << oendl; + owarn << str+" "+slave.fullImageInfo( str ) << oendl; PNGSlave pngslave; - qWarning( str + " " + pngslave.iconViewName(str) ); - qWarning( str + " " + pngslave.fullImageInfo(str)); + owarn << str + " " + pngslave.iconViewName(str) << oendl; + owarn << str + " " + pngslave.fullImageInfo(str) << oendl; JpegSlave jpgslave; - qWarning( str + " " + jpgslave.iconViewName(str ) ); - qWarning( str + " " + jpgslave.fullImageInfo( str ) ); + owarn << str + " " + jpgslave.iconViewName(str ) << oendl; + owarn << str + " " + jpgslave.fullImageInfo( str ) << oendl; //return app.exec(); QPixmap pix = ThumbNailTool::getThumb( str, 24, 24 ); if ( pix.isNull() ) { - qWarning( "No Thumbnail" ); + owarn << "No Thumbnail" << oendl; pix = slave.pixmap(str, 24, 24); } if (!pix.isNull() ) { - qWarning( "Saving Thumbnail" ); + owarn << "Saving Thumbnail" << oendl; ThumbNailTool::putThumb( str, pix, 24, 24 ); } } #endif diff --git a/noncore/graphics/opie-eye/slave/slave.pro b/noncore/graphics/opie-eye/slave/slave.pro index 3f42495..903d667 100644 --- a/noncore/graphics/opie-eye/slave/slave.pro +++ b/noncore/graphics/opie-eye/slave/slave.pro @@ -1,18 +1,18 @@ -CONFIG += qte +CONFIG = qt TEMPLATE = app TARGET = opie-eye_slave DESTDIR = $(OPIEDIR)/bin HEADERS = gif_slave.h slaveiface.h slavereciever.h \ thumbnailtool.h png_slave.h jpeg_slave.h \ ../iface/slaveiface.h SOURCES = main.cpp gif_slave.cpp slavereciever.cpp \ slaveiface.cpp thumbnailtool.cpp png_slave.cpp \ jpeg_slave.cpp INCLUDEPATH += $(OPIEDIR)/include ../ DEPENDSPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopiecore2 -include ( $(OPIEDIR)/include.pro )
\ No newline at end of file +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/graphics/opie-eye/slave/slavereciever.cpp b/noncore/graphics/opie-eye/slave/slavereciever.cpp index bbbbb30..82b3d23 100644 --- a/noncore/graphics/opie-eye/slave/slavereciever.cpp +++ b/noncore/graphics/opie-eye/slave/slavereciever.cpp @@ -1,226 +1,230 @@ /* * GPLv2 zecke@handhelds.org */ #include "slavereciever.h" #include "slaveiface.h" +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; +/* QT */ #include <qtimer.h> static SlaveObjects* _slaveObj = 0; QDataStream & operator << (QDataStream & str, bool b) { str << Q_INT8(b); return str; } QDataStream & operator >> (QDataStream & str, bool & b) { Q_INT8 l; str >> l; b = bool(l); return str; } QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { return s << inf.file << inf.pixmap << inf.width << inf.height; } /* * GUI sends no QPIxmap!!! */ QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { s >> inf.file >> inf.width >> inf.height; - qWarning( "Recieved %s %d %d", inf.file.latin1(), inf.width, inf.height ); + owarn << "Recieved " << inf.file.latin1() << " " << inf.width << " " << inf.height << "" << oendl; return s; } QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { return s << i.kind << i.file << i.info; } QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { s >> i.kind >> i.file >> i.info; return s; } SlaveObjects* slaveObjects() { if ( !_slaveObj ) _slaveObj = new SlaveObjects; return _slaveObj; } SlaveReciever::SlaveReciever( QObject* par) : QObject( par ), m_refs( 0 ) { m_inf = new QTimer(this); connect(m_inf,SIGNAL(timeout()), this, SLOT(slotImageInfo())); m_pix = new QTimer(this); connect(m_pix,SIGNAL(timeout()), this, SLOT(slotThumbNail())); m_out = new QTimer(this); connect(m_out,SIGNAL(timeout()), this, SLOT(slotSend())); SlaveObjects *obj = slaveObjects(); // won't be changed SlaveMap::Iterator it; SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! for(it = map->begin(); it != map->end(); ++it ) { obj->insert( it.key(), (*it.data())() ); } } SlaveReciever::~SlaveReciever() { } void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { - qWarning( "String is %s", string.data() ); + owarn << "String is " << string.data() << "" << oendl; QDataStream stream(ar, IO_ReadOnly ); QStringList lst; static ImageInfo inf; static PixmapInfo pix; if ( string == "thumbInfo(QString)" ) { stream >> inf.file; m_inList.append(inf); }else if ( string == "thumbInfos(QStringList)" ) { stream >> lst; for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { - qWarning( "Adding thumbinfo for file "+ *it ); + owarn << "Adding thumbinfo for file "+ *it << oendl; inf.file = (*it); m_inList.append(inf); } }else if ( string == "fullInfo(QString)" ) { inf.kind = true; stream >> inf.file; m_inList.append(inf); }else if ( string == "fullInfos(QStringList)" ) { stream >> lst; for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { - qWarning( "Adding fullInfo for"+ *it ); + owarn << "Adding fullInfo for"+ *it << oendl; inf.file = (*it); inf.kind = true; m_inList.append(inf); } }else if ( string == "pixmapInfo(QString,int,int)" ) { stream >> pix.file >> pix.width >> pix.height; m_inPix.append(pix); }else if ( string == "pixmapInfos(PixmapInfos)" ) { PixmapList list; stream >> list; for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { - qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); + owarn << "Got " << (*it).width << " " << (*it).height << " " + (*it).file << oendl; m_inPix.append(*it); } }else if ( string == "refUp()" ) { m_refs++; }else if ( string == "refDown()" ) { m_refs--; } if (!m_inf->isActive() && !m_inList.isEmpty() ) m_inf->start(5); if (!m_pix->isActive() && !m_inPix.isEmpty() ) m_pix->start(5); if ( m_refs ) QPEApplication::setKeepRunning(); else qApp->quit(); } PixmapList SlaveReciever::outPix()const { return m_outPix; } StringList SlaveReciever::outInf()const{ return m_outList; } void SlaveReciever::slotImageInfo() { ImageInfo inf = m_inList.first(); m_inList.remove( inf ); static SlaveObjects::Iterator it; static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! for(it = map->begin(); it != map->end(); ++it ) { if( (*it)->supports(inf.file ) ) { /* full image info */ if (inf.kind ) inf.info = (*it)->fullImageInfo( inf.file ); else inf.info = (*it)->iconViewName( inf.file ); m_outList.append( inf ); break; } } if (m_inList.isEmpty() ) m_inf->stop(); if (!m_out->isActive() && !m_outList.isEmpty() ) m_out->start( 100 ); } void SlaveReciever::slotThumbNail() { PixmapInfo inf = m_inPix.first(); m_inPix.remove( inf ); static SlaveObjects::Iterator it; static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! for(it = map->begin(); it != map->end(); ++it ) { SlaveInterface* iface = it.data(); if( iface->supports(inf.file ) ) { /* pixmap */ - qWarning( "Asking for thumbNail in size %d %d for "+inf.file, inf.width, inf.height ); + owarn << "Asking for thumbNail in size " << inf.width << " " << inf.height << " for "+inf.file << oendl; inf.pixmap = iface->pixmap(inf.file, 64, 64); m_outPix.append( inf ); break; } } if(m_inPix.isEmpty() ) m_pix->stop(); if(!m_out->isActive() && !m_outPix.isEmpty() ) m_out->start(100); } void SlaveReciever::slotSend() { m_out->stop(); - qWarning( "Sending %d %d", outPix().count(), outInf().count() ); + owarn << "Sending " << outPix().count() << " " << outInf().count() << "" << oendl; /* queue it and send */ /* if this ever gets a service introduce request queues * so we can differinatate between different clients */ if (! m_outPix.isEmpty() ) { QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); answer << outPix(); for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { - qWarning( "Sending out %s %d %d", (*it).file.latin1(), (*it).width, (*it).height ); + owarn << "Sending out " << (*it).file.latin1() << " " << (*it).width << " " << (*it).height << "" << oendl; } } if ( !m_outList.isEmpty() ) { QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); answer << outInf(); for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { - qWarning( "Sending out2 " + (*it).file ); + owarn << "Sending out2 " + (*it).file << oendl; } } m_outList.clear(); m_outPix.clear(); } diff --git a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp index a202457..d2e169c 100644 --- a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp +++ b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp @@ -1,61 +1,66 @@ #include "thumbnailtool.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qfileinfo.h> #include <qdir.h> #include <qimage.h> #include <qpixmap.h> #include <qstring.h> static bool makeThumbDir( const QFileInfo& inf, bool make = false) { QDir dir( inf.dirPath()+ "/.opie-eye" ); if ( !dir.exists() ) if ( make ) return dir.mkdir(QString::null); else return false; return true; } /* * check if the Opie opie-eye dir exists * check if a thumbnail exists * load the thumbnail * /foo/bar/imagefoo.gif * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif */ QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) { QFileInfo inf( path ); - qWarning( "Get Thumb" ); + owarn << "Get Thumb" << oendl; if ( !makeThumbDir( inf ) ) { QPixmap pix; return pix; } QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); - qWarning( inf.dirPath()+str ); + owarn << inf.dirPath()+str << oendl; return QPixmap( inf.dirPath()+str,"PNG" ); } void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) { QFileInfo inf( path ); makeThumbDir( inf, true ); QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); - qWarning( inf.dirPath()+str ); + owarn << inf.dirPath()+str << oendl; pix.save( inf.dirPath()+str, "PNG" ); } QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) { double hs = (double)h / (double)img.height() ; double ws = (double)w / (double)img.width() ; double scaleFactor = (hs > ws) ? ws : hs; int smoothW = (int)(scaleFactor * img.width()); int smoothH = (int)(scaleFactor * img.height()); QPixmap pixmap; if ( img.width() <= w && img.height() <= h ) pixmap.convertFromImage( img ); else pixmap.convertFromImage( img.smoothScale( smoothW, smoothH) ); return pixmap; } |