本文整理汇总了C++中KisPaintDeviceSP::setY方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::setY方法的具体用法?C++ KisPaintDeviceSP::setY怎么用?C++ KisPaintDeviceSP::setY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::setY方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRoundTrip
void KisClipboardTest::testRoundTrip()
{
const KoColorSpace *cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
KisPaintDeviceSP newDev;
QPoint errorPoint;
QRect fillRect(10,10,20,20);
KoColor pixel(Qt::red, cs);
dev->fill(fillRect.x(),fillRect.y(),
fillRect.width(), fillRect.height(), pixel.data());
QCOMPARE(dev->exactBounds(), fillRect);
KisClipboard::instance()->setClip(dev, QPoint());
newDev = KisClipboard::instance()->clip(QPoint());
QCOMPARE(newDev->exactBounds().size(), fillRect.size());
newDev->setX(dev->x());
newDev->setY(dev->y());
QVERIFY(TestUtil::comparePaintDevices(errorPoint, dev, newDev));
QPoint offset(100,100);
dev->setX(offset.x());
dev->setY(offset.y());
QCOMPARE(dev->exactBounds(), fillRect.translated(offset));
KisClipboard::instance()->setClip(dev, QPoint());
newDev = KisClipboard::instance()->clip(QPoint());
QCOMPARE(newDev->exactBounds().size(), fillRect.translated(offset).size());
newDev->setX(dev->x());
newDev->setY(dev->y());
QVERIFY(TestUtil::comparePaintDevices(errorPoint, dev, newDev));
}
示例2: doStrokeCallback
void MoveSelectionStrokeStrategy::doStrokeCallback(KisStrokeJobData *data)
{
MoveStrokeStrategy::Data *d = dynamic_cast<MoveStrokeStrategy::Data*>(data);
if (d) {
KisIndirectPaintingSupport *indirect =
static_cast<KisIndirectPaintingSupport*>(m_paintLayer.data());
KisPaintDeviceSP movedDevice = indirect->temporaryTarget();
QRegion dirtyRegion = movedDevice->region();
QPoint currentDeviceOffset(movedDevice->x(), movedDevice->y());
QPoint newDeviceOffset(m_initialDeviceOffset + d->offset);
dirtyRegion |= dirtyRegion.translated(newDeviceOffset - currentDeviceOffset);
movedDevice->setX(newDeviceOffset.x());
movedDevice->setY(newDeviceOffset.y());
m_finalOffset = d->offset;
m_paintLayer->setDirty(dirtyRegion);
} else {
KisStrokeStrategyUndoCommandBased::doStrokeCallback(data);
}
}
示例3: yShear
KisPaintDeviceSP KisShearVisitor::yShear(KisPaintDeviceSP src, qreal shearY, KoUpdater *progress)
{
int start = progress->progress();
KisPaintDeviceSP dst = KisPaintDeviceSP(new KisPaintDevice(src->colorSpace()));
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
dst->setX(src->x());
dst->setY(src->y());
QRect r = src->exactBounds();
qreal displacement;
qint32 displacementInt;
qreal weight;
for (qint32 x = r.left(); x <= r.right(); x++) {
//calculate displacement
displacement = x * shearY;
displacementInt = (qint32)(floor(displacement));
weight = displacement - displacementInt;
qint16 pixelWeights[2];
pixelWeights[0] = static_cast<quint8>(weight * 255 + 0.5);
pixelWeights[1] = 255 - pixelWeights[0];
KisVLineConstIteratorPixel srcIt = src->createVLineIterator(x, r.y(), r.height() + 1);
KisVLineIteratorPixel leftSrcIt = src->createVLineIterator(x, r.y() - 1, r.height() + 1);
KisVLineIteratorPixel dstIt = dst->createVLineIterator(x, r.y() + displacementInt, r.height() + 1);
while (!srcIt.isDone()) {
const quint8 *pixelPtrs[2];
pixelPtrs[0] = leftSrcIt.rawData();
pixelPtrs[1] = srcIt.rawData();
mixOp->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
++srcIt;
++leftSrcIt;
++dstIt;
}
progress->setProgress(start + x);
}
return dst;
}
示例4: xShear
KisPaintDeviceSP KisShearVisitor::xShear(KisPaintDeviceSP src, qreal shearX, KoUpdater *progress)
{
KisPaintDeviceSP dst = KisPaintDeviceSP(new KisPaintDevice(src->colorSpace()));
dst->setX(src->x());
dst->setY(src->y());
QRect r = src->exactBounds();
qreal displacement;
qint32 displacementInt;
qreal weight;
KoMixColorsOp * mixOp = src->colorSpace()->mixColorsOp();
for (qint32 y = r.top(); y <= r.bottom(); y++) {
//calculate displacement
displacement = -y * shearX;
displacementInt = (qint32)(floor(displacement));
weight = displacement - displacementInt;
qint16 pixelWeights[2];
pixelWeights[0] = static_cast<quint8>(weight * 255 + 0.5);
pixelWeights[1] = 255 - pixelWeights[0];
KisHLineConstIteratorPixel srcIt = src->createHLineIterator(r.x(), y, r.width() + 1);
KisHLineConstIteratorPixel leftSrcIt = src->createHLineIterator(r.x() - 1, y, r.width() + 1);
KisHLineIteratorPixel dstIt = dst->createHLineIterator(r.x() + displacementInt, y, r.width() + 1);
while (!srcIt.isDone()) {
const quint8 *pixelPtrs[2];
pixelPtrs[0] = leftSrcIt.rawData();
pixelPtrs[1] = srcIt.rawData();
mixOp->mixColors(pixelPtrs, pixelWeights, 2, dstIt.rawData());
++srcIt;
++leftSrcIt;
++dstIt;
}
progress->setProgress(y);
}
return dst;
}
示例5: testTranslate
void KisPaintDeviceTest::testTranslate()
{
QRect fillRect(0,0,64,64);
quint8 fillPixel[4]={255,255,255,255};
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP device = new KisPaintDevice(cs);
device->fill(fillRect.left(), fillRect.top(),
fillRect.width(), fillRect.height(),fillPixel);
device->setX(-10);
device->setY(10);
QCOMPARE(device->exactBounds(), QRect(-10,10,64,64));
QCOMPARE(device->extent(), QRect(-10,10,64,64));
}
示例6: run
void KisPasteActionFactory::run(KisView2 *view)
{
KisImageWSP image = view->image();
//figure out where to position the clip
// XXX: Fix this for internal points & zoom! (BSAR)
QWidget * w = view->canvas();
QPoint center = QPoint(w->width() / 2, w->height() / 2);
QPoint bottomright = QPoint(w->width(), w->height());
if (bottomright.x() > image->width())
center.setX(image->width() / 2);
if (bottomright.y() > image->height())
center.setY(image->height() / 2);
const KoCanvasBase* canvasBase = view->canvasBase();
const KoViewConverter* viewConverter = view->canvasBase()->viewConverter();
KisPaintDeviceSP clip = KisClipboard::instance()->clip(
QPoint(
viewConverter->viewToDocumentX(canvasBase->canvasController()->canvasOffsetX()) + center.x(),
viewConverter->viewToDocumentY(canvasBase->canvasController()->canvasOffsetY()) + center.y()));
if (clip) {
// Pasted layer content could be outside image bounds and invisible, if that is the case move content into the bounds
QRect exactBounds = clip->exactBounds();
if (!exactBounds.isEmpty() && !exactBounds.intersects(image->bounds())) {
clip->setX(clip->x() - exactBounds.x());
clip->setY(clip->y() - exactBounds.y());
}
KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
KisNodeSP aboveNode = view->activeLayer();
KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();
KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
KisProcessingApplicator *ap = beginAction(view, cmd->text());
ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
endAction(ap, KisOperationConfiguration(id()).toXML());
} else {
#ifdef __GNUC__
#warning "Add saving of XML data for Paste of shapes"
#endif
view->canvasBase()->toolProxy()->paste();
}
}
示例7: testThumbnailDeviceWithOffset
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));
}
示例8: testSharedDataManager
void KisPaintDeviceTest::testSharedDataManager()
{
QRect fillRect(0,0,100,100);
quint8 fillPixel[4]={255,255,255,255};
QRect clearRect(10,10,20,20);
QImage srcImage;
QImage dstImage;
const KoColorSpace *cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP srcDevice = new KisPaintDevice(cs);
srcDevice->setX(10);
srcDevice->setY(20);
srcDevice->fill(fillRect.left(), fillRect.top(),
fillRect.width(), fillRect.height(),fillPixel);
KisPaintDeviceSP dstDevice = new KisPaintDevice(srcDevice->dataManager(), srcDevice);
QVERIFY(srcDevice->extent() == dstDevice->extent());
QVERIFY(srcDevice->exactBounds() == dstDevice->exactBounds());
QVERIFY(srcDevice->defaultBounds() == dstDevice->defaultBounds());
QVERIFY(srcDevice->x() == dstDevice->x());
QVERIFY(srcDevice->y() == dstDevice->y());
srcImage = srcDevice->convertToQImage(0);
dstImage = dstDevice->convertToQImage(0);
QVERIFY(srcImage == dstImage);
srcDevice->clear(clearRect);
srcImage = srcDevice->convertToQImage(0);
dstImage = dstDevice->convertToQImage(0);
QVERIFY(srcImage == dstImage);
}