本文整理汇总了C++中KisLayerSP::paintDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ KisLayerSP::paintDevice方法的具体用法?C++ KisLayerSP::paintDevice怎么用?C++ KisLayerSP::paintDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisLayerSP
的用法示例。
在下文中一共展示了KisLayerSP::paintDevice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeToLayerImpl
void KisIndirectPaintingSupport::mergeToLayerImpl(KisLayerSP layer,
UndoAdapter *undoAdapter,
const KUndo2MagicString &transactionText)
{
/**
* We do not apply selection here, because it has already
* been taken into account in a tool code
*/
KisPainter gc(layer->paintDevice());
setupTemporaryPainter(&gc);
d->lock.lockForWrite();
/**
* Scratchpad may not have an undo adapter
*/
if(undoAdapter) {
gc.beginTransaction(transactionText);
}
foreach (const QRect &rc, d->temporaryTarget->region().rects()) {
gc.bitBlt(rc.topLeft(), d->temporaryTarget, rc);
}
releaseResources();
if(undoAdapter) {
gc.endTransaction(undoAdapter);
}
d->lock.unlock();
}
示例2: mergeToLayer
void KisIndirectPaintingSupport::mergeToLayer(KisLayerSP layer, const QRegion ®ion, const QString &transactionText)
{
/**
* We do not apply selection here, because it has already
* been taken into account in a tool code
*/
KisPainter gc(layer->paintDevice());
gc.setCompositeOp(d->compositeOp);
gc.setOpacity(d->compositeOpacity);
gc.setChannelFlags(layer->channelFlags());
if (KisPaintLayer* paintLayer = dynamic_cast<KisPaintLayer*>(layer.data())) {
if (paintLayer->alphaLocked()) {
gc.setLockAlpha(paintLayer->alphaLocked());
}
}
d->lock.lockForWrite();
if(layer->image()) {
gc.beginTransaction(transactionText);
}
foreach(const QRect& rc, region.rects()) {
gc.bitBlt(rc.topLeft(), d->temporaryTarget, rc);
}
d->temporaryTarget = 0;
// in the scratchpad the layer has no image and there is no undo adapter
if(layer->image()) {
gc.endTransaction(layer->image()->undoAdapter());
}
d->lock.unlock();
}
示例3: benchmarkWideArea
/**
* This benchmark runs a series of huge strokes on a canvas with a
* particular configuration of the swapper/pooler and history
* management. After the test is done you can visualize the results
* with the GNU Octave. Please use kis_low_memory_show_report.m file
* for that.
*/
void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
const QRectF &rect, qreal vstep,
int numCycles,
bool createTransaction,
int hardLimitMiB,
int softLimitMiB,
int poolLimitMiB,
int index)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(QString(FILES_DATA_DIR) + QDir::separator() + presetFileName);
LOAD_PRESET_OR_RETURN(preset, presetFileName);
/**
* Initialize image and painter
*/
const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, HUGE_IMAGE_SIZE, HUGE_IMAGE_SIZE, colorSpace, "stroke sample image", true);
KisLayerSP layer = new KisPaintLayer(image, "temporary for stroke sample", OPACITY_OPAQUE_U8, colorSpace);
KisLayerSP layerExtra = new KisPaintLayer(image, "temporary for threading", OPACITY_OPAQUE_U8, colorSpace);
image->addNode(layer, image->root());
image->addNode(layerExtra, image->root());
KisPainter *painter = new KisPainter(layer->paintDevice());
painter->setPaintColor(KoColor(Qt::black, colorSpace));
painter->setPaintOpPreset(preset, layer, image);
/**
* A simple adapter that will store all the transactions for us
*/
KisSurrogateUndoAdapter undoAdapter;
/**
* Reset configuration to the desired settings
*/
KisImageConfig config;
qreal oldHardLimit = config.memoryHardLimitPercent();
qreal oldSoftLimit = config.memorySoftLimitPercent();
qreal oldPoolLimit = config.memoryPoolLimitPercent();
const qreal _MiB = 100.0 / KisImageConfig::totalRAM();
config.setMemoryHardLimitPercent(hardLimitMiB * _MiB);
config.setMemorySoftLimitPercent(softLimitMiB * _MiB);
config.setMemoryPoolLimitPercent(poolLimitMiB * _MiB);
KisTileDataStore::instance()->testingRereadConfig();
/**
* Create an empty the log file
*/
QString fileName;
fileName = QString("log_%1_%2_%3_%4_%5.txt")
.arg(createTransaction)
.arg(hardLimitMiB)
.arg(softLimitMiB)
.arg(poolLimitMiB)
.arg(index);
QFile logFile(fileName);
logFile.open(QFile::WriteOnly | QFile::Truncate);
QTextStream logStream(&logFile);
logStream.setFieldWidth(10);
logStream.setFieldAlignment(QTextStream::AlignRight);
/**
* Start painting on the image
*/
QTime cycleTime;
QTime lineTime;
cycleTime.start();
lineTime.start();
qreal rectBottom = rect.y() + rect.height();
for (int i = 0; i < numCycles; i++) {
cycleTime.restart();
QLineF line(rect.topLeft(), rect.topLeft() + QPointF(rect.width(), 0));
if (createTransaction) {
painter->beginTransaction();
}
KisDistanceInformation currentDistance;
while(line.y1() < rectBottom) {
lineTime.restart();
KisPaintInformation pi1(line.p1(), 0.0);
KisPaintInformation pi2(line.p2(), 1.0);
painter->paintLine(pi1, pi2, ¤tDistance);
//.........这里部分代码省略.........
示例4: doPartialTests
//.........这里部分代码省略.........
result &= chk.checkImage(image, testName);
}
// toggle mask visibility
mask->setVisible(false);
mask->setDirty();
image->waitForDone();
testName = QString("tm_%1_mask_visible_off").arg(testIndex++);
result &= chk.checkImage(image, testName);
mask->setVisible(true);
mask->setDirty();
image->waitForDone();
testName = QString("tm_%1_mask_visible_on").arg(testIndex++);
result &= chk.checkImage(image, testName);
// entire bounds update
// no clearing, just don't hang up
paintLayer->setDirty(refRect);
image->waitForDone();
testName = QString("tm_%1_layer_dirty_bounds").arg(testIndex++);
result &= chk.checkImage(image, testName);
// no clearing, just don't hang up
mask->setDirty(refRect);
image->waitForDone();
testName = QString("tm_%1_mask_dirty_bounds").arg(testIndex++);
result &= chk.checkImage(image, testName);
if (paintLayer != visibilityToggleLayer) {
// no clearing, just don't hang up
visibilityToggleLayer->setDirty(refRect);
image->waitForDone();
testName = QString("tm_%1_extra_layer_dirty_bounds").arg(testIndex++);
result &= chk.checkImage(image, testName);
}
QRect fillRect;
// partial updates outside
fillRect = QRect(-100, 0.5 * refRect.height(), 50, 100);
paintLayer->paintDevice()->fill(fillRect, KoColor(Qt::red, image->colorSpace()));
paintLayer->setDirty(fillRect);
image->waitForDone();
testName = QString("tm_%1_layer_dirty_outside_%2_%3").arg(testIndex++).arg(fillRect.x()).arg(fillRect.y());
result &= chk.checkImage(image, testName);
fillRect = QRect(0.5 * refRect.width(), -100, 100, 50);
paintLayer->paintDevice()->fill(fillRect, KoColor(Qt::red, image->colorSpace()));
paintLayer->setDirty(fillRect);
image->waitForDone();
testName = QString("tm_%1_layer_dirty_outside_%2_%3").arg(testIndex++).arg(fillRect.x()).arg(fillRect.y());
result &= chk.checkImage(image, testName);
fillRect = QRect(refRect.width() + 50, 0.2 * refRect.height(), 50, 100);
paintLayer->paintDevice()->fill(fillRect, KoColor(Qt::red, image->colorSpace()));
paintLayer->setDirty(fillRect);
image->waitForDone();
testName = QString("tm_%1_layer_dirty_outside_%2_%3").arg(testIndex++).arg(fillRect.x()).arg(fillRect.y());
result &= chk.checkImage(image, testName);
// partial update inside
fillRect = QRect(0.5 * refRect.width() - 50, 0.5 * refRect.height() - 50, 100, 100);
paintLayer->paintDevice()->fill(fillRect, KoColor(Qt::red, image->colorSpace()));
paintLayer->setDirty(fillRect);
image->waitForDone();
testName = QString("tm_%1_layer_dirty_inside_%2_%3").arg(testIndex++).arg(fillRect.x()).arg(fillRect.y());
result &= chk.checkImage(image, testName);
// clear explicitly
image->projection()->clear();
mask->setDirty();
image->waitForDone();
testName = QString("tm_%1_mask_dirty_bounds").arg(testIndex++);
result &= chk.checkImage(image, testName);
KisDumbTransformMaskParams *params =
dynamic_cast<KisDumbTransformMaskParams*>(mask->transformParams().data());
QTransform t = params->testingGetTransform();
t *= QTransform::fromTranslate(400, 300);
params->testingSetTransform(t);
mask->setTransformParams(mask->transformParams());
mask->setDirty();
image->waitForDone();
testName = QString("tm_%1_mask_dirty_after_offset").arg(testIndex++);
result &= chk.checkImage(image, testName);
return result;
}
示例5: loadFromDevice
KisImportExportFilter::ConversionStatus KisXCFImport::loadFromDevice(QIODevice* device, KisDocument* doc)
{
dbgFile << "Start decoding file";
// Read the file into memory
device->open(QIODevice::ReadOnly);
QByteArray data = device->readAll();
xcf_file = (uint8_t*)data.data();
xcf_length = data.size();
device->close();
// Decode the data
getBasicXcfInfo() ;
initColormap();
dbgFile << XCF.version << "width = " << XCF.width << "height = " << XCF.height << "layers = " << XCF.numLayers;
// Create the image
KisImageSP image = new KisImage(doc->createUndoStore(), XCF.width, XCF.height, KoColorSpaceRegistry::instance()->rgb8(), "built image");
QVector<Layer> layers;
uint maxDepth = 0;
// Read layers
for (int i = 0; i < XCF.numLayers; ++i) {
Layer layer;
xcfLayer& xcflayer = XCF.layers[i];
dbgFile << i << " name = " << xcflayer.name << " opacity = " << xcflayer.opacity << "group:" << xcflayer.isGroup << xcflayer.pathLength;
dbgFile << ppVar(xcflayer.dim.width) << ppVar(xcflayer.dim.height) << ppVar(xcflayer.dim.tilesx) << ppVar(xcflayer.dim.tilesy) << ppVar(xcflayer.dim.ntiles) << ppVar(xcflayer.dim.c.t) << ppVar(xcflayer.dim.c.l) << ppVar(xcflayer.dim.c.r) << ppVar(xcflayer.dim.c.b);
maxDepth = qMax(maxDepth, xcflayer.pathLength);
bool isRgbA = false;
// Select the color space
const KoColorSpace* colorSpace = 0;
switch (xcflayer.type) {
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
colorSpace = KoColorSpaceRegistry::instance()->rgb8();
isRgbA = true;
break;
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
colorSpace = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), "");
isRgbA = false;
break;
}
// Create the layer
KisLayerSP kisLayer;
if (xcflayer.isGroup) {
kisLayer = new KisGroupLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity);
}
else {
kisLayer = new KisPaintLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity, colorSpace);
}
// Set some properties
kisLayer->setCompositeOpId(layerModeG2K(xcflayer.mode));
kisLayer->setVisible(xcflayer.isVisible);
kisLayer->disableAlphaChannel(xcflayer.mode != GIMP_NORMAL_MODE);
layer.layer = kisLayer;
layer.depth = xcflayer.pathLength;
// Copy the data in the image
initLayer(&xcflayer);
int left = xcflayer.dim.c.l;
int top = xcflayer.dim.c.t;
if (!xcflayer.isGroup) {
// Copy the data;
for (unsigned int x = 0; x < xcflayer.dim.width; x += TILE_WIDTH) {
for (unsigned int y = 0; y < xcflayer.dim.height; y += TILE_HEIGHT) {
rect want;
want.l = x + left;
want.t = y + top;
want.b = want.t + TILE_HEIGHT;
want.r = want.l + TILE_WIDTH;
Tile* tile = getMaskOrLayerTile(&xcflayer.dim, &xcflayer.pixels, want);
KisHLineIteratorSP it = kisLayer->paintDevice()->createHLineIteratorNG(x, y, TILE_WIDTH);
rgba* data = tile->pixels;
for (int v = 0; v < TILE_HEIGHT; ++v) {
if (isRgbA) {
// RGB image
do {
KoBgrTraits<quint8>::setRed(it->rawData(), GET_RED(*data));
KoBgrTraits<quint8>::setGreen(it->rawData(), GET_GREEN(*data));
KoBgrTraits<quint8>::setBlue(it->rawData(), GET_BLUE(*data));
KoBgrTraits<quint8>::setOpacity(it->rawData(), quint8(GET_ALPHA(*data)), 1);
++data;
} while (it->nextPixel());
} else {
// Grayscale image
do {
//.........这里部分代码省略.........