Commit 0555fa38 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fixed an offset bug when creating a thumbnail of a paint device with offset

The 'translation' seems to be some historical artifact and obviously
not needed anymore.

BUG:321536
parent fa2dbe98
......@@ -714,14 +714,9 @@ KisPaintDeviceSP KisPaintDevice::createThumbnailDevice(qint32 w, qint32 h, QRect
int srcWidth, srcHeight;
int srcX0, srcY0;
QRect e;
if (!rect.isValid())
e = extent();
else
e = rect.translated(-m_d->x, -m_d->y);
QRect e = rect.isValid() ? rect : extent();
e.getRect(&srcX0, &srcY0, &srcWidth, &srcHeight);
if (w > srcWidth) {
w = srcWidth;
h = qint32(double(srcWidth) / w * h);
......
......@@ -390,6 +390,24 @@ void KisPaintDeviceTest::testThumbnail()
}
}
void KisPaintDeviceTest::testThumbnailDeviceWithOffset()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->convertFromQImage(image, 0);
dev->setX(10);
dev->setY(10);
QImage thumb = dev->createThumbnail(640,441,QRect(10,10,640,441));
image.save("oring.png");
thumb.save("thumb.png");
QPoint pt;
QVERIFY(TestUtil::compareQImages(pt, thumb, image));
}
void KisPaintDeviceTest::testCaching()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
......
......@@ -33,6 +33,7 @@ private slots:
void testClear();
void testCrop();
void testThumbnail();
void testThumbnailDeviceWithOffset();
void testCaching();
void testRegion();
void testPixel();
......
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