本文整理汇总了C++中KisPaintDeviceSP类的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP类的具体用法?C++ KisPaintDeviceSP怎么用?C++ KisPaintDeviceSP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KisPaintDeviceSP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KisPaintDevice
void KisScanlineFillTest::testFillGeneral(const QVector<KisFillInterval> &initialBackwardIntervals,
const QVector<QColor> &expectedResult,
const QVector<KisFillInterval> &expectedForwardIntervals,
const QVector<KisFillInterval> &expectedBackwardIntervals)
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->setPixel(1, 0, Qt::white);
dev->setPixel(2, 0, Qt::white);
dev->setPixel(5, 0, Qt::white);
dev->setPixel(8, 0, Qt::white);
dev->setPixel(17, 0, Qt::white);
QRect boundingRect(-10, -10, 30, 30);
KisScanlineFill gc(dev, QPoint(), boundingRect);
KisFillIntervalMap *backwardMap = gc.testingGetBackwardIntervals();
Q_FOREACH (const KisFillInterval &i, initialBackwardIntervals) {
backwardMap->insertInterval(i);
}
示例2: KisPaintDevice
void KisFillPainterTest::benchmarkFillPainter(const QPoint &startPoint, bool useCompositioning)
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
QImage srcImage(TestUtil::fetchDataFileLazy("heavy_labyrinth.png"));
QVERIFY(!srcImage.isNull());
QRect imageRect = srcImage.rect();
dev->convertFromQImage(srcImage, 0, 0, 0);
QBENCHMARK_ONCE {
KisFillPainter gc(dev);
gc.setFillThreshold(THRESHOLD);
gc.setWidth(imageRect.width());
gc.setHeight(imageRect.height());
gc.setPaintColor(KoColor(Qt::red, dev->colorSpace()));
gc.setUseCompositioning(useCompositioning);
gc.fillColor(startPoint.x(), startPoint.y(), dev);
}
QImage resultImage =
dev->convertToQImage(0,
imageRect.x(), imageRect.y(),
imageRect.width(), imageRect.height());
QString testName = QString("heavy_labyrinth_%1_%2_%3")
.arg(startPoint.x())
.arg(startPoint.y())
.arg(useCompositioning ? "composed" : "direct");
QVERIFY(TestUtil::checkQImage(resultImage,
"fill_painter",
"general_",
testName));
}
示例3: SLOT
void ImageBuilder::createImageFromClipboardDelayed()
{
DocumentManager::instance()->disconnect(this, SLOT(createImageFromClipboardDelayed()));
KisConfig cfg;
cfg.setPasteBehaviour(PASTE_ASSUME_MONITOR);
QSize sz = KisClipboard::instance()->clipSize();
KisPaintDeviceSP clipDevice = KisClipboard::instance()->clip(QRect(0, 0, sz.width(), sz.height()), false);
KisImageWSP image = DocumentManager::instance()->document()->image();
if (image && image->root() && image->root()->firstChild()) {
KisLayer * layer = dynamic_cast<KisLayer*>(image->root()->firstChild().data());
Q_ASSERT(layer);
layer->setOpacity(OPACITY_OPAQUE_U8);
QRect r = clipDevice->exactBounds();
KisPainter painter;
painter.begin(layer->paintDevice());
painter.setCompositeOp(COMPOSITE_COPY);
painter.bitBlt(QPoint(0, 0), clipDevice, r);
layer->setDirty(QRect(0, 0, sz.width(), sz.height()));
}
}
示例4: write
bool PSDImageData::write(QIODevice *io, KisPaintDeviceSP dev, bool hasAlpha)
{
// XXX: make the compression settting configurable. For now, always use RLE.
psdwrite(io, (quint16)Compression::RLE);
// now write all the channels in display order
// fill in the channel chooser, in the display order, but store the pixel index as well.
QRect rc(0, 0, m_header->width, m_header->height);
const int channelSize = m_header->channelDepth / 8;
const psd_color_mode colorMode = m_header->colormode;
QVector<PsdPixelUtils::ChannelWritingInfo> writingInfoList;
bool writeAlpha = hasAlpha &&
dev->colorSpace()->channelCount() != dev->colorSpace()->colorChannelCount();
const int numChannels =
writeAlpha ?
dev->colorSpace()->channelCount() :
dev->colorSpace()->colorChannelCount();
for (int i = 0; i < numChannels; i++) {
const int rleOffset = io->pos();
int channelId = writeAlpha && i == numChannels - 1 ? -1 : i;
writingInfoList <<
PsdPixelUtils::ChannelWritingInfo(channelId, -1, rleOffset);
io->seek(io->pos() + rc.height() * sizeof(quint16));
}
PsdPixelUtils::writePixelDataCommon(io, dev, rc,
colorMode, channelSize,
false, false, writingInfoList);
return true;
}
示例5: write
bool PSDImageData::write(QIODevice *io, KisPaintDeviceSP dev)
{
// XXX: make the compression settting configurable. For now, always use RLE.
psdwrite(io, (quint16)Compression::RLE);
// now write all the channels in display order
// fill in the channel chooser, in the display order, but store the pixel index as well.
QRect rc(0, 0, m_header->width, m_header->height);
QVector<quint8* > tmp = dev->readPlanarBytes(0, 0, rc.width(), rc.height());
// then reorder the planes to fit the psd model -- alpha first, then display order
QVector<quint8* > planes;
QList<KoChannelInfo*> origChannels = dev->colorSpace()->channels();
quint8* alphaPlane = 0;
foreach(KoChannelInfo *ch, KoChannelInfo::displayOrderSorted(origChannels)) {
int channelIndex = KoChannelInfo::displayPositionToChannelIndex(ch->displayPosition(), origChannels);
//qDebug() << ppVar(ch->name()) << ppVar(ch->pos()) << ppVar(ch->displayPosition()) << ppVar(channelIndex);
if (ch->channelType() == KoChannelInfo::ALPHA) {
alphaPlane = tmp[channelIndex];
} else {
planes.append(tmp[channelIndex]);
}
}
示例6: fillGradient
void KisScratchPad::fillGradient()
{
if(!m_paintLayer) return;
KisPaintDeviceSP paintDevice = m_paintLayer->paintDevice();
KoAbstractGradient* gradient = m_resourceProvider->currentGradient();
QRect gradientRect = widgetToDocument().mapRect(rect());
paintDevice->clear();
KisGradientPainter painter(paintDevice);
painter.setGradient(gradient);
painter.paintGradient(gradientRect.topLeft(),
gradientRect.bottomRight(),
KisGradientPainter::GradientShapeLinear,
KisGradientPainter::GradientRepeatNone,
0.2, false,
gradientRect.left(), gradientRect.top(),
gradientRect.width(), gradientRect.height());
update();
}
示例7: graysrc
void KisCurveMagnetic::detectEdges(const QRect & rect, KisPaintDeviceSP src, GrayMatrix& dst)
{
GrayMatrix graysrc(rect.width(), GrayCol(rect.height()));
GrayMatrix xdeltas(rect.width(), GrayCol(rect.height()));
GrayMatrix ydeltas(rect.width(), GrayCol(rect.height()));
GrayMatrix magnitude(rect.width(), GrayCol(rect.height()));
KisPaintDeviceSP smooth = new KisPaintDevice(src->colorSpace());
gaussianBlur(rect, src, smooth);
toGrayScale(rect, smooth, graysrc);
getDeltas(graysrc, xdeltas, ydeltas);
getMagnitude(xdeltas, ydeltas, magnitude);
nonMaxSupp(magnitude, xdeltas, ydeltas, dst);
}
示例8: savePaintDevice
bool KisKraSaveVisitor::savePaintDevice(KisPaintDeviceSP device,
QString location)
{
// Layer data
KisConfig cfg;
m_store->setCompressionEnabled(cfg.compressKra());
if (m_store->open(location)) {
if (!device->write(*m_writer)) {
device->disconnect();
m_store->close();
return false;
}
m_store->close();
}
if (m_store->open(location + ".defaultpixel")) {
m_store->write((char*)device->defaultPixel(), device->colorSpace()->pixelSize());
m_store->close();
}
m_store->setCompressionEnabled(true);
return true;
}
示例9: image
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());
}
}
示例10: OilPaint
void KisOilPaintFilter::OilPaint(const KisPaintDeviceSP src, KisPaintDeviceSP dst, const QPoint& srcTopLeft, const QPoint& dstTopLeft, int w, int h,
int BrushSize, int Smoothness, KoUpdater* progressUpdater) const
{
if (progressUpdater) {
progressUpdater->setRange(0, w * h);
}
QRect bounds(srcTopLeft.x(), srcTopLeft.y(), w, h);
KisHLineConstIteratorSP it = src->createHLineConstIteratorNG(srcTopLeft.x(), srcTopLeft.y(), w);
KisHLineIteratorSP dstIt = dst->createHLineIteratorNG(dstTopLeft.x(), dstTopLeft.y(), w);
int progress = 0;
for (qint32 yOffset = 0; yOffset < h; yOffset++) {
do { //&& !cancelRequested()) {
MostFrequentColor(src, dstIt->rawData(), bounds, it->x(), it->y(), BrushSize, Smoothness);
} while (it->nextPixel() && dstIt->nextPixel());
it->nextRow();
dstIt->nextRow();
if (progressUpdater) progressUpdater->setValue(progress += w);
}
}
示例11: referenceImageRect
void KisSelectionTest::testSelectionExactBounds()
{
QRect referenceImageRect(0,0,1000,1000);
QRect referenceDeviceRect(10,10,1000,1000);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, referenceImageRect.width(),
referenceImageRect.height(),
cs, "stest");
KisPaintDeviceSP device = new KisPaintDevice(cs);
device->fill(referenceDeviceRect, KoColor(Qt::white, cs));
QCOMPARE(device->exactBounds(), referenceDeviceRect);
KisSelectionSP selection = new KisSelection(device, new KisSelectionDefaultBounds(device, image));
quint8 defaultPixel = MAX_SELECTED;
selection->setDefaultPixel(&defaultPixel);
QCOMPARE(selection->selectedExactRect(), referenceImageRect | referenceDeviceRect);
}
示例12: processImpl
void KisBlurFilter::processImpl(KisPaintDeviceSP device,
const QRect& rect,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater
) const
{
QPoint srcTopLeft = rect.topLeft();
Q_ASSERT(device != 0);
if (!config) config = new KisFilterConfiguration(id().id(), 1);
QVariant value;
int shape = (config->getProperty("shape", value)) ? value.toInt() : 0;
uint halfWidth = (config->getProperty("halfWidth", value)) ? value.toUInt() : 5;
uint width = 2 * halfWidth + 1;
uint halfHeight = (config->getProperty("halfHeight", value)) ? value.toUInt() : 5;
uint height = 2 * halfHeight + 1;
int rotate = (config->getProperty("rotate", value)) ? value.toInt() : 0;
int strength = 100 - (config->getProperty("strength", value) ? value.toUInt() : 0);
int hFade = (halfWidth * strength) / 100;
int vFade = (halfHeight * strength) / 100;
KisMaskGenerator* kas;
dbgKrita << width << "" << height << "" << hFade << "" << vFade;
switch (shape) {
case 1:
kas = new KisRectangleMaskGenerator(width, width / height , hFade, vFade, 2);
break;
case 0:
default:
kas = new KisCircleMaskGenerator(width, width / height, hFade, vFade, 2);
break;
}
QBitArray channelFlags;
if (config) {
channelFlags = config->channelFlags();
}
if (channelFlags.isEmpty() || !config) {
channelFlags = QBitArray(device->colorSpace()->channelCount(), true);
}
KisConvolutionKernelSP kernel = KisConvolutionKernel::fromMaskGenerator(kas, rotate * M_PI / 180.0);
delete kas;
KisConvolutionPainter painter(device);
painter.setChannelFlags(channelFlags);
painter.setProgress(progressUpdater);
painter.applyMatrix(kernel, device, srcTopLeft, srcTopLeft, rect.size(), BORDER_REPEAT);
}
示例13: qimage
void KisFilterTest::testSingleThreaded()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
QImage qimage(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
QImage inverted(QString(FILES_DATA_DIR) + QDir::separator() + "inverted_hakonepa.png");
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->convertFromQImage(qimage, 0, 0, 0);
KisFilterSP f = KisFilterRegistry::instance()->value("invert");
Q_ASSERT(f);
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT(kfc);
f->process(dev, QRect(QPoint(0,0), qimage.size()), kfc);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, inverted, dev->convertToQImage(0, 0, 0, qimage.width(), qimage.height()))) {
dev->convertToQImage(0, 0, 0, qimage.width(), qimage.height()).save("filtertest.png");
QFAIL(QString("Failed to create inverted image, first different pixel: %1,%2 ").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}
示例14: setDisplayProfile
void KisScratchPad::setupScratchPad(KisCanvasResourceProvider* resourceProvider,
const QColor &defaultColor)
{
m_resourceProvider = resourceProvider;
KisConfig cfg;
setDisplayProfile(cfg.displayProfile(QApplication::desktop()->screenNumber(this)));
connect(m_resourceProvider, SIGNAL(sigDisplayProfileChanged(const KoColorProfile*)),
SLOT(setDisplayProfile(const KoColorProfile*)));
connect(m_resourceProvider, SIGNAL(sigOnScreenResolutionChanged(qreal,qreal)),
SLOT(setOnScreenResolution(qreal,qreal)));
m_defaultColor = KoColor(defaultColor, KoColorSpaceRegistry::instance()->rgb8());
KisPaintDeviceSP paintDevice =
new KisPaintDevice(m_defaultColor.colorSpace(), "scratchpad");
m_paintLayer = new KisPaintLayer(0, "ScratchPad", OPACITY_OPAQUE_U8, paintDevice);
m_paintLayer->setGraphListener(m_nodeListener);
paintDevice->setDefaultBounds(new KisScratchPadDefaultBounds(this));
fillDefault();
}
示例15: copyFromDevice
void copyFromDevice(KisViewManager *view, KisPaintDeviceSP device, bool makeSharpClip = false)
{
KisImageWSP image = view->image();
if (!image) return;
KisSelectionSP selection = view->selection();
QRect rc = (selection) ? selection->selectedExactRect() : image->bounds();
KisPaintDeviceSP clip = new KisPaintDevice(device->colorSpace());
Q_CHECK_PTR(clip);
const KoColorSpace *cs = clip->colorSpace();
// TODO if the source is linked... copy from all linked layers?!?
// Copy image data
KisPainter::copyAreaOptimized(QPoint(), device, clip, rc);
if (selection) {
// Apply selection mask.
KisPaintDeviceSP selectionProjection = selection->projection();
KisHLineIteratorSP layerIt = clip->createHLineIteratorNG(0, 0, rc.width());
KisHLineConstIteratorSP selectionIt = selectionProjection->createHLineIteratorNG(rc.x(), rc.y(), rc.width());
const KoColorSpace *selCs = selection->projection()->colorSpace();
for (qint32 y = 0; y < rc.height(); y++) {
for (qint32 x = 0; x < rc.width(); x++) {
/**
* Sharp method is an exact reverse of COMPOSITE_OVER
* so if you cover the cut/copied piece over its source
* you get an exactly the same image without any seams
*/
if (makeSharpClip) {
qreal dstAlpha = cs->opacityF(layerIt->rawData());
qreal sel = selCs->opacityF(selectionIt->oldRawData());
qreal newAlpha = sel * dstAlpha / (1.0 - dstAlpha + sel * dstAlpha);
float mask = newAlpha / dstAlpha;
cs->applyAlphaNormedFloatMask(layerIt->rawData(), &mask, 1);
} else {
cs->applyAlphaU8Mask(layerIt->rawData(), selectionIt->oldRawData(), 1);
}
layerIt->nextPixel();
selectionIt->nextPixel();
}
layerIt->nextRow();
selectionIt->nextRow();
}
}
KisClipboard::instance()->setClip(clip, rc.topLeft());
}