void LensAutoFixTool::preparePreview() { // Settings information must be get before to disable settings view. LensFunContainer settings = d->cameraSelector->settings(); d->settingsView->assignFilterSettings(settings); ImageIface* const iface = d->previewWidget->imageIface(); DImg preview = iface->preview(); if (d->showGrid->isChecked()) { QBitmap pattern(9, 9); pattern.clear(); QPainter p1(&pattern); p1.setPen(QPen(Qt::black, 1)); p1.drawLine(5, 0, 5, 9); p1.drawLine(0, 5, 9, 5); p1.end(); QPixmap pix(preview.size()); pix.fill(Qt::transparent); QPainter p2(&pix); p2.setPen(QPen(Qt::gray, 1)); p2.fillRect(0, 0, pix.width(), pix.height(), QBrush(pattern)); p2.end(); DImg grid(pix.toImage()); DColorComposer* const composer = DColorComposer::getComposer(DColorComposer::PorterDuffNone); DColorComposer::MultiplicationFlags flags = DColorComposer::NoMultiplication; // Do alpha blending of template on dest image preview.bitBlendImage(composer, &grid, 0, 0, preview.width(), preview.height(), 0, 0, flags); } setFilter(new LensFunFilter(&preview, this, settings)); }
void DImageFilterActionTest::testActions() { QStringList files = QDir(imagePath()).entryList(QDir::Files); files.removeOne(originalImage()); DImg original(imagePath() + originalImage()); QVERIFY(!original.isNull()); foreach (const QString& fileName, files) { DImg ref(imagePath() + fileName); QVERIFY(!ref.isNull()); DImageHistory history = ref.getImageHistory(); FilterActionFilter filter; filter.setFilterActions(history.allActions()); QVERIFY(filter.isReproducible() || filter.isComplexAction()); filter.setupFilter(original.copy()); filter.startFilterDirectly(); qDebug() << filter.filterActions().size(); DImg img = filter.getTargetImage(); QVERIFY(ref.size() == img.size()); bool isEqual = true; DImg diff(ref.width(), ref.height(), ref.sixteenBit()); diff.fill(DColor(Qt::black)); for (uint x=0; x<ref.width(); x++) { for (uint y=0; y<ref.height(); y++) { DColor cref = ref.getPixelColor(x,y); DColor cres = img.getPixelColor(x,y); if (cref.red() != cres.red() || cref.green() != cres.green() || cref.blue() != cres.blue()) { //qDebug() << x << y; diff.setPixelColor(x,y, DColor(Qt::white)); isEqual = false; } } } if (!isEqual) { showDiff(original, ref, img, diff); } QVERIFY(isEqual); }
void ImageIface::setSelection(const QString& caller, const FilterAction& action, const DImg& img) { if (img.hasAlpha() != originalHasAlpha() || img.sixteenBit() != originalSixteenBit() || img.size() != selectionRect().size() ) { kDebug() << "Properties of image to overwrite selection differs than original image"; return; } if (img.isNull()) { kDebug() << "No image data to handle"; return; } d->core->putImgSelection(caller, action, img); }
void PanIconWidget::setImage(int previewWidth, int previewHeight, const DImg& image) { DImg img = DImg(image).smoothScale(previewWidth, previewHeight, Qt::KeepAspectRatio); setImage(img.copyQImage(), image.size()); }