microsoft / Lumia-imaging-sdk

Lumia Imaging SDK is a comprehensive set of GPU/CPU imaging tools and effects that run on both mobile and desktop, with high speed and memory efficiency. Samples and extras code are included.
MIT License
75 stars 37 forks source link

How to Undo an effect? #12

Open Monsok opened 8 years ago

Monsok commented 8 years ago

How do I undo an applied effect? I could not find an example in the source code.

davidbozjak commented 8 years ago

There is no concept of "undo", the rendering chain produces an output given an input and the effects in the rendering chain and their parameters. To get a different output simply change the rendering chain and then call RenderAsync() on your renderer again.

Monsok commented 8 years ago

Thanks! Based on your suggestion, I just feed the original image source as IImageProvider and call RenderAsync() again. Something like

    public async Task RenderOriginal(IImageProvider sourceImage)
    {

        if (m_swapChainPanelRenderer == null)
        {
            m_swapChainPanelRenderer = new SwapChainPanelRenderer(sourceImage, SwapChainPanel);
        }
        m_swapChainPanelRenderer.RenderOptions = Lumia.Imaging.RenderOptions.Mixed;
        m_swapChainPanelRenderer.Source = sourceImage;

        await m_swapChainPanelRenderer.RenderAsync().AsTask().ConfigureAwait(false);
    }
davidbozjak commented 8 years ago

Exactly.