Re: exif data in full screen (patch v2)

Carles Pina i Estany <[email protected]>
Newsgroups gmane.comp.kde.gwenview
Message-ID <[email protected]>
Hello again!

On Jun/24/2007, Carles Pina i Estany wrote:

> I planned for next days... but I could finish today, at least this
> version.

I send a new version. Just a cosmetic thing showing the example.

> I send the patch attached on this mail. The patch is against last svn
> version.
> 
> Possible things to improve:

Other comment: focal length now is "XX mm", aperture is "F2.8". This
suffixes and prefix comes from exiv2 data, of course I could remove
it, if you think that is better.

Good night!

-- 
Carles Pina i Estany		GPG id: 0x8CBDAE64
	http://pinux.info	Manresa - Barcelona

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Gwenview-general mailing list
Gwenview-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/gwenview-general
gwenview.osdexif.patch2 (text/plain, 8.5 KB)
Index: app/configfullscreenpage.ui
===================================================================
--- app/configfullscreenpage.ui	(revision 679406)
+++ app/configfullscreenpage.ui	(working copy)
@@ -113,6 +113,10 @@
 &lt;li&gt;%r: resolution&lt;/li&gt;
 &lt;li&gt;%n: current image position&lt;/li&gt;
 &lt;li&gt;%N: image count&lt;/li&gt;
+&lt;li&gt;%a: aperture&lt;/li&gt;
+&lt;li&gt;%t: exposure time&lt;/li&gt;
+&lt;li&gt;%i: iso&lt;/li&gt;
+&lt;li&gt;%l: focal length&lt;/li&gt;
 &lt;/ul&gt;
 &lt;/qt&gt;</string>
             </property>
Index: app/configdialog.cpp
===================================================================
--- app/configdialog.cpp	(revision 679406)
+++ app/configdialog.cpp	(working copy)
@@ -261,6 +261,10 @@
 	formatter.mImageSize=QSize(1600, 1200);
 	formatter.mPosition=4;
 	formatter.mCount=12;
+	formatter.mAperture="F2.8";
+	formatter.mExposureTime="1/60 s";
+	formatter.mIso="100";
+	formatter.mFocalLength="8.88 mm";
 	
 	QString txt=formatter.format( d->mFullScreenPage->kcfg_osdFormat->text() );
 	d->mFullScreenPage->mOSDPreviewLabel->setText(txt);
Index: app/mainwindow.cpp
===================================================================
--- app/mainwindow.cpp	(revision 679406)
+++ app/mainwindow.cpp	(working copy)
@@ -297,6 +297,10 @@
 	formatter.mImageSize=mDocument->image().size();
 	formatter.mPosition=mFileViewController->shownFilePosition()+1;
 	formatter.mCount=mFileViewController->fileCount();
+	formatter.mAperture=mDocument->aperture();
+	formatter.mExposureTime=mDocument->exposuretime();
+	formatter.mIso=mDocument->iso();
+	formatter.mFocalLength=mDocument->focallength();
 	
 	QString txt=formatter.format( FullScreenConfig::osdFormat() );
 	mFullScreenLabelAction->label()->setText(txt);
Index: gvcore/documentimpl.cpp
===================================================================
--- gvcore/documentimpl.cpp	(revision 679406)
+++ gvcore/documentimpl.cpp	(working copy)
@@ -57,6 +57,22 @@
 	mDocument->setFileSize(size);
 }
 
+QString DocumentImpl::aperture() const {
+	return QString::null;
+}
+
+QString DocumentImpl::exposuretime() const {
+	return QString::null;
+}
+
+QString DocumentImpl::iso() const {
+	return QString::null;
+}
+
+QString DocumentImpl::focallength() const {
+	return QString::null;
+}
+
 QString DocumentImpl::comment() const {
 	return QString::null;
 }
Index: gvcore/documentjpegloadedimpl.h
===================================================================
--- gvcore/documentjpegloadedimpl.h	(revision 679406)
+++ gvcore/documentjpegloadedimpl.h	(working copy)
@@ -42,7 +42,12 @@
 	QString comment() const;
 	void setComment(const QString&);
 	Document::CommentState commentState() const;
-	
+
+	QString aperture() const;
+	QString exposuretime() const;
+	QString iso() const;
+	QString focallength() const;
+
 	void transform(ImageUtils::Orientation);
 
 protected:
Index: gvcore/captionformatter.h
===================================================================
--- gvcore/captionformatter.h	(revision 679406)
+++ gvcore/captionformatter.h	(working copy)
@@ -41,6 +41,11 @@
 	QString mPath;
 	QString mFileName;
 	QString mComment;
+	QString mAperture;
+	QString mFocalLength;
+	QString mExposureTime;
+	QString mIso;
+
 	QSize mImageSize;
 	int mPosition;
 	int mCount;
Index: gvcore/documentimpl.h
===================================================================
--- gvcore/documentimpl.h	(revision 679406)
+++ gvcore/documentimpl.h	(working copy)
@@ -52,7 +52,12 @@
 	 * Convenience method to emit rectUpdated with the whole image rect
 	 */
 	void emitImageRectUpdated();
-	
+
+	virtual QString aperture() const;
+	virtual QString exposuretime() const;
+	virtual QString iso() const;
+	virtual QString focallength() const;
+
 	virtual QString comment() const;
 	virtual Document::CommentState commentState() const;
 	virtual void setComment(const QString&);
Index: gvcore/document.cpp
===================================================================
--- gvcore/document.cpp	(revision 679406)
+++ gvcore/document.cpp	(working copy)
@@ -283,6 +283,22 @@
 	return d->mImpl->comment();
 }
 
+QString Document::aperture() const {
+	return d->mImpl->aperture();
+}
+
+QString Document::exposuretime() const {
+       return d->mImpl->exposuretime();
+}
+
+QString Document::iso() const {
+	return d->mImpl->iso();
+}
+
+QString Document::focallength() const {
+	return d->mImpl->focallength();
+}
+
 void Document::setComment(const QString& comment) {
 	d->mImpl->setComment(comment);
 	d->mModified=true;
Index: gvcore/documentjpegloadedimpl.cpp
===================================================================
--- gvcore/documentjpegloadedimpl.cpp	(revision 679406)
+++ gvcore/documentjpegloadedimpl.cpp	(working copy)
@@ -119,6 +119,22 @@
 	d->mJPEGContent.setComment(comment);
 }
 
+QString DocumentJPEGLoadedImpl::aperture() const {
+	return d->mJPEGContent.aperture();
+}
+
+QString DocumentJPEGLoadedImpl::exposuretime() const {
+	return d->mJPEGContent.exposuretime();
+}
+
+QString DocumentJPEGLoadedImpl::iso() const {
+	return d->mJPEGContent.iso();
+}
+
+QString DocumentJPEGLoadedImpl::focallength() const {
+	return d->mJPEGContent.focallength();
+}
+
 Document::CommentState DocumentJPEGLoadedImpl::commentState() const {
 	return Document::WRITABLE;
 }
Index: gvcore/captionformatter.cpp
===================================================================
--- gvcore/captionformatter.cpp	(revision 679406)
+++ gvcore/captionformatter.cpp	(working copy)
@@ -45,6 +45,11 @@
 	str.replace("%r", resolution);
 	str.replace("%n", QString::number(mPosition));
 	str.replace("%N", QString::number(mCount));
+	str.replace("%a", mAperture);
+	str.replace("%t", mExposureTime);
+	str.replace("%i", mIso);
+	str.replace("%l", mFocalLength);
+
 	return str;
 }
 
Index: gvcore/document.h
===================================================================
--- gvcore/document.h	(revision 679406)
+++ gvcore/document.h	(working copy)
@@ -84,6 +84,10 @@
 	Document::CommentState commentState() const;
 	QString comment() const;
 	void setComment(const QString&);
+	QString aperture() const;
+	QString exposuretime() const;
+	QString iso() const;
+	QString focallength() const;
 
 	int duration() const;
 	
Index: imageutils/jpegcontent.cpp
===================================================================
--- imageutils/jpegcontent.cpp	(revision 679406)
+++ imageutils/jpegcontent.cpp	(working copy)
@@ -143,6 +143,11 @@
 	QByteArray mRawData;
 	QSize mSize;
 	QString mComment;
+	QString mAperture;
+	QString mExposureTime;
+	QString mFocalLength;
+	QString mIso;
+
 	bool mPendingTransformation;
 	QWMatrix mTransformMatrix;
 	Exiv2::ExifData mExifData;
@@ -264,6 +269,11 @@
 	d->mExifData = image->exifData();
 	d->mComment = QString::fromUtf8( image->comment().c_str() );
 
+	d->mAperture=aperture();
+	d->mExposureTime=exposuretime();
+	d->mIso=iso();
+	d->mFocalLength=iso();
+
 	// Adjust the size according to the orientation
 	switch (orientation()) {
 	case TRANSPOSE:
@@ -351,12 +361,47 @@
 	return d->mComment;
 }
 
+QString JPEGContent::getexifinformation(const QString exifkey) const {
+	QString ret;
+	
+	Exiv2::ExifKey key(exifkey.latin1());
+	Exiv2::ExifData::iterator it = d->mExifData.findKey(key);
 
+	if (it != d->mExifData.end()) {
+               std::ostringstream outputString;
+               outputString << *it;
+               ret=QString(outputString.str().c_str());
+	}
+	else {
+		ret="n/a";
+	}
+	return ret;
+}
+
+QString JPEGContent::aperture() const {
+	d->mAperture=getexifinformation("Exif.Photo.FNumber");
+	return d->mAperture;
+}
+
+QString JPEGContent::exposuretime() const {
+	d->mExposureTime=getexifinformation("Exif.Photo.ExposureTime");
+	return d->mExposureTime;
+}
+
+QString JPEGContent::iso() const {
+	d->mIso=getexifinformation("Exif.Photo.ISOSpeedRatings");
+	return d->mIso;
+}
+
+QString JPEGContent::focallength() const {
+	d->mFocalLength=getexifinformation("Exif.Photo.FocalLength");
+	return d->mFocalLength;
+}
+
 void JPEGContent::setComment(const QString& comment) {
 	d->mComment = comment;
 }
 
-
 static QWMatrix createRotMatrix(int angle) {
 	QWMatrix matrix;
 	matrix.rotate(angle);
Index: imageutils/jpegcontent.h
===================================================================
--- imageutils/jpegcontent.h	(revision 679406)
+++ imageutils/jpegcontent.h	(working copy)
@@ -51,7 +51,14 @@
 
 	QString comment() const;
 	void setComment(const QString&);
-	
+
+	QString aperture() const;
+	QString exposuretime() const;
+	QString iso() const;
+	QString focallength() const;
+
+	QString getexifinformation(const QString exifkey) const;
+
 	void transform(Orientation);
 
 	QImage thumbnail() const;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.