refactored code for extracting image dimensions from metadata

(cherry picked from commit 0ece9c5bfad09bc9052238d83fa696ef39effaaa)
This commit is contained in:
Alberto Griggio
2020-12-02 02:03:00 -08:00
committed by Lawrence Lee
parent 0102fca563
commit 92befa7e81
13 changed files with 146 additions and 21 deletions

View File

@@ -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);

View File

@@ -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;
}
};

View File

@@ -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<span size=\"small\">%2 MP (%3x%4)</span>",
infoString,

View File

@@ -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;
}