diff --git a/rtdata/languages/default b/rtdata/languages/default index dcd3de182..5839deba5 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -741,6 +741,7 @@ HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION;Line noise filter direction HISTORY_MSG_PREPROCESS_PDAFLINESFILTER;PDAF lines filter HISTORY_MSG_PRSHARPEN_CONTRAST;PRS - Contrast threshold HISTORY_MSG_RAW_BORDER;Raw border +HISTORY_MSG_RESIZE_ALLOW_UPSCALING;Resize - Allow upscaling HISTORY_MSG_SHARPENING_CONTRAST;Sharpening - Contrast threshold HISTORY_MSG_SOFTLIGHT_ENABLED;Soft light HISTORY_MSG_SOFTLIGHT_STRENGTH;Soft light - Strength @@ -1835,6 +1836,7 @@ TP_RAW_SENSOR_XTRANS_DMETHOD_TOOLTIP;3-pass gives best results (recommended for TP_RAW_SENSOR_XTRANS_LABEL;Sensor with X-Trans Matrix TP_RAW_VNG4;VNG4 TP_RESIZE_APPLIESTO;Applies to: +TP_RESIZE_ALLOW_UPSCALING;Allow Upscaling TP_RESIZE_CROPPEDAREA;Cropped Area TP_RESIZE_FITBOX;Bounding Box TP_RESIZE_FULLIMAGE;Full Image diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index f756f425b..4218c88ac 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1917,7 +1917,8 @@ ResizeParams::ResizeParams() : method("Lanczos"), dataspec(3), width(900), - height(900) + height(900), + allowUpscaling(false) { } @@ -1930,7 +1931,8 @@ bool ResizeParams::operator ==(const ResizeParams& other) const && method == other.method && dataspec == other.dataspec && width == other.width - && height == other.height; + && height == other.height + && allowUpscaling == other.allowUpscaling; } bool ResizeParams::operator !=(const ResizeParams& other) const @@ -3142,6 +3144,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->resize.dataspec, "Resize", "DataSpecified", resize.dataspec, keyFile); saveToKeyfile(!pedited || pedited->resize.width, "Resize", "Width", resize.width, keyFile); saveToKeyfile(!pedited || pedited->resize.height, "Resize", "Height", resize.height, keyFile); + saveToKeyfile(!pedited || pedited->resize.allowUpscaling, "Resize", "AllowUpscaling", resize.allowUpscaling, keyFile); // Post resize sharpening saveToKeyfile(!pedited || pedited->prsharpening.enabled, "PostResizeSharpening", "Enabled", prsharpening.enabled, keyFile); @@ -4149,6 +4152,14 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Resize", "DataSpecified", pedited, resize.dataspec, pedited->resize.dataspec); assignFromKeyfile(keyFile, "Resize", "Width", pedited, resize.width, pedited->resize.width); assignFromKeyfile(keyFile, "Resize", "Height", pedited, resize.height, pedited->resize.height); + if (ppVersion >= 339) { + assignFromKeyfile(keyFile, "Resize", "AllowUpscaling", pedited, resize.allowUpscaling, pedited->resize.allowUpscaling); + } else { + resize.allowUpscaling = true; + if (pedited) { + pedited->resize.allowUpscaling = true; + } + } } if (keyFile.has_group ("PostResizeSharpening")) { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 717473996..b6fd1befd 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1000,6 +1000,7 @@ struct ResizeParams { int dataspec; int width; int height; + bool allowUpscaling; ResizeParams(); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 14f215f07..f825e34a9 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1192,7 +1192,8 @@ private: } if (labResize) { // resize lab data - if(labView->W != imw || labView->H != imh) { + if ((labView->W != imw || labView->H != imh) && + (params.resize.allowUpscaling || (labView->W >= imw && labView->H >= imh))) { // resize image tmplab = new LabImage (imw, imh); ipf.Lanczos (labView, tmplab, tmpScale); @@ -1265,7 +1266,8 @@ private: pl->setProgress (0.70); } - if (tmpScale != 1.0 && params.resize.method == "Nearest") { // resize rgb data (gamma applied) + if (tmpScale != 1.0 && params.resize.method == "Nearest" && + (params.resize.allowUpscaling || (readyImg->getWidth() >= imw && readyImg->getHeight() >= imh))) { // resize rgb data (gamma applied) Imagefloat* tempImage = new Imagefloat (imw, imh); ipf.resize (readyImg, tempImage, tmpScale); delete readyImg; @@ -1383,7 +1385,7 @@ private: assert (params.resize.enabled); // resize image - { + if (params.resize.allowUpscaling || (imw <= fw && imh <= fh)) { std::unique_ptr resized (new LabImage (imw, imh)); ipf.Lanczos (tmplab.get(), resized.get(), scale_factor); tmplab = std::move (resized); diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 0118a3c5c..ad7af7c8d 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -1212,6 +1212,7 @@ void FileCatalog::developRequested (std::vector tbe, bool fas params.resize.appliesTo = options.fastexport_resize_appliesTo; params.resize.method = options.fastexport_resize_method; params.resize.dataspec = options.fastexport_resize_dataspec; + params.resize.allowUpscaling = false; } rtengine::ProcessingJob* pjob = rtengine::ProcessingJob::create (fbe->filename, th->getType() == FT_Raw, params, fastmode && options.fastexport_use_fast_pipeline); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 567deb6f0..ad9df6896 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -377,6 +377,7 @@ void ParamsEdited::set (bool v) resize.width = v; resize.height = v; resize.enabled = v; + resize.allowUpscaling = v; icm.input = v; icm.toneCurve = v; icm.applyLookTable = v; @@ -931,6 +932,7 @@ void ParamsEdited::initFrom (const std::vector resize.width = resize.width && p.resize.width == other.resize.width; resize.height = resize.height && p.resize.height == other.resize.height; resize.enabled = resize.enabled && p.resize.enabled == other.resize.enabled; + resize.allowUpscaling = resize.allowUpscaling && p.resize.allowUpscaling == other.resize.allowUpscaling; icm.input = icm.input && p.icm.input == other.icm.input; icm.toneCurve = icm.toneCurve && p.icm.toneCurve == other.icm.toneCurve; icm.applyLookTable = icm.applyLookTable && p.icm.applyLookTable == other.icm.applyLookTable; @@ -2406,6 +2408,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten toEdit.resize.enabled = mods.resize.enabled; } + if (resize.allowUpscaling) { + toEdit.resize.allowUpscaling = mods.resize.allowUpscaling; + } + if (icm.input) { toEdit.icm.input = mods.icm.input; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 7a4387028..959a1ff39 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -569,6 +569,7 @@ public: bool width; bool height; bool enabled; + bool allowUpscaling; }; class ColorManagementParamsEdited diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index ac12e97d8..7c6a291c0 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -1,11 +1,13 @@ #pragma once // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 338 +#define PPVERSION 339 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes + 339 2018-07-04 + added allowUpscaling to ResizeParams 338 2018-06-15 increased precision for the channel mixer 337 2018-06-13 diff --git a/rtgui/resize.cc b/rtgui/resize.cc index 0491065d2..d72b606ad 100644 --- a/rtgui/resize.cc +++ b/rtgui/resize.cc @@ -18,12 +18,15 @@ */ #include "resize.h" #include "guiutils.h" +#include "eventmapper.h" using namespace rtengine; using namespace rtengine::procparams; Resize::Resize () : FoldableToolPanel(this, "resize", M("TP_RESIZE_LABEL"), false, true), maxw(100000), maxh(100000) { + auto m = ProcEventMapper::getInstance(); + EvResizeAllowUpscaling = m->newEvent(RESIZE, "HISTORY_MSG_RESIZE_ALLOW_UPSCALING"); cropw = 0; croph = 0; @@ -88,6 +91,11 @@ Resize::Resize () : FoldableToolPanel(this, "resize", M("TP_RESIZE_LABEL"), fals sbox->pack_start (*hbox); sizeBox->pack_start (*sbox, Gtk::PACK_SHRINK, 0); + + allowUpscaling = Gtk::manage(new Gtk::CheckButton(M("TP_RESIZE_ALLOW_UPSCALING"))); + sizeBox->pack_start(*allowUpscaling); + allowUpscaling->signal_toggled().connect(sigc::mem_fun(*this, &Resize::allowUpscalingChanged)); + sizeBox->show_all (); sizeBox->reference (); @@ -137,6 +145,7 @@ void Resize::read (const ProcParams* pp, const ParamsEdited* pedited) h->set_value (pp->resize.height); setEnabled (pp->resize.enabled); spec->set_active (pp->resize.dataspec); + allowUpscaling->set_active(pp->resize.allowUpscaling); updateGUI(); appliesTo->set_active (0); @@ -175,6 +184,7 @@ void Resize::read (const ProcParams* pp, const ParamsEdited* pedited) spec->set_active (4); } + allowUpscaling->set_inconsistent(!pedited->resize.allowUpscaling); set_inconsistent (multiImage && !pedited->resize.enabled); } @@ -214,6 +224,8 @@ void Resize::write (ProcParams* pp, ParamsEdited* pedited) pp->resize.enabled = getEnabled (); //printf(" L:%d H:%d\n", pp->resize.width, pp->resize.height); + pp->resize.allowUpscaling = allowUpscaling->get_active(); + if (pedited) { pedited->resize.enabled = !get_inconsistent(); pedited->resize.dataspec = dataSpec != MAX_SCALE; @@ -229,6 +241,7 @@ void Resize::write (ProcParams* pp, ParamsEdited* pedited) pedited->resize.width = false; pedited->resize.height = false; } + pedited->resize.allowUpscaling = !allowUpscaling->get_inconsistent(); } } @@ -620,6 +633,22 @@ void Resize::enabledChanged () } } + +void Resize::allowUpscalingChanged() +{ + + if (listener) { + if (allowUpscaling->get_inconsistent()) { + listener->panelChanged(EvResizeAllowUpscaling, M("GENERAL_UNCHANGED")); + } else if (allowUpscaling->get_active()) { + listener->panelChanged(EvResizeAllowUpscaling, M("GENERAL_ENABLED")); + } else { + listener->panelChanged(EvResizeAllowUpscaling, M("GENERAL_DISABLED")); + } + } +} + + void Resize::setAdjusterBehavior (bool scaleadd) { diff --git a/rtgui/resize.h b/rtgui/resize.h index f179b65f9..0534e292a 100644 --- a/rtgui/resize.h +++ b/rtgui/resize.h @@ -66,7 +66,9 @@ private: int getComputedHeight (); void notifyBBox (); void updateGUI (); + void allowUpscalingChanged(); + rtengine::ProcEvent EvResizeAllowUpscaling; Adjuster* scale; Gtk::VBox* sizeBox; MyComboBoxText* appliesTo; @@ -74,6 +76,7 @@ private: MyComboBoxText* spec; MySpinButton* w; MySpinButton* h; + Gtk::CheckButton *allowUpscaling; int maxw, maxh; int cropw, croph; sigc::connection sconn, aconn, wconn, hconn;