void ContentAwareResizeTool::prepareEffect() { if (d->prevW != d->wInput->value() || d->prevH != d->hInput->value() || d->prevWP != d->wpInput->value() || d->prevHP != d->hpInput->value()) { slotValuesChanged(); } disableSettings(); ImageIface* iface = d->previewWidget->imageIface(); int w = iface->previewWidth(); int h = iface->previewHeight(); DImg imTemp = iface->getOriginalImg()->smoothScale(w, h, Qt::KeepAspectRatio); int new_w = (int)(w*d->wpInput->value()/100.0); int new_h = (int)(h*d->hpInput->value()/100.0); if (d->mixedRescaleInput->value()<100.0) // mixed rescale { double stdRescaleP = (100.0 - d->mixedRescaleInput->value()) / 100.0; int diff_w = (int)(stdRescaleP * (w - new_w)); int diff_h = (int)(stdRescaleP * (h - new_h)); imTemp.resize(imTemp.width() - diff_w, imTemp.height() - diff_h); } QImage mask; if (d->weightMaskBox->isChecked()) { mask = d->previewWidget->getMask(); } contentAwareResizeCore(&imTemp, new_w, new_h, mask); }
void DImgBuiltinFilter::apply(DImg& image) const { switch (m_type) { case NoOperation: break; case Rotate90: image.rotate(DImg::ROT90); break; case Rotate180: image.rotate(DImg::ROT180); break; case Rotate270: image.rotate(DImg::ROT270); break; case FlipHorizontally: image.flip(DImg::HORIZONTAL); break; case FlipVertically: image.flip(DImg::VERTICAL); break; case Crop: image.crop(m_arg.toRect()); break; case Resize: { QSize s = m_arg.toSize(); image.resize(s.width(), s.height()); break; } case ConvertTo8Bit: image.convertToEightBit(); break; case ConvertTo16Bit: image.convertToSixteenBit(); break; } }