Exemple #1
0
void RawImport::setPreviewImage()
{
    // Preserve metadata from loaded image, and take post-processed image data
    d->postProcessedImage = d->previewWidget->demosaicedImage().copyMetaData();
    DImg data             = filter()->getTargetImage();
    d->postProcessedImage.putImageData(data.width(), data.height(), data.sixteenBit(), data.hasAlpha(),
                                       data.stripImageData(), false);
    d->previewWidget->setPostProcessedImage(d->postProcessedImage);
    d->settingsBox->setPostProcessedImage(d->postProcessedImage);
    EditorToolIface::editorToolIface()->setToolStopProgress();
    setBusy(false);
}
Exemple #2
0
uchar* ImageIface::Private::previewImageData()
{
    if (previewImage.isNull())
    {
        DImg* im = 0;

        if (previewType == FullImage)
        {
            im = core->getImg();

            if (!im || im->isNull())
            {
                return 0;
            }
        }
        else  // ImageSelection
        {
            im = new DImg(core->getImgSelection());

            if (!im)
            {
                return 0;
            }

            if (im->isNull())
            {
                delete im;
                return 0;
            }

            im->setIccProfile(core->getEmbeddedICC());
        }

        QSize sz(im->width(), im->height());
        sz.scale(constrainWidth, constrainHeight, Qt::KeepAspectRatio);

        previewImage       = im->smoothScale(sz.width(), sz.height());
        previewWidth       = previewImage.width();
        previewHeight      = previewImage.height();

        // only create another copy if needed, in setPreviewImage
        targetPreviewImage = previewImage;

        if (previewType == ImageSelection)
        {
            delete im;
        }
    }

    DImg previewData = previewImage.copyImageData();
    return previewData.stripImageData();
}
Exemple #3
0
bool UndoManager::putImageDataAndHistory(DImg* const img, int stepsBack) const
{
    if (stepsBack <= 0 || stepsBack > d->undoActions.size())
    {
        return false;
    }

    /*
     * We need to find a snapshot, for the state the given number of steps back.
     * 0 steps back is the current state of the EditorCore.
     * 1 step back is the snapshot of the last undo action, at d->undoActions.size() - 1.
     * The next problem is that if the corresponding action is reversible,
     * we do not have a snapshot, but need to walk forward to the first snapshot (or current
     * state), then apply the reversible steps.
     */
    int step = d->undoActions.size() - stepsBack;
    int snapshot;

    for (snapshot = step; snapshot < d->undoActions.size(); ++snapshot)
    {
        if (dynamic_cast<UndoActionIrreversible*>(d->undoActions.at(snapshot)))
        {
            break;
        }
    }

    if (snapshot == step)
    {
        getSnapshot(step, img);
    }
    else
    {
        DImg reverting;

        // Get closest available snapshot
        if (snapshot < d->undoActions.size())
        {
            getSnapshot(snapshot, &reverting);
        }
        else
        {
            reverting = d->core->getImg()->copyImageData();
        }

        // revert reversible actions, until reaching desired step
        for (; snapshot > step; snapshot--)
        {
            UndoActionReversible* const reversible = dynamic_cast<UndoActionReversible*>(d->undoActions.at(snapshot - 1));
            if (!reversible) // would be a bug
            {
                continue;
            }
            reversible->getReverseFilter().apply(reverting);
        }

        img->putImageData(reverting.width(), reverting.height(), reverting.sixteenBit(),
                          reverting.hasAlpha(), reverting.stripImageData(), false);
    }

    // adjust history
    UndoAction* const action             = d->undoActions.at(step);
    UndoMetadataContainer dataBeforeStep = action->getMetadata();
    dataBeforeStep.toImage(*img);

    return true;
}