本文整理汇总了C++中KisFilterSP::process方法的典型用法代码示例。如果您正苦于以下问题:C++ KisFilterSP::process方法的具体用法?C++ KisFilterSP::process怎么用?C++ KisFilterSP::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisFilterSP
的用法示例。
在下文中一共展示了KisFilterSP::process方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFilter
bool KisCrashFilterTest::applyFilter(const KoColorSpace * cs, KisFilterSP f)
{
QImage qimage(QString(FILES_DATA_DIR) + QDir::separator() + "carrot.png");
KisPaintDeviceSP dev = new KisPaintDevice(cs);
// dev->fill(0, 0, 100, 100, dev->defaultPixel());
dev->convertFromQImage(qimage, 0, 0, 0);
// Get the predefined configuration from a file
KisFilterConfigurationSP kfc = f->defaultConfiguration(dev);
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + f->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
dbgKrita << "creating new file for " << f->id();
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out.setCodec("UTF-8");
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
in.setCodec("UTF-8");
s = in.readAll();
kfc->fromXML(s);
}
dbgKrita << f->id() << ", " << cs->id() << ", " << cs->profile()->name();// << kfc->toXML() << "\n";
f->process(dev, QRect(QPoint(0,0), qimage.size()), kfc);
return true;
}
示例2: testWithProgressUpdater
void KisFilterTest::testWithProgressUpdater()
{
TestUtil::TestProgressBar * bar = new TestUtil::TestProgressBar();
KoProgressUpdater* pu = new KoProgressUpdater(bar);
KoUpdaterPtr updater = pu->startSubtask();
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, updater);
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());
}
delete pu;
delete bar;
}
示例3: applyFilter
bool applyFilter(const KoColorSpace * cs, KisFilterSP f)
{
QImage qimage(QString(FILES_DATA_DIR) + QDir::separator() + "lena.png");
KisPaintDeviceSP dev = new KisPaintDevice(cs);
// dev->fill(0, 0, 100, 100, dev->defaultPixel());
dev->convertFromQImage(qimage, "", 0, 0);
// Get the predefined configuration from a file
KisFilterConfiguration * kfc = f->defaultConfiguration(dev);
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + f->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "creating new file for " << f->id();
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
s = in.readAll();
kfc->fromXML(s);
}
qDebug() << f->id() << ", " << cs->id() << ", " << cs->profile()->name();// << kfc->toXML() << "\n";
KisConstProcessingInformation src(dev, QPoint(0, 0), 0);
KisProcessingInformation dst(dev, QPoint(0, 0), 0);
f->process(src, dst, qimage.size(), kfc);
return true;
}
示例4: testDifferentSrcAndDst
void KisFilterTest::testDifferentSrcAndDst()
{
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 src = new KisPaintDevice(cs);
KisPaintDeviceSP dst = new KisPaintDevice(cs);
KisSelectionSP sel = new KisSelection(new KisSelectionDefaultBounds(src));
sel->getOrCreatePixelSelection()->invert(); // select everything
sel->updateProjection();
src->convertFromQImage(qimage, 0, 0, 0);
KisFilterSP f = KisFilterRegistry::instance()->value("invert");
Q_ASSERT(f);
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT(kfc);
f->process(src, dst, sel, QRect(QPoint(0,0), qimage.size()), kfc);
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, inverted, dst->convertToQImage(0, 0, 0, qimage.width(), qimage.height()))) {
dst->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());
}
}
示例5: benchmarkFilter
void KisLevelFilterBenchmark::benchmarkFilter()
{
KisFilterSP filter = KisFilterRegistry::instance()->value("levels");
//KisFilterConfigurationSP kfc = filter->defaultConfiguration(m_device);
KisColorTransformationConfiguration * kfc= new KisColorTransformationConfiguration("levels", 1);
kfc->setProperty("blackvalue", 75);
kfc->setProperty("whitevalue", 231);
kfc->setProperty("gammavalue", 1.0);
kfc->setProperty("outblackvalue", 0);
kfc->setProperty("outwhitevalue", 255);
// Get the predefined configuration from a file
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + filter->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out.setCodec("UTF-8");
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
in.setCodec("UTF-8");
s = in.readAll();
kfc->fromXML(s);
}
QSize size = KritaUtils::optimalPatchSize();
QVector<QRect> rects = KritaUtils::splitRectIntoPatches(QRect(0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), size);
QBENCHMARK{
Q_FOREACH (const QRect &rc, rects) {
filter->process(m_device, rc, kfc);
}
}
示例6: benchmarkFilter
void KisBContrastBenchmark::benchmarkFilter()
{
KisFilterSP filter = KisFilterRegistry::instance()->value("brightnesscontrast");
KisFilterConfigurationSP kfc = filter->defaultConfiguration(m_device);
// Get the predefined configuration from a file
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + filter->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out.setCodec("UTF-8");
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
in.setCodec("UTF-8");
s = in.readAll();
kfc->fromXML(s);
}
QSize size = KritaUtils::optimalPatchSize();
QVector<QRect> rects = KritaUtils::splitRectIntoPatches(QRect(0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), size);
QBENCHMARK{
Q_FOREACH (const QRect &rc, rects) {
filter->process(m_device, rc, kfc);
}
}
示例7: decorateRect
QRect KisFilterMask::decorateRect(KisPaintDeviceSP &src,
KisPaintDeviceSP &dst,
const QRect & rc,
PositionToFilthy maskPos) const
{
Q_UNUSED(maskPos);
KisSafeFilterConfigurationSP filterConfig = filter();
Q_ASSERT(nodeProgressProxy());
Q_ASSERT_X(src != dst, "KisFilterMask::decorateRect",
"src must be != dst, because we cant create transactions "
"during merge, as it breaks reentrancy");
if (!filterConfig) {
return QRect();
}
KisFilterSP filter =
KisFilterRegistry::instance()->value(filterConfig->name());
if (!filter) {
warnKrita << "Could not retrieve filter \"" << filterConfig->name() << "\"";
return QRect();
}
KIS_ASSERT_RECOVER_NOOP(this->busyProgressIndicator());
this->busyProgressIndicator()->update();
filter->process(src, dst, 0, rc, filterConfig.data(), 0);
QRect r = filter->changedRect(rc, filterConfig.data(), dst->defaultBounds()->currentLevelOfDetail());
return r;
}
示例8: testOldDataApiAfterCopy
void KisFilterTest::testOldDataApiAfterCopy()
{
QRect updateRect(0,0,63,63);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
quint8 *whitePixel = new quint8[cs->pixelSize()];
cs->fromQColor(Qt::white, whitePixel);
cs->setOpacity(whitePixel, OPACITY_OPAQUE_U8, 1);
KisPaintDeviceSP tmp = new KisPaintDevice(cs);
KisPaintDeviceSP src = new KisPaintDevice(cs);
src->fill(0, 0, 50, 50, whitePixel);
/**
* Make a full copy here to catch the bug.
* Buggy memento manager would make a commit
* that is not good.
*/
KisPaintDeviceSP dst = new KisPaintDevice(*src);
/**
* This would write go to a new revision in a buggy
* memento manager
*/
dst->clear(updateRect);
KisFilterSP f = KisFilterRegistry::instance()->value("invert");
Q_ASSERT(f);
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT(kfc);
/**
* This filter reads from oldRawData, so if we have some
* weirdness with transactions it will read from old and non-cleared
* version of the device and we will see a black square instead
* of empty device in tmp
*/
f->process(dst, tmp, 0, updateRect, kfc);
/**
* In theory, both devices: dst and tmp must be empty by now
*/
KisPaintDeviceSP reference = new KisPaintDevice(cs);
QImage refImage = reference->convertToQImage(0,0,0,63,63);
QImage dstImage = dst->convertToQImage(0,0,0,63,63);
QImage tmpImage = tmp->convertToQImage(0,0,0,63,63);
QPoint pt;
QVERIFY(TestUtil::compareQImages(pt, refImage, dstImage));
QVERIFY(TestUtil::compareQImages(pt, refImage, tmpImage));
}
示例9: testBlurFilterApplicationRect
void KisFilterTest::testBlurFilterApplicationRect()
{
QRect filterRect(10,10,40,40);
QRect src1Rect(5,5,50,50);
QRect src2Rect(0,0,60,60);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
quint8 *whitePixel = new quint8[cs->pixelSize()];
cs->fromQColor(Qt::white, whitePixel);
cs->setOpacity(whitePixel, OPACITY_OPAQUE_U8, 1);
KisPaintDeviceSP src1 = new KisPaintDevice(cs);
src1->fill(src1Rect.left(),src1Rect.top(),src1Rect.width(),src1Rect.height(), whitePixel);
KisPaintDeviceSP src2 = new KisPaintDevice(cs);
src2->fill(src2Rect.left(),src2Rect.top(),src2Rect.width(),src2Rect.height(), whitePixel);
KisPaintDeviceSP dst1 = new KisPaintDevice(cs);
KisPaintDeviceSP dst2 = new KisPaintDevice(cs);
KisFilterSP f = KisFilterRegistry::instance()->value("blur");
Q_ASSERT(f);
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT(kfc);
f->process(src1, dst1, 0, filterRect, kfc);
f->process(src2, dst2, 0, filterRect, kfc);
KisPaintDeviceSP reference = new KisPaintDevice(cs);
reference->fill(filterRect.left(),filterRect.top(),filterRect.width(),filterRect.height(), whitePixel);
QImage refImage = reference->convertToQImage(0,10,10,40,40);
QImage dst1Image = dst1->convertToQImage(0,10,10,40,40);
QImage dst2Image = dst2->convertToQImage(0,10,10,40,40);
//dst1Image.save("DST1.png");
//dst2Image.save("DST2.png");
QPoint pt;
QVERIFY(TestUtil::compareQImages(pt, refImage, dst1Image));
QVERIFY(TestUtil::compareQImages(pt, refImage, dst2Image));
}
示例10: benchmarkFilter
void KisBlurBenchmark::benchmarkFilter()
{
KisFilterSP filter = KisFilterRegistry::instance()->value("blur");
KisFilterConfiguration * kfc = filter->defaultConfiguration(m_device);
// Get the predefined configuration from a file
QFile file(QString(FILES_DATA_DIR) + QDir::separator() + filter->id() + ".cfg");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << kfc->toXML();
} else {
QString s;
QTextStream in(&file);
s = in.readAll();
kfc->fromXML(s);
}
QBENCHMARK{
filter->process(m_device, QRect(0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), kfc);
}
}