Fixed cropping not working in file browser mode
see issue 609
This commit is contained in:
@@ -790,23 +790,11 @@ int Thumbnail::getImageWidth (const procparams::ProcParams& params, int rheight)
|
||||
return rwidth;
|
||||
}
|
||||
|
||||
void Thumbnail::getFinalSize (const rtengine::procparams::ProcParams& params, int& fullw, int& fullh) {
|
||||
|
||||
// WARNING: When downscaled, the ratio have loosed a lot of precision, so we can't get back the exact initial dimensions
|
||||
double fw = thumbImg->width*scale;
|
||||
double fh = thumbImg->height*scale;
|
||||
|
||||
if (params.coarse.rotate==90 || params.coarse.rotate==270) {
|
||||
fh = thumbImg->width*scale;
|
||||
fw = thumbImg->height*scale;
|
||||
}
|
||||
if (!params.resize.enabled) {
|
||||
fullw = fw;
|
||||
fullh = fh;
|
||||
}
|
||||
else {
|
||||
fullw = (int)((double)fw+0.5);
|
||||
fullh = (int)((double)fh+0.5);
|
||||
void Thumbnail::getDimensions (int& w, int& h, double& scaleFac) {
|
||||
if (thumbImg) {
|
||||
w=thumbImg->width; h=thumbImg->height; scaleFac=scale;
|
||||
} else {
|
||||
w=0; h=0; scale=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,7 @@ namespace rtengine {
|
||||
IImage8* processImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale);
|
||||
IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale);
|
||||
int getImageWidth (const procparams::ProcParams& pparams, int rheight);
|
||||
void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h);
|
||||
void getDimensions (int& w, int& h, double& scaleFac);
|
||||
|
||||
static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, rtengine::RawMetaDataLocation& rml, int &w, int &h, int fixwh, bool rotate);
|
||||
static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, bool rotate);
|
||||
|
@@ -36,7 +36,7 @@ using namespace rtengine::procparams;
|
||||
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
|
||||
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL),
|
||||
pparamsValid(false), needsReProcessing(true),imageLoading(false), lastImg(NULL),
|
||||
initial_(false) {
|
||||
initial_(false), lastW(0), lastH(0), lastScale(0) {
|
||||
|
||||
cfs.load (getCacheFileName ("data")+".txt");
|
||||
loadProcParams ();
|
||||
@@ -392,6 +392,31 @@ void Thumbnail::getThumbnailSize (int &w, int &h) {
|
||||
if (w==0) w = tw * h / th;
|
||||
}
|
||||
|
||||
void Thumbnail::getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) {
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
#endif
|
||||
|
||||
// WARNING: When downscaled, the ratio have loosed a lot of precision, so we can't get back the exact initial dimensions
|
||||
double fw = lastW*lastScale;
|
||||
double fh = lastH*lastScale;
|
||||
|
||||
if (pparams.coarse.rotate==90 || pparams.coarse.rotate==270) {
|
||||
fh = lastW*lastScale;
|
||||
fw = lastH*lastScale;
|
||||
}
|
||||
if (!pparams.resize.enabled) {
|
||||
w = fw;
|
||||
h = fh;
|
||||
}
|
||||
else {
|
||||
w = (int)(fw+0.5);
|
||||
h = (int)(fh+0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale) {
|
||||
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
@@ -418,7 +443,8 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro
|
||||
image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
|
||||
}
|
||||
|
||||
//_saveThumbnail();
|
||||
tpp->getDimensions(lastW,lastH,lastScale);
|
||||
|
||||
delete tpp;
|
||||
tpp = 0;
|
||||
return image;
|
||||
@@ -440,8 +466,8 @@ rtengine::IImage8* Thumbnail::upgradeThumbImage (const rtengine::procparams::Pro
|
||||
}
|
||||
|
||||
rtengine::IImage8* image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
|
||||
tpp->getDimensions(lastW,lastH,lastScale);
|
||||
|
||||
//_saveThumbnail();
|
||||
delete tpp;
|
||||
tpp = 0;
|
||||
return image;
|
||||
|
@@ -54,6 +54,7 @@ class Thumbnail {
|
||||
unsigned char* lastImg;
|
||||
int lastW;
|
||||
int lastH;
|
||||
double lastScale;
|
||||
|
||||
// exif & date/time strings
|
||||
Glib::ustring exifString;
|
||||
@@ -102,7 +103,7 @@ class Thumbnail {
|
||||
rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
|
||||
rtengine::IImage8* upgradeThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
|
||||
void getThumbnailSize (int &w, int &h);
|
||||
void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) { if (tpp) tpp->getFinalSize (pparams, w, h); }
|
||||
void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h);
|
||||
|
||||
const Glib::ustring& getExifString ();
|
||||
const Glib::ustring& getDateTimeString ();
|
||||
|
Reference in New Issue
Block a user