本文整理汇总了C++中KisPaintDeviceSP::createRandomSubAccessor方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::createRandomSubAccessor方法的具体用法?C++ KisPaintDeviceSP::createRandomSubAccessor怎么用?C++ KisPaintDeviceSP::createRandomSubAccessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::createRandomSubAccessor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runPartialDst
void KisPerspectiveTransformWorker::runPartialDst(KisPaintDeviceSP srcDev,
KisPaintDeviceSP dstDev,
const QRect &dstRect)
{
if (m_isIdentity) {
KisPainter::copyAreaOptimizedOldData(dstRect.topLeft(), srcDev, dstDev, dstRect);
return;
}
QRectF srcClipRect = srcDev->exactBounds();
if (srcClipRect.isEmpty()) return;
KisProgressUpdateHelper progressHelper(m_progressUpdater, 100, dstRect.height());
KisRandomSubAccessorSP srcAcc = srcDev->createRandomSubAccessor();
KisRandomAccessorSP accessor = dstDev->createRandomAccessorNG(dstRect.x(), dstRect.y());
for (int y = dstRect.y(); y < dstRect.y() + dstRect.height(); ++y) {
for (int x = dstRect.x(); x < dstRect.x() + dstRect.width(); ++x) {
QPointF dstPoint(x, y);
QPointF srcPoint = m_backwardTransform.map(dstPoint);
if (srcClipRect.contains(srcPoint)) {
accessor->moveTo(dstPoint.x(), dstPoint.y());
srcAcc->moveTo(srcPoint.x(), srcPoint.y());
srcAcc->sampledOldRawData(accessor->rawData());
}
}
progressHelper.step();
}
}
示例2: processImpl
void KisFilterWave::processImpl(KisPaintDeviceSP device,
const QRect& applyRect,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater
) const
{
Q_ASSERT(device.data() != 0);
int cost = (applyRect.width() * applyRect.height()) / 100;
if (cost == 0) cost = 1;
int count = 0;
QVariant value;
int horizontalwavelength = (config && config->getProperty("horizontalwavelength", value)) ? value.toInt() : 50;
int horizontalshift = (config && config->getProperty("horizontalshift", value)) ? value.toInt() : 50;
int horizontalamplitude = (config && config->getProperty("horizontalamplitude", value)) ? value.toInt() : 4;
int horizontalshape = (config && config->getProperty("horizontalshape", value)) ? value.toInt() : 0;
int verticalwavelength = (config && config->getProperty("verticalwavelength", value)) ? value.toInt() : 50;
int verticalshift = (config && config->getProperty("verticalshift", value)) ? value.toInt() : 50;
int verticalamplitude = (config && config->getProperty("verticalamplitude", value)) ? value.toInt() : 4;
int verticalshape = (config && config->getProperty("verticalshape", value)) ? value.toInt() : 0;
KisSequentialIterator dstIt(device, applyRect);
KisWaveCurve* verticalcurve;
if (verticalshape == 1)
verticalcurve = new KisTriangleWaveCurve(verticalamplitude, verticalwavelength, verticalshift);
else
verticalcurve = new KisSinusoidalWaveCurve(verticalamplitude, verticalwavelength, verticalshift);
KisWaveCurve* horizontalcurve;
if (horizontalshape == 1)
horizontalcurve = new KisTriangleWaveCurve(horizontalamplitude, horizontalwavelength, horizontalshift);
else
horizontalcurve = new KisSinusoidalWaveCurve(horizontalamplitude, horizontalwavelength, horizontalshift);
KisRandomSubAccessorSP srcRSA = device->createRandomSubAccessor();
do {
double xv = horizontalcurve->valueAt(dstIt.y(), dstIt.x());
double yv = verticalcurve->valueAt(dstIt.x(), dstIt.y());
srcRSA->moveTo(QPointF(xv, yv));
srcRSA->sampledOldRawData(dstIt.rawData());
if (progressUpdater) progressUpdater->setProgress((++count) / cost);
} while (dstIt.nextPixel());
delete horizontalcurve;
delete verticalcurve;
}
示例3: run
void KisPerspectiveTransformWorker::run()
{
KIS_ASSERT_RECOVER_RETURN(m_dev);
if (m_isIdentity) return;
KisPaintDeviceSP cloneDevice = new KisPaintDevice(*m_dev.data());
// Clear the destination device, since all the tiles are already
// shared with cloneDevice
m_dev->clear();
KIS_ASSERT_RECOVER_NOOP(!m_isIdentity);
KisProgressUpdateHelper progressHelper(m_progressUpdater, 100, m_dstRegion.rectCount());
KisRandomSubAccessorSP srcAcc = cloneDevice->createRandomSubAccessor();
KisRandomAccessorSP accessor = m_dev->createRandomAccessorNG(0, 0);
foreach(const QRect &rect, m_dstRegion.rects()) {
for (int y = rect.y(); y < rect.y() + rect.height(); ++y) {
for (int x = rect.x(); x < rect.x() + rect.width(); ++x) {
QPointF dstPoint(x, y);
QPointF srcPoint = m_backwardTransform.map(dstPoint);
if (m_srcRect.contains(srcPoint)) {
accessor->moveTo(dstPoint.x(), dstPoint.y());
srcAcc->moveTo(srcPoint.x(), srcPoint.y());
srcAcc->sampledOldRawData(accessor->rawData());
}
}
}
progressHelper.step();
}
}
示例4: paintAt
KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info)
{
if (!painter()->device()) return 1.0;
KisBrushSP brush = m_brush;
if (!brush)
return 1.0;
if (!brush->canPaintFor(info))
return 1.0;
if (!m_duplicateStartIsSet) {
m_duplicateStartIsSet = true;
m_duplicateStart = info.pos();
}
KisPaintDeviceSP realSourceDevice = settings->node()->paintDevice();
qreal scale = m_sizeOption.apply(info);
if (checkSizeTooSmall(scale)) return KisSpacingInformation();
QPointF hotSpot = brush->hotSpot(scale, scale, 0, info);
QPointF pt = info.pos() - hotSpot;
setCurrentScale(scale);
// Split the coordinates into integer plus fractional parts. The integer
// is where the dab will be positioned and the fractional part determines
// the sub-pixel positioning.
qint32 x, y;
qreal xFraction, yFraction; // will not be used
splitCoordinate(pt.x(), &x, &xFraction);
splitCoordinate(pt.y(), &y, &yFraction);
QPoint srcPoint;
if(m_moveSourcePoint)
{
srcPoint = QPoint(x - static_cast<qint32>(settings->offset().x()),
y - static_cast<qint32>(settings->offset().y()));
} else {
srcPoint = QPoint(static_cast<qint32>(settings->position().x() - hotSpot.x()),
static_cast<qint32>(settings->position().y() - hotSpot.y()));
}
qint32 sw = brush->maskWidth(scale, 0.0, xFraction, yFraction, info);
qint32 sh = brush->maskHeight(scale, 0.0, xFraction, yFraction, info);
if (srcPoint.x() < 0)
srcPoint.setX(0);
if (srcPoint.y() < 0)
srcPoint.setY(0);
// Perspective correction ?
KisImageWSP image = settings->m_image;
if (m_perspectiveCorrection && image && image->perspectiveGrid()->countSubGrids() == 1) {
Matrix3qreal startM = Matrix3qreal::Identity();
Matrix3qreal endM = Matrix3qreal::Identity();
// First look for the grid corresponding to the start point
KisSubPerspectiveGrid* subGridStart = *image->perspectiveGrid()->begin();
QRect r = QRect(0, 0, image->width(), image->height());
#if 1
if (subGridStart) {
startM = KisPerspectiveMath::computeMatrixTransfoFromPerspective(r, *subGridStart->topLeft(), *subGridStart->topRight(), *subGridStart->bottomLeft(), *subGridStart->bottomRight());
}
#endif
#if 1
// Second look for the grid corresponding to the end point
KisSubPerspectiveGrid* subGridEnd = *image->perspectiveGrid()->begin();
if (subGridEnd) {
endM = KisPerspectiveMath::computeMatrixTransfoToPerspective(*subGridEnd->topLeft(), *subGridEnd->topRight(), *subGridEnd->bottomLeft(), *subGridEnd->bottomRight(), r);
}
#endif
// Compute the translation in the perspective transformation space:
QPointF positionStartPaintingT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart));
QPointF duplicateStartPositionT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart) - QPointF(settings->offset()));
QPointF translat = duplicateStartPositionT - positionStartPaintingT;
KisRectIteratorSP dstIt = m_srcdev->createRectIteratorNG(0, 0, sw, sh);
KisRandomSubAccessorSP srcAcc = realSourceDevice->createRandomSubAccessor();
//Action
do {
QPointF p = KisPerspectiveMath::matProd(startM, KisPerspectiveMath::matProd(endM, QPointF(dstIt->x() + x, dstIt->y() + y)) + translat);
srcAcc->moveTo(p);
srcAcc->sampledOldRawData(dstIt->rawData());
} while (dstIt->nextPixel());
} else {
KisPainter copyPainter(m_srcdev);
copyPainter.setCompositeOp(COMPOSITE_COPY);
copyPainter.bitBltOldData(0, 0, realSourceDevice, srcPoint.x(), srcPoint.y(), sw, sh);
copyPainter.end();
}
// heal ?
//.........这里部分代码省略.........