本文整理汇总了C++中KisFilterSP::defaultConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C++ KisFilterSP::defaultConfiguration方法的具体用法?C++ KisFilterSP::defaultConfiguration怎么用?C++ KisFilterSP::defaultConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisFilterSP
的用法示例。
在下文中一共展示了KisFilterSP::defaultConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: testProjectionSelected
void KisFilterMaskTest::testProjectionSelected()
{
KisImageSP image;
KisPaintLayerSP layer;
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");
KisFilterSP f = KisFilterRegistry::instance()->value("invert");
Q_ASSERT(f);
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT(kfc);
KisFilterMaskSP mask = new KisFilterMask();
mask->setFilter(kfc);
mask->createNodeProgressProxy();
KisPaintDeviceSP projection = new KisPaintDevice(cs);
initImage(image, layer, projection, mask);
projection->convertFromQImage(qimage, 0, 0, 0);
mask->initSelection(layer);
mask->select(qimage.rect(), MAX_SELECTED);
mask->apply(projection, qimage.rect(), qimage.rect(), KisNode::N_FILTHY);
QCOMPARE(mask->exactBounds(), QRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT));
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, inverted, projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()))) {
projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()).save("filtermasktest2.png");
QFAIL(QString("Failed to create inverted image, first different pixel: %1,%2 ").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
}
}
示例3: 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);
}
}
示例4: loadAdjustmentLayer
KisNodeSP KisKraLoader::loadAdjustmentLayer(const KoXmlElement& element, KisImageWSP image,
const QString& name, const KoColorSpace* cs, quint32 opacity)
{
// XXX: do something with filterversion?
Q_UNUSED(cs);
QString attr;
KisAdjustmentLayer* layer;
QString filtername;
if ((filtername = element.attribute(FILTER_NAME)).isNull()) {
// XXX: Invalid adjustmentlayer! We should warn about it!
warnFile << "No filter in adjustment layer";
return 0;
}
KisFilterSP f = KisFilterRegistry::instance()->value(filtername);
if (!f) {
warnFile << "No filter for filtername" << filtername << "";
return 0; // XXX: We don't have this filter. We should warn about it!
}
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
// We'll load the configuration and the selection later.
layer = new KisAdjustmentLayer(image, name, kfc, 0);
Q_CHECK_PTR(layer);
layer->setOpacity(opacity);
return layer;
}
示例5: loadFilterMask
KisNodeSP KisKraLoader::loadFilterMask(const KoXmlElement& element, KisNodeSP parent)
{
Q_UNUSED(parent);
QString attr;
KisFilterMask* mask;
QString filtername;
// XXX: should we check the version?
if ((filtername = element.attribute(FILTER_NAME)).isNull()) {
// XXX: Invalid filter layer! We should warn about it!
warnFile << "No filter in filter layer";
return 0;
}
KisFilterSP f = KisFilterRegistry::instance()->value(filtername);
if (!f) {
warnFile << "No filter for filtername" << filtername << "";
return 0; // XXX: We don't have this filter. We should warn about it!
}
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
// We'll load the configuration and the selection later.
mask = new KisFilterMask();
mask->setFilter(kfc);
Q_CHECK_PTR(mask);
return mask;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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());
}
}
示例9: 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));
}
示例10: testChecksum
void KisSimpleUpdateQueueTest::testChecksum()
{
QRect imageRect(0,0,512,512);
QRect dirtyRect(100,100,100,100);
const KoColorSpace * colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, imageRect.width(), imageRect.height(), colorSpace, "test");
KisLayerSP paintLayer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8);
KisAdjustmentLayerSP adjustmentLayer = new KisAdjustmentLayer(image, "adj", 0, 0);
image->lock();
image->addNode(paintLayer1, image->rootLayer());
image->addNode(adjustmentLayer, image->rootLayer());
image->unlock();
KisFilterSP filter = KisFilterRegistry::instance()->value("blur");
Q_ASSERT(filter);
KisFilterConfiguration *configuration = filter->defaultConfiguration(0);
KisTestableSimpleUpdateQueue queue;
KisWalkersList& walkersList = queue.getWalkersList();
{
TestUtil::LodOverride l(1, image);
queue.addUpdateJob(adjustmentLayer, dirtyRect, imageRect, 1);
QCOMPARE(walkersList[0]->checksumValid(), true);
QCOMPARE(walkersList[0]->levelOfDetail(), 1);
}
adjustmentLayer->setFilter(configuration);
{
TestUtil::LodOverride l(1, image);
QCOMPARE(walkersList[0]->checksumValid(), false);
}
QVector<KisUpdateJobItem*> jobs;
KisTestableUpdaterContext context(2);
{
TestUtil::LodOverride l(1, image);
queue.processQueue(context);
}
jobs = context.getJobs();
{
TestUtil::LodOverride l(1, image);
QCOMPARE(jobs[0]->walker()->checksumValid(), true);
}
}
示例11: createStroke
KisStrokeStrategy* createStroke(bool indirectPainting,
KisResourcesSnapshotSP resources,
KisImageWSP image) {
Q_UNUSED(image);
Q_UNUSED(indirectPainting);
KisFilterSP filter = KisFilterRegistry::instance()->value(m_filterName);
Q_ASSERT(filter);
KisFilterConfiguration *filterConfig = filter->defaultConfiguration(0);
Q_ASSERT(filterConfig);
return new KisFilterStrokeStrategy(filter, KisSafeFilterConfigurationSP(filterConfig), resources);
}
示例12: 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));
}
示例13: 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);
}
}
示例14: testConvertImageColorSpace
void KisImageTest::testConvertImageColorSpace()
{
const KoColorSpace *cs8 = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, 1000, 1000, cs8, "stest");
KisPaintDeviceSP device1 = new KisPaintDevice(cs8);
KisLayerSP paint1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8, device1);
KisFilterSP filter = KisFilterRegistry::instance()->value("blur");
Q_ASSERT(filter);
KisFilterConfiguration *configuration = filter->defaultConfiguration(0);
Q_ASSERT(configuration);
KisLayerSP blur1 = new KisAdjustmentLayer(image, "blur1", configuration, 0);
image->addNode(paint1, image->root());
image->addNode(blur1, image->root());
image->refreshGraph();
const KoColorSpace *cs16 = KoColorSpaceRegistry::instance()->rgb16();
image->lock();
image->convertImageColorSpace(cs16,
KoColorConversionTransformation::InternalRenderingIntent,
KoColorConversionTransformation::InternalConversionFlags);
image->unlock();
QVERIFY(*cs16 == *image->colorSpace());
QVERIFY(*cs16 == *image->root()->colorSpace());
QVERIFY(*cs16 == *paint1->colorSpace());
QVERIFY(*cs16 == *blur1->colorSpace());
QVERIFY(!image->root()->compositeOp());
QVERIFY(*cs16 == *paint1->compositeOp()->colorSpace());
QVERIFY(*cs16 == *blur1->compositeOp()->colorSpace());
image->refreshGraph();
}
示例15: testFullRefreshWithClones
void KisAsyncMergerTest::testFullRefreshWithClones()
{
const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, 128, 128, colorSpace, "clones test");
KisPaintDeviceSP device1 = new KisPaintDevice(colorSpace);
device1->fill(image->bounds(), KoColor( Qt::white, colorSpace));
KisFilterSP filter = KisFilterRegistry::instance()->value("invert");
Q_ASSERT(filter);
KisFilterConfiguration *configuration = filter->defaultConfiguration(0);
Q_ASSERT(configuration);
KisLayerSP paintLayer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8, device1);
KisFilterMaskSP invertMask1 = new KisFilterMask();
invertMask1->initSelection(0, paintLayer1);
invertMask1->setFilter(configuration);
KisLayerSP cloneLayer1 = new KisCloneLayer(paintLayer1, image, "clone_of_1", OPACITY_OPAQUE_U8);
/**
* The clone layer must have a projection to allow us
* to read what it got from its source. Just shift it.
*/
cloneLayer1->setX(10);
cloneLayer1->setY(10);
image->addNode(cloneLayer1, image->rootLayer());
image->addNode(paintLayer1, image->rootLayer());
image->addNode(invertMask1, paintLayer1);
QRect cropRect(image->bounds());
KisFullRefreshWalker walker(cropRect);
KisAsyncMerger merger;
walker.collectRects(image->rootLayer(), image->bounds());
merger.startMerge(walker);
// Wait for additional jobs generated by the clone are finished
image->waitForDone();
QRect filledRect(10, 10,
image->width() - cloneLayer1->x(),
image->height() - cloneLayer1->y());
const int pixelSize = device1->pixelSize();
const int numPixels = filledRect.width() * filledRect.height();
QByteArray bytes(numPixels * pixelSize, 13);
cloneLayer1->projection()->readBytes((quint8*)bytes.data(), filledRect);
KoColor desiredPixel(Qt::black, colorSpace);
quint8 *srcPtr = (quint8*)bytes.data();
quint8 *dstPtr = desiredPixel.data();
for(int i = 0; i < numPixels; i++) {
if(memcmp(srcPtr, dstPtr, pixelSize)) {
qDebug() << "expected:" << dstPtr[0] << dstPtr[1] << dstPtr[2] << dstPtr[3];
qDebug() << "result: " << srcPtr[0] << srcPtr[1] << srcPtr[2] << srcPtr[3];
QFAIL("Failed to compare pixels");
}
srcPtr += pixelSize;
}
}