From f023a90170a80ccb2af304c5b5aadf2a2660b62d Mon Sep 17 00:00:00 2001 From: Alexander Brock Date: Sat, 11 Feb 2023 23:51:32 +0100 Subject: [PATCH] Add camera_defish to PerspCorrection::read/write --- rtengine/iptransform.cc | 8 +++++--- rtgui/perspective.cc | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 301d4b929..615eaa124 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -521,7 +521,7 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; - if (true || params->perspective.camera_defish) { + if (params->perspective.camera_defish) { double const focal_source = params->perspective.camera_focal_length * maxRadius*1351.0/5206.416/6.5; double focal_dst = focal_source; x_d /= focal_dst; @@ -1261,7 +1261,7 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; - if (true || params->perspective.camera_defish) { + if (params->perspective.camera_defish) { double const focal_source = params->perspective.camera_focal_length * maxRadius*1351.0/5206.416/6.5; double focal_dst = focal_source; x_d /= focal_dst; @@ -1513,7 +1513,9 @@ bool ImProcFunctions::needsPerspective () const params->perspective.projection_shift_horiz || params->perspective.projection_shift_vert || params->perspective.projection_yaw || - params->perspective.camera_defish) ); + params->perspective.camera_defish || + params->perspective.camera_scale > 1.0 + 1e-6 || + params->perspective.camera_scale < 1.0 - 1e-6 )); } bool ImProcFunctions::needsGradient () const diff --git a/rtgui/perspective.cc b/rtgui/perspective.cc index cddcb2da8..060a62b04 100644 --- a/rtgui/perspective.cc +++ b/rtgui/perspective.cc @@ -346,6 +346,7 @@ void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited) vert->setValue (pp->perspective.vertical); setFocalLengthValue (pp, metadata); camera_pitch->setValue (pp->perspective.camera_pitch); + camera_defish->set_active(pp->perspective.camera_defish); camera_scale->setValue (pp->perspective.camera_scale); camera_roll->setValue (pp->perspective.camera_roll); camera_shift_horiz->setValue (pp->perspective.camera_shift_horiz); @@ -399,6 +400,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited) pp->perspective.camera_focal_length = camera_focal_length->getValue (); } pp->perspective.camera_pitch = camera_pitch->getValue (); + pp->perspective.camera_defish = camera_defish->get_active (); pp->perspective.camera_scale = camera_scale->getValue (); pp->perspective.camera_roll = camera_roll->getValue (); pp->perspective.camera_shift_horiz = camera_shift_horiz->getValue (); @@ -422,6 +424,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited) } if (pedited) { + pedited->perspective.camera_defish = true; pedited->perspective.method = method->get_active_row_number() != 2; pedited->perspective.horizontal = horiz->getEditedState (); pedited->perspective.vertical = vert->getEditedState ();