Merge branch 'master' into gtk3

This commit is contained in:
Hombre
2016-12-13 23:00:47 +01:00
3 changed files with 54 additions and 15 deletions

View File

@@ -274,37 +274,37 @@ public:
{ {
return profile_data; return profile_data;
} }
IMFILE *get_file() IMFILE *get_file() const
{ {
return ifp; return ifp;
} }
bool is_supportedThumb() const ; bool is_supportedThumb() const ;
bool is_jpegThumb() const ; bool is_jpegThumb() const ;
bool is_ppmThumb() const ; bool is_ppmThumb() const ;
int get_thumbOffset() int get_thumbOffset() const
{ {
return int(thumb_offset); return int(thumb_offset);
} }
int get_thumbWidth() int get_thumbWidth() const
{ {
return int(thumb_width); return int(thumb_width);
} }
int get_thumbHeight() int get_thumbHeight() const
{ {
return int(thumb_height); return int(thumb_height);
} }
int get_thumbBPS() int get_thumbBPS() const
{ {
return thumb_load_raw ? 16 : 8; return thumb_load_raw ? 16 : 8;
} }
bool get_thumbSwap() const; bool get_thumbSwap() const;
unsigned get_thumbLength() unsigned get_thumbLength() const
{ {
return thumb_length; return thumb_length;
} }
bool zeroIsBad() bool zeroIsBad() const
{ {
return zero_is_bad == 1 ? true : false; return zero_is_bad == 1;
} }
public: public:

View File

@@ -41,6 +41,25 @@
#include "StopWatch.h" #include "StopWatch.h"
namespace
{
bool checkRawImageThumb(const rtengine::RawImage& raw_image)
{
if (!raw_image.is_supportedThumb()) {
return false;
}
const std::size_t length =
fdata(raw_image.get_thumbOffset(), raw_image.get_file())[1] != 0xD8 && raw_image.is_ppmThumb()
? raw_image.get_thumbWidth() * raw_image.get_thumbHeight() * (raw_image.get_thumbBPS() / 8) * 3
: raw_image.get_thumbLength();
return raw_image.get_thumbOffset() + length < raw_image.get_file()->size;
}
}
extern Options options; extern Options options;
namespace rtengine namespace rtengine
@@ -175,8 +194,8 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL
int err = 1; int err = 1;
// see if it is something we support // See if it is something we support
if ( ri->is_supportedThumb() && ri->get_thumbOffset() < ri->get_file()->size ) { if (checkRawImageThumb(*ri)) {
const char* data((const char*)fdata(ri->get_thumbOffset(), ri->get_file())); const char* data((const char*)fdata(ri->get_thumbOffset(), ri->get_file()));
if ( (unsigned char)data[1] == 0xd8 ) { if ( (unsigned char)data[1] == 0xd8 ) {
@@ -491,6 +510,17 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
tmph = high; tmph = high;
} }
const bool rotate_90 =
rotate
&& (
ri->get_rotateDegree() == 90
|| ri->get_rotateDegree() == 270
);
if (rotate_90) {
std::swap(tmpw, tmph);
}
if (fixwh == 1) { // fix height, scale width if (fixwh == 1) { // fix height, scale width
w = tmpw * h / tmph; w = tmpw * h / tmph;
} else { } else {
@@ -501,8 +531,11 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
delete tpp->thumbImg; delete tpp->thumbImg;
} }
tpp->thumbImg = nullptr; if (rotate_90) {
tpp->thumbImg = resizeTo<Image16>(h, w, TI_Bilinear, tmpImg);
} else {
tpp->thumbImg = resizeTo<Image16>(w, h, TI_Bilinear, tmpImg); tpp->thumbImg = resizeTo<Image16>(w, h, TI_Bilinear, tmpImg);
}
delete tmpImg; delete tmpImg;

View File

@@ -2110,10 +2110,15 @@ void CropWindow::updateHoveredPicker (rtengine::Coord *imgPos)
} }
LockableColorPicker::Validity validity = checkValidity (hoveredPicker, cropPos); LockableColorPicker::Validity validity = checkValidity (hoveredPicker, cropPos);
hoveredPicker->setValidity (validity); hoveredPicker->setValidity (validity);
{
MyMutex::MyLock lock(cropHandler.cimg);
if (validity == LockableColorPicker::Validity::INSIDE) { if (validity == LockableColorPicker::Validity::INSIDE) {
cropHandler.colorPick(cropPos, r, g, b, rpreview, gpreview, bpreview, hoveredPicker->getSize()); cropHandler.colorPick(cropPos, r, g, b, rpreview, gpreview, bpreview, hoveredPicker->getSize());
hoveredPicker->setRGB (r, g, b, rpreview, gpreview, bpreview); hoveredPicker->setRGB (r, g, b, rpreview, gpreview, bpreview);
} }
}
} }
void CropWindow::changeZoom (int zoom, bool notify, int centerx, int centery) void CropWindow::changeZoom (int zoom, bool notify, int centerx, int centery)
{ {
@@ -2477,6 +2482,7 @@ void CropWindow::drawObservedFrame (Cairo::RefPtr<Cairo::Context> cr, int rw, in
void CropWindow::cropImageUpdated () void CropWindow::cropImageUpdated ()
{ {
MyMutex::MyLock lock(cropHandler.cimg);
for (auto colorPicker : colorPickers) { for (auto colorPicker : colorPickers) {
Coord imgPos, cropPos; Coord imgPos, cropPos;