void ResizeTool::putPreviewData() { ImageIface* iface = d->previewWidget->imageIface(); int w = iface->previewWidth(); int h = iface->previewHeight(); DImg imTemp = filter()->getTargetImage().smoothScale(w, h, Qt::KeepAspectRatio); DImg imDest(w, h, filter()->getTargetImage().sixteenBit(), filter()->getTargetImage().hasAlpha()); QColor background = toolView()->backgroundRole(); imDest.fill(DColor(background, filter()->getTargetImage().sixteenBit())); imDest.bitBltImage(&imTemp, (w-imTemp.width())/2, (h-imTemp.height())/2); iface->putPreviewImage((imDest.smoothScale(iface->previewWidth(), iface->previewHeight())).bits()); d->previewWidget->updatePreview(); }
void ResizeTool::prepareEffect() { if (d->prevW != d->wInput->value() || d->prevH != d->hInput->value() || d->prevWP != d->wpInput->value() || d->prevHP != d->hpInput->value()) { slotValuesChanged(); } 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->useGreycstorationBox->isChecked()) { setFilter(new GreycstorationFilter(&imTemp, d->settingsWidget->settings(), GreycstorationFilter::Resize, new_w, new_h, QImage(), this)); } else { // See B.K.O #152192: CImg resize() sound like defective or unadapted // to resize image without good quality. DImgBuiltinFilter resize(DImgBuiltinFilter::Resize, QSize(new_w, new_h)); setFilter(resize.createThreadedFilter(&imTemp, this)); } }
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 RainDropTool::putPreviewData() { ImageIface* iface = d->previewWidget->imageIface(); DImg imDest = filter()->getTargetImage().smoothScale(iface->previewWidth(), iface->previewHeight()); iface->putPreviewImage(imDest.bits()); d->previewWidget->updatePreview(); }