本文整理汇总了C++中KisBrushSP::canPaintFor方法的典型用法代码示例。如果您正苦于以下问题:C++ KisBrushSP::canPaintFor方法的具体用法?C++ KisBrushSP::canPaintFor怎么用?C++ KisBrushSP::canPaintFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisBrushSP
的用法示例。
在下文中一共展示了KisBrushSP::canPaintFor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintAt
void KisBrushOp::paintAt(const KisPaintInformation& info)
{
if (!painter()->device()) return;
KisBrushSP brush = m_brush;
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (!brush->canPaintFor(adjustedInfo))
return;
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF pt = info.pos() - hotSpot;
// 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;
double xFraction;
qint32 y;
double yFraction;
splitCoordinate(pt.x(), &x, &xFraction);
splitCoordinate(pt.y(), &y, &yFraction);
quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info.pressure());
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info.pressure());
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
KisFixedPaintDeviceSP dab = cachedDab(device->colorSpace());
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->image(device->colorSpace(), scale, 0.0, adjustedInfo, xFraction, yFraction);
} else {
KoColor color = painter()->paintColor();
color.convertTo(dab->colorSpace());
brush->mask(dab, color, scale, scale, 0.0, info, xFraction, yFraction);
}
painter()->bltFixed(QPoint(x, y), dab, dab->bounds());
painter()->setOpacity(origOpacity);
painter()->setPaintColor(origColor);
}
示例2: paintAt
KisSpacingInformation KisFilterOp::paintAt(const KisPaintInformation& info)
{
if (!painter()) {
return KisSpacingInformation(1.0);
}
if (!m_filter) {
return KisSpacingInformation(1.0);
}
if (!source()) {
return KisSpacingInformation(1.0);
}
KisBrushSP brush = m_brush;
if (!brush) return KisSpacingInformation(1.0);
if (! brush->canPaintFor(info))
return KisSpacingInformation(1.0);
qreal scale = m_sizeOption.apply(info);
if (checkSizeTooSmall(scale)) return KisSpacingInformation();
setCurrentScale(scale);
qreal rotation = m_rotationOption.apply(info);
static const KoColorSpace *cs = KoColorSpaceRegistry::instance()->alpha8();
static KoColor color(Qt::black, cs);
QRect dstRect;
KisFixedPaintDeviceSP dab =
m_dabCache->fetchDab(cs, color, info.pos(),
scale, scale, rotation,
info, 1.0,
&dstRect);
if (dstRect.isEmpty()) return KisSpacingInformation(1.0);
QRect dabRect = dab->bounds();
// sanity check
Q_ASSERT(dstRect.size() == dabRect.size());
// Filter the paint device
QRect neededRect = m_filter->neededRect(dstRect, m_filterConfiguration);
KisPainter p(m_tmpDevice);
if (!m_smudgeMode) {
p.setCompositeOp(COMPOSITE_COPY);
}
p.bitBltOldData(neededRect.topLeft() - dstRect.topLeft(), source(), neededRect);
KisTransaction transaction(m_tmpDevice);
m_filter->process(m_tmpDevice, dabRect, m_filterConfiguration, 0);
transaction.end();
painter()->
bitBltWithFixedSelection(dstRect.x(), dstRect.y(),
m_tmpDevice, dab,
0, 0,
dabRect.x(), dabRect.y(),
dabRect.width(), dabRect.height());
painter()->renderMirrorMaskSafe(dstRect, m_tmpDevice, 0, 0, dab,
!m_dabCache->needSeparateOriginal());
return effectiveSpacing(scale, rotation);
}
示例3: 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 ?
//.........这里部分代码省略.........
示例4: paintAt
qreal KisFilterOp::paintAt(const KisPaintInformation& info)
{
if (!painter()) {
return 1.0;
}
if (!m_filter) {
return 1.0;
}
if (!source()) {
return 1.0;
}
KisBrushSP brush = m_brush;;
if (!brush) return 1.0;
if (! brush->canPaintFor(info))
return 1.0;
qreal scale = KisPaintOp::scaleForPressure(m_sizeOption.apply(info));
if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) return spacing(scale);
setCurrentScale(scale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
// 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;
qreal xFraction;
qint32 y;
qreal yFraction;
splitCoordinate(pt.x(), &x, &xFraction);
splitCoordinate(pt.y(), &y, &yFraction);
qint32 maskWidth = brush->maskWidth(scale, 0.0);
qint32 maskHeight = brush->maskHeight(scale, 0.0);
// Filter the paint device
m_filter->process(KisConstProcessingInformation(source(), QPoint(x, y)),
KisProcessingInformation(m_tmpDevice, QPoint(0, 0)),
QSize(maskWidth, maskHeight),
m_filterConfiguration, 0);
// Apply the mask on the paint device (filter before mask because edge pixels may be important)
KisFixedPaintDeviceSP fixedDab = new KisFixedPaintDevice(m_tmpDevice->colorSpace());
fixedDab->setRect(m_tmpDevice->extent());
fixedDab->initialize();
m_tmpDevice->readBytes(fixedDab->data(), fixedDab->bounds());
brush->mask(fixedDab, scale, scale, 0.0, info, xFraction, yFraction);
m_tmpDevice->writeBytes(fixedDab->data(), fixedDab->bounds());
if (!m_ignoreAlpha) {
KisHLineIteratorPixel itTmpDev = m_tmpDevice->createHLineIterator(0, 0, maskWidth);
KisHLineIteratorPixel itSrc = source()->createHLineIterator(x, y, maskWidth);
const KoColorSpace* cs = m_tmpDevice->colorSpace();
for (int y = 0; y < maskHeight; ++y) {
while (!itTmpDev.isDone()) {
quint8 alphaTmpDev = cs->opacityU8(itTmpDev.rawData());
quint8 alphaSrc = cs->opacityU8(itSrc.rawData());
cs->setOpacity(itTmpDev.rawData(), qMin(alphaTmpDev, alphaSrc), 1);
++itTmpDev;
++itSrc;
}
itTmpDev.nextRow();
itSrc.nextRow();
}
}
// Blit the paint device onto the layer
QRect dabRect = QRect(0, 0, maskWidth, maskHeight);
QRect dstRect = QRect(x, y, dabRect.width(), dabRect.height());
if (dstRect.isNull() || dstRect.isEmpty() || !dstRect.isValid()) return 1.0;
qint32 sx = dstRect.x() - x;
qint32 sy = dstRect.y() - y;
qint32 sw = dstRect.width();
qint32 sh = dstRect.height();
painter()->bitBlt(dstRect.x(), dstRect.y(), m_tmpDevice, sx, sy, sw, sh);
return spacing(scale);
}