From d570459f1e82f6a5ec9090bfb8c9931d36ef4809 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 5 Feb 2017 19:03:34 +0100 Subject: [PATCH] Fixed bug in last commit when image was rotated --- rtengine/imagesource.h | 2 +- rtengine/rawimagesource.cc | 17 ++++++++++++++++- rtengine/rawimagesource.h | 2 +- rtengine/stdimagesource.h | 2 +- rtgui/cropwindow.cc | 2 +- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index e8740edf4..8998fa848 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -160,7 +160,7 @@ public: { return this; } - virtual void getRawValues(int x, int y, int &R, int &G, int &B) = 0; + virtual void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) = 0; }; } #endif diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 00ce631b2..4fce68bdf 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -5460,10 +5460,25 @@ void RawImageSource::init () } } -void RawImageSource::getRawValues(int x, int y, int &R, int &G, int &B) +void RawImageSource::getRawValues(int x, int y, int rotate, int &R, int &G, int &B) { int xnew = x + border; int ynew = y + border; + rotate += ri->get_rotateDegree(); + rotate %= 360; + if (rotate == 90) { + std::swap(xnew,ynew); + ynew = H - 1 - ynew; + } else if (rotate == 180) { + xnew = W - 1 - xnew; + ynew = H - 1 - ynew; + } else if (rotate == 270) { + std::swap(xnew,ynew); + ynew = H - 1 - ynew; + xnew = W - 1 - xnew; + ynew = H - 1 - ynew; + } + int c = FC(ynew,xnew); int val = round(rawData[ynew][xnew] / scale_mul[c]); if(c == 0) { diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 99363d9e0..948efb355 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -264,7 +264,7 @@ protected: void pixelshift(int winx, int winy, int winw, int winh, const RAWParams::BayerSensor &bayerParams, unsigned int frame, const std::string &model, float rawWpCorrection); void hflip (Imagefloat* im); void vflip (Imagefloat* im); - void getRawValues(int x, int y, int &R, int &G, int &B); + void getRawValues(int x, int y, int rotate, int &R, int &G, int &B); }; } diff --git a/rtengine/stdimagesource.h b/rtengine/stdimagesource.h index 775bd484d..1dbddf325 100644 --- a/rtengine/stdimagesource.h +++ b/rtengine/stdimagesource.h @@ -97,7 +97,7 @@ public: } void setCurrentFrame(unsigned int frameNum) {} - void getRawValues(int x, int y, int &R, int &G, int &B) { R = G = B = 0;} + void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) { R = G = B = 0;} }; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index c021886fb..a6e93c511 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -1045,7 +1045,7 @@ void CropWindow::pointerMoved (int bstate, int x, int y) ipc->getParams(¶ms); if(params.raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::none]) { ImageSource *isrc = static_cast(ipc->getInitialImage()); - isrc->getRawValues(mx, my, rval, gval, bval); + isrc->getRawValues(mx, my, params.coarse.rotate, rval, gval, bval); } } // pmlistener->pointerMoved (true, cropHandler.colorParams.working, mx, my, pix[0], pix[1], pix[2]);