void KisPixelSelection::renderToProjection(KisSelection* projection) { QRect updateRect = selectedExactRect(); KisPainter painter(projection); painter.setCompositeOp(colorSpace()->compositeOp(COMPOSITE_COPY)); painter.bitBlt(updateRect.topLeft(), KisPaintDeviceSP(this), updateRect); painter.end(); }
void KisPixelSelection::select(const QRect & rc, quint8 selectedness) { QRect r = rc.normalized(); if (r.width() > 0 && r.height() > 0) { KisFillPainter painter(KisPaintDeviceSP(this)); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); painter.fillRect(r, KoColor(Qt::white, cs), selectedness); } }
void KisPixelSelection::clear(const QRect & r) { if (*(m_datamanager->defaultPixel()) != MIN_SELECTED) { KisFillPainter painter(KisPaintDeviceSP(this)); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); painter.fillRect(r, KoColor(Qt::white, cs), MIN_SELECTED); } else { m_datamanager->clear(r.x(), r.y(), r.width(), r.height(), m_datamanager->defaultPixel()); } }
void KisPixelSelection::clear(const QRect & r) { if (*defaultPixel() != MIN_SELECTED) { KisFillPainter painter(KisPaintDeviceSP(this)); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); painter.fillRect(r, KoColor(Qt::white, cs), MIN_SELECTED); } else { KisPaintDevice::clear(r); } }
void KisPixelSelection::renderToProjection(KisSelection* projection, const QRect& r) { QRect updateRect = r.intersected(selectedExactRect()); if (updateRect.isValid()) { KisPainter painter(projection); painter.setCompositeOp(COMPOSITE_COPY); painter.bitBlt(updateRect.x(), updateRect.y(), KisPaintDeviceSP(this), updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height()); painter.end(); } }
void KisSmallTilesFilter::process(KisConstProcessingInformation srcInfo, KisProcessingInformation dstInfo, const QSize& size, const KisFilterConfiguration* config, KoUpdater* progressUpdater ) const { const KisPaintDeviceSP src = srcInfo.paintDevice(); KisPaintDeviceSP dst = dstInfo.paintDevice(); QPoint dstTopLeft = dstInfo.topLeft(); QPoint srcTopLeft = srcInfo.topLeft(); Q_ASSERT(!src.isNull()); Q_ASSERT(!dst.isNull()); //read the filter configuration values from the KisFilterConfiguration object quint32 numberOfTiles = config->getInt("numberOfTiles", 2); QRect srcRect = src->exactBounds(); int w = static_cast<int>(srcRect.width() / numberOfTiles); int h = static_cast<int>(srcRect.height() / numberOfTiles); KisPaintDeviceSP tile = KisPaintDeviceSP(0); if (srcInfo.selection()) { KisPaintDeviceSP tmp = new KisPaintDevice(src->colorSpace()); KisPainter gc(tmp); gc.setCompositeOp(COMPOSITE_COPY); gc.bitBlt(0, 0, src, srcTopLeft.x(), srcTopLeft.y(), size.width(), size.height()); tile = tmp->createThumbnailDevice(srcRect.width() / numberOfTiles, srcRect.height() / numberOfTiles); } else { tile = src->createThumbnailDevice(srcRect.width() / numberOfTiles, srcRect.height() / numberOfTiles); } if (tile.isNull()) return; KisPainter gc(dst); gc.setCompositeOp(COMPOSITE_COPY); if (progressUpdater) { progressUpdater->setRange(0, numberOfTiles); } if (srcInfo.selection()) { gc.setSelection(srcInfo.selection()); } for (uint y = 0; y < numberOfTiles; ++y) { for (uint x = 0; x < numberOfTiles; ++x) { gc.bitBlt(w * x, h * y, tile, 0, 0, w, h); } if (progressUpdater) progressUpdater->setValue(y); } gc.end(); }
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; }
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; }
KisSelectedTransactionData::KisSelectedTransactionData(const QString& name, KisNodeSP node, QUndoCommand* parent) : KisTransactionData(name, node->paintDevice(), parent) , m_selTransaction(0) , m_hadSelection(false /*device->hasSelection()*/) { m_layer = dynamic_cast<KisLayer*>(node.data()); while (!m_layer && node->parent()) { m_layer = dynamic_cast<KisLayer*>(node->parent().data()); node = node->parent(); } if (m_layer->selection()) m_selTransaction = new KisTransactionData(name, KisPaintDeviceSP(m_layer->selection()->getOrCreatePixelSelection().data())); // if(! m_hadSelection) { // m_device->deselect(); // let us not be the cause of select // } }
void KisPixelSelection::select(const QRect & r, quint8 selectedness) { KisFillPainter painter(KisPaintDeviceSP(this)); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); painter.fillRect(r, KoColor(Qt::white, cs), selectedness); }