Commit bd9602f5 authored by Ivan Yossi's avatar Ivan Yossi 👌

Avoid rounding coords for hue and value on bilinear sampleData

BUG:290383
parent 3b453bbc
......@@ -44,24 +44,33 @@ void KisRandomSubAccessor::sampledOldRawData(quint8* dst)
{
const quint8* pixels[4];
qint16 weights[4];
int x = (int)floor(m_currentPoint.x());
int y = (int)floor(m_currentPoint.y());
qreal x = m_currentPoint.x();
qreal y = m_currentPoint.y();
int xz = qRound(x);
int yz = qRound(y);
double hsub = m_currentPoint.x() - x;
if (hsub < 0.0) hsub = 1.0 + hsub;
if (hsub < 0.0) {
hsub = 1.0 + hsub;
}
double vsub = m_currentPoint.y() - y;
if (vsub < 0.0) vsub = 1.0 + vsub;
if (vsub < 0.0) {
vsub = 1.0 + vsub;
}
weights[0] = qRound((1.0 - hsub) * (1.0 - vsub) * 255);
m_randomAccessor->moveTo(x, y);
m_randomAccessor->moveTo(xz, yz);
pixels[0] = m_randomAccessor->oldRawData();
weights[1] = qRound((1.0 - vsub) * hsub * 255);
m_randomAccessor->moveTo(x + 1, y);
m_randomAccessor->moveTo(xz + 1, yz);
pixels[1] = m_randomAccessor->oldRawData();
weights[2] = qRound(vsub * (1.0 - hsub) * 255);
m_randomAccessor->moveTo(x, y + 1);
m_randomAccessor->moveTo(xz, yz + 1);
pixels[2] = m_randomAccessor->oldRawData();
weights[3] = qRound(hsub * vsub * 255);
m_randomAccessor->moveTo(x + 1, y + 1);
m_randomAccessor->moveTo(xz + 1, yz + 1);
pixels[3] = m_randomAccessor->oldRawData();
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
}
......@@ -70,23 +79,31 @@ void KisRandomSubAccessor::sampledRawData(quint8* dst)
{
const quint8* pixels[4];
qint16 weights[4];
int x = (int)floor(m_currentPoint.x());
int y = (int)floor(m_currentPoint.y());
qreal x = m_currentPoint.x();
qreal y = m_currentPoint.y();
int xz = qRound(x);
int yz = qRound(y);
double hsub = m_currentPoint.x() - x;
if (hsub < 0.0) hsub = 1.0 + hsub;
if (hsub < 0.0) {
hsub = 1.0 + hsub;
}
double vsub = m_currentPoint.y() - y;
if (vsub < 0.0) vsub = 1.0 + vsub;
if (vsub < 0.0) {
vsub = 1.0 + vsub;
}
weights[0] = qRound((1.0 - hsub) * (1.0 - vsub) * 255);
m_randomAccessor->moveTo(x, y);
m_randomAccessor->moveTo(xz, yz);
pixels[0] = m_randomAccessor->rawDataConst();
weights[1] = qRound((1.0 - vsub) * hsub * 255);
m_randomAccessor->moveTo(x + 1, y);
m_randomAccessor->moveTo(xz + 1, yz);
pixels[1] = m_randomAccessor->rawDataConst();
weights[2] = qRound(vsub * (1.0 - hsub) * 255);
m_randomAccessor->moveTo(x, y + 1);
m_randomAccessor->moveTo(xz, yz + 1);
pixels[2] = m_randomAccessor->rawDataConst();
weights[3] = qRound(hsub * vsub * 255);
m_randomAccessor->moveTo(x + 1, y + 1);
m_randomAccessor->moveTo(xz + 1, yz + 1);
pixels[3] = m_randomAccessor->rawDataConst();
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
}
......@@ -47,12 +47,13 @@ public:
*/
void sampledRawData(quint8* dst);
inline void moveTo(double x, double y) {
inline void moveTo(qreal x, qreal y) {
m_currentPoint.setX(x); m_currentPoint.setY(y);
}
inline void moveTo(const QPointF& p) {
m_currentPoint = p;
}
private:
KisPaintDeviceSP m_device;
QPointF m_currentPoint;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment