[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/gwenview
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2010-06-15 20:23:25
Message-ID: 20100615202325.B46F1AC8D4 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1138359 by gateau:
Do not delete EXIF data when applying a lossy image manipulation.
BUG:217792
BUG:225933
CCMAIL:thomas@monjalon.net
M +1 -3 lib/document/jpegdocumentloadedimpl.cpp
M +20 -0 lib/jpegcontent.cpp
M +4 -0 lib/jpegcontent.h
M +23 -0 tests/jpegcontenttest.cpp
M +1 -0 tests/jpegcontenttest.h
--- trunk/KDE/kdegraphics/gwenview/lib/document/jpegdocumentloadedimpl.cpp #1138358:1138359
@@ -72,10 +72,8 @@
void JpegDocumentLoadedImpl::setImage(const QImage& image) {
+ d->mJpegContent->setImage(image);
DocumentLoadedImpl::setImage(image);
- // mJpegContent is no longer relevant, so we'd better switch to a normal
- // loaded impl
- switchToImpl(new DocumentLoadedImpl(document(), QByteArray() /* rawData */, true /* quietInit */));
}
--- trunk/KDE/kdegraphics/gwenview/lib/jpegcontent.cpp #1138358:1138359
@@ -585,4 +585,24 @@
}
+void JpegContent::setImage(const QImage& image) {
+ QBuffer buffer;
+ QImageWriter writer(&buffer, "jpeg");
+ bool ok = writer.write(image);
+ if (!ok) {
+ kError() << writer.errorString();
+ d->mErrorString = writer.errorString();
+ return;
+ }
+ d->mRawData = buffer.data();
+ d->mSize = image.size();
+ d->mExifData["Exif.Photo.PixelXDimension"] = image.width();
+ d->mExifData["Exif.Photo.PixelYDimension"] = image.height();
+ resetOrientation();
+
+ d->mPendingTransformation = false;
+ d->mTransformMatrix = QMatrix();
+}
+
+
} // namespace
--- trunk/KDE/kdegraphics/gwenview/lib/jpegcontent.h #1138358:1138359
@@ -56,6 +56,10 @@
QImage thumbnail() const;
void setThumbnail(const QImage&);
+ // Recreate raw data to represent image
+ // Note: thumbnail must be updated separately
+ void setImage(const QImage& image);
+
bool load(const QString& file);
bool loadFromData(const QByteArray& rawData);
/**
--- trunk/KDE/kdegraphics/gwenview/tests/jpegcontenttest.cpp #1138358:1138359
@@ -273,3 +273,26 @@
QCOMPARE(content.rawData(), fileData);
}
+
+void JpegContentTest::testSetImage() {
+ Gwenview::JpegContent content;
+ bool result=content.load(pathForTestFile(ORIENT6_FILE));
+ QVERIFY(result);
+
+ QImage image = QImage(400, 300, QImage::Format_RGB32);
+ image.fill(Qt::red);
+
+ content.setImage(image);
+
+ result = content.save(TMP_FILE);
+ QVERIFY(result);
+
+ result = content.load(TMP_FILE);
+ QVERIFY(result);
+
+ QCOMPARE(content.size(), image.size());
+
+ QStringList ignoredKeys;
+ ignoredKeys << "Orientation";
+ compareMetaInfo(pathForTestFile(ORIENT6_FILE), pathForTestFile(TMP_FILE), ignoredKeys);
+}
--- trunk/KDE/kdegraphics/gwenview/tests/jpegcontenttest.h #1138358:1138359
@@ -37,6 +37,7 @@
void testMultipleRotations();
void testLoadTruncated();
void testRawData();
+ void testSetImage();
};
#endif // JPEGCONTENTTEST_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic