Fixed cropping not working in file browser mode

see issue 609
This commit is contained in:
Oliver Duis
2011-07-19 19:01:18 +02:00
parent fdb490c49f
commit 0a67e308bf
4 changed files with 37 additions and 22 deletions

View File

@@ -790,23 +790,11 @@ int Thumbnail::getImageWidth (const procparams::ProcParams& params, int rheight)
return rwidth; return rwidth;
} }
void Thumbnail::getFinalSize (const rtengine::procparams::ProcParams& params, int& fullw, int& fullh) { void Thumbnail::getDimensions (int& w, int& h, double& scaleFac) {
if (thumbImg) {
// WARNING: When downscaled, the ratio have loosed a lot of precision, so we can't get back the exact initial dimensions w=thumbImg->width; h=thumbImg->height; scaleFac=scale;
double fw = thumbImg->width*scale; } else {
double fh = thumbImg->height*scale; w=0; h=0; scale=1;
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);
} }
} }

View File

@@ -73,7 +73,7 @@ namespace rtengine {
IImage8* processImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale); IImage8* processImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale);
IImage8* quickProcessImage (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); 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* 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); static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, int &w, int &h, int fixwh, bool rotate);

View File

@@ -36,7 +36,7 @@ using namespace rtengine::procparams;
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), : fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL),
pparamsValid(false), needsReProcessing(true),imageLoading(false), lastImg(NULL), pparamsValid(false), needsReProcessing(true),imageLoading(false), lastImg(NULL),
initial_(false) { initial_(false), lastW(0), lastH(0), lastScale(0) {
cfs.load (getCacheFileName ("data")+".txt"); cfs.load (getCacheFileName ("data")+".txt");
loadProcParams (); loadProcParams ();
@@ -392,6 +392,31 @@ void Thumbnail::getThumbnailSize (int &w, int &h) {
if (w==0) w = tw * h / th; 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) { rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale) {
Glib::Mutex::Lock lock(mutex); 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); image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
} }
//_saveThumbnail(); tpp->getDimensions(lastW,lastH,lastScale);
delete tpp; delete tpp;
tpp = 0; tpp = 0;
return image; 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); rtengine::IImage8* image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
tpp->getDimensions(lastW,lastH,lastScale);
//_saveThumbnail();
delete tpp; delete tpp;
tpp = 0; tpp = 0;
return image; return image;

View File

@@ -54,6 +54,7 @@ class Thumbnail {
unsigned char* lastImg; unsigned char* lastImg;
int lastW; int lastW;
int lastH; int lastH;
double lastScale;
// exif & date/time strings // exif & date/time strings
Glib::ustring exifString; Glib::ustring exifString;
@@ -102,7 +103,7 @@ class Thumbnail {
rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale); rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
rtengine::IImage8* upgradeThumbImage (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 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& getExifString ();
const Glib::ustring& getDateTimeString (); const Glib::ustring& getDateTimeString ();