本文整理汇总了C++中KisPaintDeviceSP::createRectConstIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintDeviceSP::createRectConstIterator方法的具体用法?C++ KisPaintDeviceSP::createRectConstIterator怎么用?C++ KisPaintDeviceSP::createRectConstIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisPaintDeviceSP
的用法示例。
在下文中一共展示了KisPaintDeviceSP::createRectConstIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testApplication
void KisThreadedApplicatorTest::testApplication()
{
const KoColorSpace * colorSpace = KoColorSpaceRegistry::instance()->rgb8();
TestJobFactory factory;
TestUtil::TestProgressBar bar;
KoProgressUpdater updater(&bar);
KisPaintDeviceSP test = new KisPaintDevice(colorSpace);
quint8 *bytes = test->colorSpace()->allocPixelBuffer(1);
memset(bytes, 128, test->colorSpace()->pixelSize());
test->fill(0, 0, 1000, 1000, bytes);
KisTransaction transaction("", test);
KisThreadedApplicator applicator(test, QRect(0, 0, 1000, 1000), &factory, &updater);
applicator.execute();
KisRectConstIteratorPixel it = test->createRectConstIterator(0, 0, 1000, 1000);
while (!it.isDone()) {
QCOMPARE((int)it.rawData()[0], (int)255);
QCOMPARE((int)it.rawData()[1], (int)255);
QCOMPARE((int)it.rawData()[2], (int)255);
QCOMPARE((int)it.rawData()[3], (int)255);
++it;
}
}
示例2: process
void KisFilterColorToAlpha::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 != 0);
Q_ASSERT(dst != 0);
if (config == 0) config = new KisFilterConfiguration("colortoalpha", 1);
QVariant value;
QColor cTA = (config->getProperty("targetcolor", value)) ? value.value<QColor>() : QColor(255, 255, 255);
int threshold = (config->getProperty("threshold", value)) ? value.toInt() : 0;
qreal thresholdF = threshold;
KisRectIteratorPixel dstIt = dst->createRectIterator(dstTopLeft.x(), dstTopLeft.y(), size.width(), size.height(), dstInfo.selection());
KisRectConstIteratorPixel srcIt = src->createRectConstIterator(srcTopLeft.x(), srcTopLeft.y(), size.width(), size.height(), srcInfo.selection());
int totalCost = size.width() * size.height() / 100;
if (totalCost == 0) totalCost = 1;
int currentProgress = 0;
const KoColorSpace * cs = src->colorSpace();
qint32 pixelsize = cs->pixelSize();
quint8* color = new quint8[pixelsize];
cs->fromQColor(cTA, color);
while (! srcIt.isDone()) {
if (srcIt.isSelected()) {
quint8 d = cs->difference(color, srcIt.oldRawData());
qreal newOpacity; // = cs->opacityF(srcIt.rawData());
if (d >= threshold) {
newOpacity = 1.0;
} else {
newOpacity = d / thresholdF;
}
memcpy(dstIt.rawData(), srcIt.rawData(), pixelsize);
if(newOpacity < cs->opacityF(srcIt.rawData()))
{
cs->setOpacity(dstIt.rawData(), newOpacity, 1);
}
}
if (progressUpdater) progressUpdater->setProgress((++currentProgress) / totalCost);
++srcIt;
++dstIt;
}
delete[] color;
}