diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 74c9f91c2..ea96f9608 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -515,10 +515,6 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, break; } - if (pLCPMap && params->lensProf.useDist) { - pLCPMap->correctDistortion(x_d, y_d, w2, h2); - } - x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; if (params->perspective.camera_defish) { @@ -532,6 +528,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, y_d *= factor; } + if (pLCPMap && params->lensProf.useDist) { + pLCPMap->correctDistortion(x_d, y_d, w2, h2); + } + // rotate double Dx = x_d * cost - y_d * sint; double Dy = x_d * sint + y_d * cost; @@ -1253,10 +1253,6 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I break; } - if (enableLCPDist) { - pLCPMap->correctDistortion(x_d, y_d, w2, h2); - } - x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; if (params->perspective.camera_defish) { @@ -1264,12 +1260,16 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I y_d /= f; const double r = std::sqrt(x_d * x_d + y_d * y_d); - const double factor = f * std::atan(r)/r; + const double factor = f * std::atan(r) / r; x_d *= factor; y_d *= factor; } + if (enableLCPDist) { + pLCPMap->correctDistortion(x_d, y_d, w2, h2); + } + // rotate const double Dxc = x_d * cost - y_d * sint; const double Dyc = x_d * sint + y_d * cost;