diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index da0c136fc..469388b1c 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -81,7 +81,9 @@ FramesData::FramesData(const Glib::ustring &fname) : lens("Unknown"), sampleFormat(IIOSF_UNKNOWN), isPixelShift(false), - isHDR(false) + isHDR(false), + w_(-1), + h_(-1) { make.clear(); model.clear(); @@ -374,6 +376,8 @@ FramesData::FramesData(const Glib::ustring &fname) : } } + meta.getDimensions(w_, h_); + // ----------------------- // Special file type detection (HDR, PixelShift) // ------------------------ @@ -773,3 +777,17 @@ void FramesData::fillBasicTags(Exiv2::ExifData &exif) const strftime(buf, 256, "%Y:%m:%d %H:%M:%S", &t); set_exif(exif, "Exif.Photo.DateTimeOriginal", buf); } + + +void FramesData::getDimensions(int &w, int &h) const +{ + w = w_; + h = h_; +} + + +void FramesData::setDimensions(int w, int h) +{ + w_ = w; + h_ = h; +} diff --git a/rtengine/imagedata.h b/rtengine/imagedata.h index 3a915c15d..88c0ec48d 100644 --- a/rtengine/imagedata.h +++ b/rtengine/imagedata.h @@ -57,6 +57,8 @@ private: IIOSampleFormat sampleFormat; bool isPixelShift; bool isHDR; + int w_; + int h_; public: explicit FramesData(const Glib::ustring& fname); @@ -84,8 +86,11 @@ public: std::string getOrientation() const override; Glib::ustring getFileName() const override; int getRating() const override; + void getDimensions(int &w, int &h) const override; void fillBasicTags(Exiv2::ExifData &exif) const; + + void setDimensions(int w, int h); }; } diff --git a/rtengine/metadata.cc b/rtengine/metadata.cc index 049233cc6..85fcf79ff 100644 --- a/rtengine/metadata.cc +++ b/rtengine/metadata.cc @@ -448,6 +448,29 @@ void Exiv2Metadata::setExifKeys(const std::vector *keys) } +void Exiv2Metadata::getDimensions(int &w, int &h) const +{ + if (image_) { + if (dynamic_cast(image_.get())) { + auto &exif = image_->exifData(); + auto itw = exif.findKey(Exiv2::ExifKey("Exif.Image.ImageWidth")); + auto ith = exif.findKey(Exiv2::ExifKey("Exif.Image.ImageLength")); + if (itw != exif.end() && ith != exif.end()) { + w = itw->toLong(); + h = ith->toLong(); + } else { + w = h = -1; + } + } else { + w = image_->pixelWidth(); + h = image_->pixelHeight(); + } + } else { + w = h = -1; + } +} + + Glib::ustring Exiv2Metadata::xmpSidecarPath(const Glib::ustring &path) { Glib::ustring fn = path; diff --git a/rtengine/metadata.h b/rtengine/metadata.h index 0f9f7919d..d9b195ed5 100644 --- a/rtengine/metadata.h +++ b/rtengine/metadata.h @@ -58,6 +58,8 @@ public: void setExifKeys(const std::vector *keys); + void getDimensions(int &w, int &h) const; + static Glib::ustring xmpSidecarPath(const Glib::ustring& path); static Exiv2::XmpData getXmpSidecar(const Glib::ustring& path); diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 8f8a71553..e583a27a5 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -690,7 +690,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima { MyMutex::MyLock lock(getImageMutex); - tran = defTransform (tran); + tran = defTransform(ri, tran); // compute channel multipliers double r, g, b; @@ -1009,8 +1009,41 @@ void RawImageSource::convertColorSpace(Imagefloat* image, const ColorManagementP void RawImageSource::getFullSize (int& w, int& h, int tr) { + computeFullSize(ri, tr, w, h); - tr = defTransform (tr); + // tr = defTransform(ri, tr); + + // if (fuji) { + // w = ri->get_FujiWidth() * 2 + 1; + // h = (H - ri->get_FujiWidth()) * 2 + 1; + // } else if (d1x) { + // w = W; + // h = 2 * H; + // } else { + // w = W; + // h = H; + // } + + // if ((tr & TR_ROT) == TR_R90 || (tr & TR_ROT) == TR_R270) { + // int tmp = w; + // w = h; + // h = tmp; + // } + + // w -= 2 * border; + // h -= 2 * border; +} + + +void RawImageSource::computeFullSize(const RawImage *ri, int tr, int &w, int &h) +{ + tr = defTransform(ri, tr); + + const int W = ri->get_width(); + const int H = ri->get_height(); + const bool fuji = ri->get_FujiWidth() != 0; + const bool d1x = !ri->get_model().compare("D1X"); + const int border = (ri->getSensorType() == ST_BAYER ? 4 : (ri->getSensorType() == ST_FUJI_XTRANS ? 7 : 0)); if (fuji) { w = ri->get_FujiWidth() * 2 + 1; @@ -1253,6 +1286,11 @@ int RawImageSource::load (const Glib::ustring &fname, bool firstFrameOnly) // Load complete Exif information idata = new FramesData(fname); // TODO: std::unique_ptr<> idata->setDCRawFrameCount (numFrames); + { + int ww, hh; + getFullSize(ww, hh); + idata->setDimensions(ww, hh); + } green(W, H); red(W, H); @@ -2718,7 +2756,7 @@ void RawImageSource::scaleColors(int winx, int winy, int winw, int winh, const R //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -int RawImageSource::defTransform (int tran) +int RawImageSource::defTransform(const RawImage *ri, int tran) { int deg = ri->get_rotateDegree(); @@ -4466,7 +4504,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double Probably (sure) there are improvement to do... I have create a table temperature with temp and white point with 118 values between 2000K and 12000K we can obviously change these values, more...with different steps - I have create a table for tint (green)with 134 values between 0.4 to 4. + I have create a table for tint (green)with 134 values between 0.4 to 4. I have create or recuparate and transformed 201 spectral colors from Colorchecker24, others color and my 468 colors target, or from web flowers, etc. with a step of 5nm, I think it is large enough. I think this value of 201 is now complete: I tested correlation with 60, 90, 100, 120, 155...better student increase with number of color, but now it seems stabilized Of course we can increase this number :) @@ -4519,7 +4557,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double itcwb_precis : 5 by default - can be set to 3 or 9 - 3 best sampling but more time...9 "old" settings - but low differences in times with 3 instead of 9 about twice time 160ms instead of 80ms for a big raw file */ // BENCHFUN - + TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix("sRGB"); const float wp[3][3] = { {static_cast(wprof[0][0]), static_cast(wprof[0][1]), static_cast(wprof[0][2])}, @@ -5064,7 +5102,7 @@ void RawImageSource::ItcWB(bool extra, double &tempref, double &greenref, double } estimchrom /= sizcu4; - if (settings->verbose) { + if (settings->verbose) { printf("estimchrom=%f\n", estimchrom); } if (settings->itcwb_sort) { //sort in ascending with chroma values @@ -5366,7 +5404,7 @@ void RawImageSource::getrgbloc(int begx, int begy, int yEn, int xEn, int cx, int if (settings->itcwb_precis == 5) { precision = 5; } else if (settings->itcwb_precis < 5) { - precision = 3; + precision = 3; } else if (settings->itcwb_precis > 5) { precision = 9; } @@ -5628,11 +5666,11 @@ void RawImageSource::getAutoWBMultipliersitc(double & tempref, double & greenref if (settings->itcwb_precis == 5) { precision = 5; } else if (settings->itcwb_precis < 5) { - precision = 3; + precision = 3; } else if (settings->itcwb_precis > 5) { precision = 9; } - + const int bfw = W / precision + ((W % precision) > 0 ? 1 : 0);// 5 arbitrary value can be change to 3 or 9 ; const int bfh = H / precision + ((H % precision) > 0 ? 1 : 0); WBauto(tempref, greenref, redloc, greenloc, blueloc, bfw, bfh, avg_rm, avg_gm, avg_bm, tempitc, greenitc, studgood, twotimes, wbpar, begx, begy, yEn, xEn, cx, cy, cmp, raw); @@ -6093,7 +6131,7 @@ ColorTemp RawImageSource::getSpotWB (std::vector &red, std::vectorinit(); + + RawImageSource::computeFullSize(ri, TR_NONE, tpp->full_width, tpp->full_height); + delete ri; return tpp; } @@ -1025,7 +1028,9 @@ Thumbnail::Thumbnail () : gammaCorrected (false), colorMatrix{}, scaleGain (1.0), - isRaw (true) + isRaw (true), + full_width(-1), + full_height(-1) { } @@ -1236,7 +1241,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT ipf.dehaze(baseImg, params.dehaze); ipf.ToneMapFattal02(baseImg, params.fattal, 3, 0, nullptr, 0, 0, 0); - + // perform transform int origFW; int origFH; @@ -2125,7 +2130,7 @@ bool Thumbnail::readData (const Glib::ustring& fname) colorMatrix[i][j] = cm[ix++]; } } - + if (keyFile.has_key ("LiveThumbData", "ScaleGain")) { scaleGain = keyFile.get_double ("LiveThumbData", "ScaleGain"); } diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index 33bfec21c..455f4fadb 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -82,6 +82,8 @@ class Thumbnail public: bool isRaw; + int full_width; + int full_height; ~Thumbnail (); Thumbnail (); @@ -94,7 +96,7 @@ public: void getDimensions (int& w, int& h, double& scaleFac); static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode = false, bool forHistogramMatching = false); - static Thumbnail* loadFromRaw (const Glib::ustring& fname, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, bool forHistogramMatching = false); + static Thumbnail* loadFromRaw (const Glib::ustring& fname, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, bool forHistogramMatching=false); static Thumbnail* loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode = false); void getCamWB (double& temp, double& green); diff --git a/rtgui/cacheimagedata.cc b/rtgui/cacheimagedata.cc index 97007751c..365b8f1b7 100644 --- a/rtgui/cacheimagedata.cc +++ b/rtgui/cacheimagedata.cc @@ -56,7 +56,9 @@ CacheImageData::CacheImageData() : greenAWBMul(-1.0), blueAWBMul(-1.0), rotate(0), - thumbImgType(0) + thumbImgType(0), + width(-1), + height(-1) { } @@ -208,6 +210,12 @@ int CacheImageData::load (const Glib::ustring& fname) if (keyFile.has_key ("FileInfo", "SampleFormat")) { sampleFormat = (rtengine::IIO_Sample_Format)keyFile.get_integer ("FileInfo", "SampleFormat"); } + if (keyFile.has_key("FileInfo", "Width")) { + width = keyFile.get_integer("FileInfo", "Width"); + } + if (keyFile.has_key("FileInfo", "Height")) { + height = keyFile.get_integer("FileInfo", "Height"); + } } if (format == FT_Raw && keyFile.has_group ("ExtraRawInfo")) { @@ -298,6 +306,8 @@ int CacheImageData::save (const Glib::ustring& fname) keyFile.set_string ("FileInfo", "Filetype", filetype); keyFile.set_integer ("FileInfo", "FrameCount", frameCount); keyFile.set_integer ("FileInfo", "SampleFormat", sampleFormat); + keyFile.set_integer("FileInfo", "Width", width); + keyFile.set_integer("FileInfo", "Height", height); if (format == FT_Raw) { keyFile.set_integer ("ExtraRawInfo", "ThumbImageType", thumbImgType); diff --git a/rtgui/cacheimagedata.h b/rtgui/cacheimagedata.h index 2b4d5f471..cb02b9169 100644 --- a/rtgui/cacheimagedata.h +++ b/rtgui/cacheimagedata.h @@ -80,6 +80,9 @@ public: QUICK_THUMBNAIL = 1 // was the thumbnail generated from embedded jpeg }; + int width; + int height; + CacheImageData (); int load (const Glib::ustring& fname); @@ -110,4 +113,9 @@ public: bool getHDR() const override { return isHDR; } std::string getImageType() const override { return isPixelShift ? "PS" : isHDR ? "HDR" : "STD"; } rtengine::IIOSampleFormat getSampleFormat() const override { return sampleFormat; } + void getDimensions(int &w, int &h) const override + { + w = width; + h = height; + } }; diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 350538626..62556fb68 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1357,8 +1357,13 @@ void EditorPanel::info_toggled () escapeHtmlChars (Glib::path_get_dirname (openThm->getFileName())) + G_DIR_SEPARATOR_S, escapeHtmlChars (Glib::path_get_basename (openThm->getFileName())) ); - int ww = ipc->getFullWidth(); - int hh = ipc->getFullHeight(); + int ww = -1, hh = -1; + idata->getDimensions(ww, hh); + if (ww <= 0) { + ww = ipc->getFullWidth(); + hh = ipc->getFullHeight(); + } + //megapixels infoString = Glib::ustring::compose ("%1\n%2 MP (%3x%4)", infoString, diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index dfc1bfeb7..2ee17ba27 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -241,6 +241,10 @@ void Thumbnail::_generateThumbnailImage () cfs.format = FT_Raw; cfs.thumbImgType = quick ? CacheImageData::QUICK_THUMBNAIL : CacheImageData::FULL_THUMBNAIL; infoFromImage (fname); + if (!quick) { + cfs.width = tpp->full_width; + cfs.height = tpp->full_height; + } } } @@ -893,6 +897,8 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname) cfs.filetype = ""; } + idata->getDimensions(cfs.width, cfs.height); + delete idata; return deg; }