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 KisFilterConfiguration * 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; }
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; }
KisFilterConfiguration* KisFilterOpSettings::filterConfig() const { if (hasProperty(FILTER_ID)) { KisFilterSP filter = KisFilterRegistry::instance()->get(getString(FILTER_ID)); if (filter) { KisFilterConfiguration* configuration = filter->factoryConfiguration(0); configuration->fromXML(getString(FILTER_CONFIGURATION)); return configuration; } } return 0; }
void KisFilterConfigurationTest::testRoundTrip() { KisFilterConfiguration * kfc = new KisFilterConfiguration("test", 1); QCOMPARE(kfc->version(), 1); QCOMPARE(kfc->name(), QString("test")); QString s = kfc->toXML(); delete kfc; kfc = new KisFilterConfiguration("test2", 2); kfc->fromXML(s); QCOMPARE(kfc->version(), 1); delete kfc; }
void KisFilterOpSettings::fromXML(const QDomElement& e) { KisPaintOpSettings::fromXML(e); QDomElement element = e.firstChildElement("filterconfig"); if (hasProperty(FILTER_ID)) { KisFilterSP filter = KisFilterRegistry::instance()->get(getString(FILTER_ID)); if (filter) { KisFilterConfiguration* configuration = filter->factoryConfiguration(0); configuration->fromXML(element); setProperty(FILTER_CONFIGURATION, configuration->toXML()); delete configuration; } } }
void KisFilterConfigurationTest::testSetGetProperty() { KisFilterConfiguration * kfc = new KisFilterConfiguration("test", 1); kfc->setProperty("value1", 10); kfc->setProperty("value2", "foo"); QCOMPARE(kfc->getInt("value1"), 10); QCOMPARE(kfc->getString("value2"), QString("foo")); QString s = kfc->toXML(); delete kfc; kfc = new KisFilterConfiguration("test2", 2); kfc->fromXML(s); QCOMPARE(kfc->getInt("value1"), 10); QCOMPARE(kfc->getString("value2"), QString("foo")); delete kfc; }
KisRecordedAction* KisRecordedFilterActionFactory::fromXML(const QDomElement& elt, const KisRecordedActionLoadContext*) { QString name = elt.attribute("name"); KisNodeQueryPath pathnode = KisNodeQueryPath::fromString(elt.attribute("path")); const KisFilterSP filter = KisFilterRegistry::instance()->get(elt.attribute("filter")); if (filter) { KisFilterConfiguration* config = filter->defaultConfiguration(0); QDomElement paramsElt = elt.firstChildElement("Params"); if (config && !paramsElt.isNull()) { config->fromXML(paramsElt); } KisRecordedFilterAction* rfa = new KisRecordedFilterAction(name, pathnode, filter, config); delete config; return rfa; } else { return 0; } }
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); } }