Changeset View
Changeset View
Standalone View
Standalone View
lib/jpegcontent.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | // Exiv2 | 44 | // Exiv2 | ||
45 | #include <exiv2/exiv2.hpp> | 45 | #include <exiv2/exiv2.hpp> | ||
46 | 46 | | |||
47 | // Local | 47 | // Local | ||
48 | #include "jpegerrormanager.h" | 48 | #include "jpegerrormanager.h" | ||
49 | #include "iodevicejpegsourcemanager.h" | 49 | #include "iodevicejpegsourcemanager.h" | ||
50 | #include "exiv2imageloader.h" | 50 | #include "exiv2imageloader.h" | ||
51 | #include "gwenviewconfig.h" | 51 | #include "gwenviewconfig.h" | ||
52 | #include "imageutils.h" | ||||
52 | 53 | | |||
53 | namespace Gwenview | 54 | namespace Gwenview | ||
54 | { | 55 | { | ||
55 | 56 | | |||
56 | const int INMEM_DST_DELTA = 4096; | 57 | const int INMEM_DST_DELTA = 4096; | ||
57 | 58 | | |||
58 | //----------------------------------------------- | 59 | //----------------------------------------------- | ||
59 | // | 60 | // | ||
▲ Show 20 Lines • Show All 507 Lines • ▼ Show 20 Line(s) | 566 | { | |||
567 | if (!d->mExifData.empty()) { | 568 | if (!d->mExifData.empty()) { | ||
568 | #if(EXIV2_TEST_VERSION(0,17,91)) | 569 | #if(EXIV2_TEST_VERSION(0,17,91)) | ||
569 | Exiv2::ExifThumbC thumb(d->mExifData); | 570 | Exiv2::ExifThumbC thumb(d->mExifData); | ||
570 | Exiv2::DataBuf thumbnail = thumb.copy(); | 571 | Exiv2::DataBuf thumbnail = thumb.copy(); | ||
571 | #else | 572 | #else | ||
572 | Exiv2::DataBuf thumbnail = d->mExifData.copyThumbnail(); | 573 | Exiv2::DataBuf thumbnail = d->mExifData.copyThumbnail(); | ||
573 | #endif | 574 | #endif | ||
574 | image.loadFromData(thumbnail.pData_, thumbnail.size_); | 575 | image.loadFromData(thumbnail.pData_, thumbnail.size_); | ||
576 | | ||||
577 | Exiv2::ExifKey key("Exif.Canon.ThumbnailImageValidArea"); | ||||
578 | Exiv2::ExifData::iterator it = d->mExifData.findKey(key); | ||||
579 | | ||||
580 | // ensure ThumbnailImageValidArea actually specifies a rectangle, i.e. there must be 4 coordinates | ||||
ngraham: What does 4 mean here? | |||||
ThumbnailImageValidArea specifies a rectangle: Top left, bottom right. That makes four coordinates. tommo: ThumbnailImageValidArea specifies a rectangle: Top left, bottom right. That makes four… | |||||
Gotcha, thanks! Might make sense to put that in a comment so it's more obvious. ngraham: Gotcha, thanks! Might make sense to put that in a comment so it's more obvious. | |||||
581 | if (it != d->mExifData.end() && it->count() == 4) { | ||||
582 | QRect validArea(QPoint(it->toLong(0), it->toLong(2)), QPoint(it->toLong(1), it->toLong(3))); | ||||
583 | image = image.copy(validArea); | ||||
584 | } | ||||
585 | | ||||
ngraham: In general we prefer to use descriptive variable names | |||||
tommo: Sure. Do you insist in this case? | |||||
ngraham: Yes please. :) | |||||
Pls., which name would you consider to be descriptive in this particular case? I could have also used the result of orientation() as a temporary, IMO this would be descriptive enough. I just wanted to bind it to a variable to avoid calling it twice. tommo: Pls., which name would you consider to be descriptive in this particular case? I could have… | |||||
Orientation orientation = orientation(); Which looks somewhat ridiculous in the initialization, but it's much more readable later: ngraham: `Orientation orientation = orientation();`
Which looks somewhat ridiculous in the… | |||||
This won't compile. You can't use orientation as function in this context, since it's a variable. tommo: This won't compile. You can't use `orientation` as function in this context, since it's a… | |||||
586 | Orientation o = orientation(); | ||||
587 | if (GwenviewConfig::applyExifOrientation() && o != NORMAL && o != NOT_AVAILABLE) { | ||||
588 | image = image.transformed(ImageUtils::transformMatrix(o)); | ||||
589 | } | ||||
575 | } | 590 | } | ||
576 | return image; | 591 | return image; | ||
577 | } | 592 | } | ||
578 | 593 | | |||
579 | void JpegContent::setThumbnail(const QImage& thumbnail) | 594 | void JpegContent::setThumbnail(const QImage& thumbnail) | ||
580 | { | 595 | { | ||
581 | if (d->mExifData.empty()) { | 596 | if (d->mExifData.empty()) { | ||
582 | return; | 597 | return; | ||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |
What does 4 mean here?