Merge branch 'dev' into spot-removal-tool
This commit is contained in:
@@ -20,49 +20,96 @@
|
||||
#include "imagedimensions.h"
|
||||
#include "rtengine.h"
|
||||
|
||||
void ImageDimensions::transform (const PreviewProps & pp, int tran, int &sx1, int &sy1, int &sx2, int &sy2)
|
||||
PreviewProps::PreviewProps(int _x, int _y, int _width, int _height, int _skip) :
|
||||
x(_x),
|
||||
y(_y),
|
||||
width(_width),
|
||||
height(_height),
|
||||
skip(_skip)
|
||||
{
|
||||
}
|
||||
|
||||
int sw = width, sh = height;
|
||||
int PreviewProps::getX() const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int PreviewProps::getY() const
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
int PreviewProps::getWidth() const
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
int PreviewProps::getHeight() const
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
int PreviewProps::getSkip() const
|
||||
{
|
||||
return skip;
|
||||
}
|
||||
|
||||
void PreviewProps::set (int x, int y, int w, int h, int skip) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = w;
|
||||
this->height = h;
|
||||
this->skip = skip;
|
||||
}
|
||||
|
||||
ImageDimensions::ImageDimensions() :
|
||||
width(-1),
|
||||
height(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void ImageDimensions::transform(const PreviewProps& pp, int tran, int& sx1, int& sy1, int& sx2, int& sy2) const
|
||||
{
|
||||
int sw = width;
|
||||
int sh = height;
|
||||
|
||||
if ((tran & TR_ROT) == TR_R90 || (tran & TR_ROT) == TR_R270) {
|
||||
sw = height;
|
||||
sh = width;
|
||||
std::swap(sw, sh);
|
||||
}
|
||||
|
||||
int ppx = pp.x, ppy = pp.y;
|
||||
int ppx = pp.getX();
|
||||
int ppy = pp.getY();
|
||||
|
||||
if (tran & TR_HFLIP) {
|
||||
ppx = sw - pp.x - pp.w;
|
||||
ppx = sw - pp.getX() - pp.getWidth();
|
||||
}
|
||||
|
||||
if (tran & TR_VFLIP) {
|
||||
ppy = sh - pp.y - pp.h;
|
||||
ppy = sh - pp.getY() - pp.getHeight();
|
||||
}
|
||||
|
||||
sx1 = ppx;
|
||||
sy1 = ppy;
|
||||
sx2 = ppx + pp.w;
|
||||
sy2 = ppy + pp.h;
|
||||
sx2 = ppx + pp.getWidth();
|
||||
sy2 = ppy + pp.getHeight();
|
||||
|
||||
if ((tran & TR_ROT) == TR_R180) {
|
||||
sx1 = width - ppx - pp.w;
|
||||
sy1 = height - ppy - pp.h;
|
||||
sx2 = sx1 + pp.w;
|
||||
sy2 = sy1 + pp.h;
|
||||
sx1 = width - ppx - pp.getWidth();
|
||||
sy1 = height - ppy - pp.getHeight();
|
||||
sx2 = sx1 + pp.getWidth();
|
||||
sy2 = sy1 + pp.getHeight();
|
||||
} else if ((tran & TR_ROT) == TR_R90) {
|
||||
sx1 = ppy;
|
||||
sy1 = height - ppx - pp.w;
|
||||
sx2 = sx1 + pp.h;
|
||||
sy2 = sy1 + pp.w;
|
||||
sy1 = height - ppx - pp.getWidth();
|
||||
sx2 = sx1 + pp.getHeight();
|
||||
sy2 = sy1 + pp.getWidth();
|
||||
} else if ((tran & TR_ROT) == TR_R270) {
|
||||
sx1 = width - ppy - pp.h;
|
||||
sx1 = width - ppy - pp.getHeight();
|
||||
sy1 = ppx;
|
||||
sx2 = sx1 + pp.h;
|
||||
sy2 = sy1 + pp.w;
|
||||
sx2 = sx1 + pp.getHeight();
|
||||
sy2 = sy1 + pp.getWidth();
|
||||
}
|
||||
|
||||
//printf ("ppx %d ppy %d ppw %d pph %d s: %d %d %d %d\n",pp.x, pp.y,pp.w,pp.h,sx1,sy1,sx2,sy2);
|
||||
if (sx1 < 0) {
|
||||
sx1 = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user