本文整理汇总了C++中KisFixedPaintDeviceSP::convertToQImage方法的典型用法代码示例。如果您正苦于以下问题:C++ KisFixedPaintDeviceSP::convertToQImage方法的具体用法?C++ KisFixedPaintDeviceSP::convertToQImage怎么用?C++ KisFixedPaintDeviceSP::convertToQImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisFixedPaintDeviceSP
的用法示例。
在下文中一共展示了KisFixedPaintDeviceSP::convertToQImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMaskGeneration
void KisAutoBrushTest::testMaskGeneration()
{
KisCircleMaskGenerator* circle = new KisCircleMaskGenerator(10, 1.0, 1.0, 1.0, 2, false);
KisBrushSP a = new KisAutoBrush(circle, 0.0, 0.0);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintInformation info(QPointF(100.0, 100.0), 0.5);
// check masking an existing paint device
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs);
fdev->setRect(QRect(0, 0, 100, 100));
fdev->initialize();
cs->setOpacity(fdev->data(), OPACITY_OPAQUE_U8, 100 * 100);
QPoint errpoint;
QImage result(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_1.png");
QImage image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_1.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
// Check creating a mask dab with a single color
fdev = new KisFixedPaintDevice(cs);
a->mask(fdev, KoColor(Qt::black, cs), KisDabShape(), info);
result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_3.png");
image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_3.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
// Check creating a mask dab with a color taken from a paint device
KoColor red(Qt::red, cs);
cs->setOpacity(red.data(), quint8(128), 1);
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->fill(0, 0, 100, 100, red.data());
fdev = new KisFixedPaintDevice(cs);
a->mask(fdev, dev, KisDabShape(), info);
result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_4.png");
image = fdev->convertToQImage(0);
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_autobrush_test_4.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}
示例2: testFill
void KisFixedPaintDeviceTest::testFill()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
quint8* red = new quint8[cs->pixelSize()];
memcpy(red, KoColor(Qt::red, cs).data(), cs->pixelSize());
cs->setOpacity(red, quint8(128), 1);
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->fill(0, 0, 100, 100, red);
QVERIFY(dev->bounds() == QRect(0, 0, 100, 100));
QVERIFY(cs->opacityU8(dev->data()) == 128);
QVERIFY(memcmp(dev->data(), red, cs->pixelSize()) == 0);
//Compare fill will normal paint device
dev = new KisFixedPaintDevice(cs);
dev->setRect(QRect(0, 0, 150, 150));
dev->initialize();
dev->fill(50, 50, 50, 50, red);
KisPaintDeviceSP dev2 = new KisPaintDevice(cs);
dev2->fill(50, 50, 50, 50, red);
QImage image = dev->convertToQImage(0);
QImage checkImage = dev2->convertToQImage(0, 0, 0, 150, 150);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, checkImage)) {
image.save("kis_fixed_paint_device_filled_result.png");
checkImage.save("kis_fixed_paint_device_filled_result_expected.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
delete[] red;
}
示例3: testCopyMasking
//#define SAVE_OUTPUT_IMAGES
void KisAutoBrushTest::testCopyMasking()
{
int w = 64;
int h = 64;
int x = 0;
int y = 0;
QRect rc(x, y, w, h);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KoColor black(Qt::black, cs);
KoColor red(Qt::red, cs);
KisPaintDeviceSP tempDev = new KisPaintDevice(cs);
tempDev->fill(0, 0, w, h, red.data());
#ifdef SAVE_OUTPUT_IMAGES
tempDev->convertToQImage(0).save("tempDev.png");
#endif
KisCircleMaskGenerator * mask = new KisCircleMaskGenerator(w, 1.0, 0.5, 0.5, 2, true);
KisAutoBrush brush(mask, 0, 0);
KisFixedPaintDeviceSP maskDab = new KisFixedPaintDevice(cs);
brush.mask(maskDab, black, KisDabShape(), KisPaintInformation());
maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
#ifdef SAVE_OUTPUT_IMAGES
maskDab->convertToQImage(0, 0, 0, 64, 64).save("maskDab.png");
#endif
QCOMPARE(tempDev->exactBounds(), rc);
QCOMPARE(maskDab->bounds(), rc);
KisFixedPaintDeviceSP dev2fixed = new KisFixedPaintDevice(cs);
dev2fixed->setRect(rc);
dev2fixed->initialize();
tempDev->readBytes(dev2fixed->data(), rc);
dev2fixed->convertToQImage(0).save("converted-tempDev-to-fixed.png");
KisPaintDeviceSP dev = new KisPaintDevice(cs);
KisPainter painter(dev);
painter.setCompositeOp(COMPOSITE_COPY);
painter.bltFixedWithFixedSelection(x, y, dev2fixed, maskDab, 0, 0, 0, 0, rc.width(), rc.height());
//painter.bitBltWithFixedSelection(x, y, tempDev, maskDab, 0, 0, 0, 0, rc.width(), rc.height());
#ifdef SAVE_OUTPUT_IMAGES
dev->convertToQImage(0).save("final.png");
#endif
}
示例4: createBrushPreview
QImage KisAutoBrush::createBrushPreview()
{
srand(0);
srand48(0);
int width = maskWidth(1.0, 0.0, 0.0, 0.0, KisPaintInformation());
int height = maskHeight(1.0, 0.0, 0.0, 0.0, KisPaintInformation());
KisPaintInformation info(QPointF(width * 0.5, height * 0.5), 0.5, 0, 0, 0, 0);
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice( KoColorSpaceRegistry::instance()->rgb8() );
fdev->setRect(QRect(0, 0, width, height));
fdev->initialize();
mask(fdev,KoColor(Qt::black, fdev->colorSpace()),1.0, 1.0, 0.0, info);
return fdev->convertToQImage(0);
}
示例5: testRoundtripQImageConversion
void KisFixedPaintDeviceTest::testRoundtripQImageConversion()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->convertFromQImage(image, 0);
QImage result = dev->convertToQImage(0, 0, 0, 640, 441);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, result)) {
image.save("kis_fixed_paint_device_test_test_roundtrip_qimage.png");
result.save("kis_fixed_paint_device_test_test_roundtrip_result.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}
示例6: testBltFixed
void KisFixedPaintDeviceTest::testBltFixed()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs);
fdev->convertFromQImage(image, 0);
// Without opacity
KisPaintDeviceSP dev = new KisPaintDevice(cs);
KisPainter gc(dev);
gc.bltFixed(QPoint(0, 0), fdev, image.rect());
QImage result = dev->convertToQImage(0, 0, 0, 640, 441);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, result, 1)) {
fdev->convertToQImage(0).save("kis_fixed_paint_device_test_test_blt_fixed_expected.png");
result.save("kis_fixed_paint_device_test_test_blt_fixed_result.png");
QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}