none
Lumia Image SDK starting from SwapChainPanel

    Question

  • I read an Image into a SwapChainPanel. Now I want to apply a random chain of Effect(s) to that SwapChainPanel (not to the original Image as in the examples provided). How can I define this SwapChainPanel as an IImageProvider ?

    (e.g. once I have flipped the image I want the Antique effect to be applied to flipped image not to original image; that is clearly a very basic question but I cannot find any solution)

    thank you

    Pierre

    Friday, May 13, 2016 9:49 AM

Answers

  • Hi pierresa,
    >>How can I define this SwapChainPanel as an IImageProvider ?(e.g. once I have flipped the image I want the Antique effect to be applied to flipped image not to original image; that is clearly a very basic question but I cannot find any solution)
    You can use the SwapChainPanelRenderer.Source property to get the IImageProvider. You can add the IImageProvider to the AntiqueEffect(IImageProvider) Constructor. 
    You can use SwapChainPanelRenderer(IImageProvider, SwapChainPanel) to create and initialize a new SwapChainPanelRenderer renderer with an image source and a target bitmap. And use SwapChainPanelRenderer.RenderAsync to renders the image source to the swap chain panel. 

    For example:

    When I click the button, I added the FlipEffect to the SwapChainPanelTarget. Then I click the button1, I get the filpped image. We can add it to the AntiqueEffect, and show it to the SwapChainPanel.

    private SwapChainPanelRenderer m_renderer;
    private FlipEffect flipEffect;
    
    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        flipEffect = new FlipEffect(FlipMode.Horizontal);
        var file = await StorageFile.GetFileFromApplicationUriAsync(new System.Uri("ms-appx:///Assets/Ring.jpg"));
        IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read);
        fileStream.Seek(0);
        flipEffect.Source = new Lumia.Imaging.RandomAccessStreamImageSource(fileStream);
        m_renderer = new SwapChainPanelRenderer(flipEffect, SwapChainPanelTarget);
        await m_renderer.RenderAsync();
    }
    
    private async void Button_Click_1(object sender, RoutedEventArgs e)
    {
        var flippedimage = m_renderer.Source;
        AntiqueEffect antiqueEffect = new AntiqueEffect(flippedimage);
        m_renderer = new SwapChainPanelRenderer(antiqueEffect, SwapChainPanelTarget);
        await m_renderer.RenderAsync();
    }
    

    Also there is a sample about Lumia Imaging SDK projects, see https://github.com/Microsoft/Lumia-imaging-sdk.

    Best Regards,
    Jayden Gu

    • Marked as answer by pierresa Monday, May 16, 2016 3:50 PM
    Monday, May 16, 2016 8:25 AM

All replies

  • Hi pierresa,
    >>How can I define this SwapChainPanel as an IImageProvider ?(e.g. once I have flipped the image I want the Antique effect to be applied to flipped image not to original image; that is clearly a very basic question but I cannot find any solution)
    You can use the SwapChainPanelRenderer.Source property to get the IImageProvider. You can add the IImageProvider to the AntiqueEffect(IImageProvider) Constructor. 
    You can use SwapChainPanelRenderer(IImageProvider, SwapChainPanel) to create and initialize a new SwapChainPanelRenderer renderer with an image source and a target bitmap. And use SwapChainPanelRenderer.RenderAsync to renders the image source to the swap chain panel. 

    For example:

    When I click the button, I added the FlipEffect to the SwapChainPanelTarget. Then I click the button1, I get the filpped image. We can add it to the AntiqueEffect, and show it to the SwapChainPanel.

    private SwapChainPanelRenderer m_renderer;
    private FlipEffect flipEffect;
    
    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        flipEffect = new FlipEffect(FlipMode.Horizontal);
        var file = await StorageFile.GetFileFromApplicationUriAsync(new System.Uri("ms-appx:///Assets/Ring.jpg"));
        IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read);
        fileStream.Seek(0);
        flipEffect.Source = new Lumia.Imaging.RandomAccessStreamImageSource(fileStream);
        m_renderer = new SwapChainPanelRenderer(flipEffect, SwapChainPanelTarget);
        await m_renderer.RenderAsync();
    }
    
    private async void Button_Click_1(object sender, RoutedEventArgs e)
    {
        var flippedimage = m_renderer.Source;
        AntiqueEffect antiqueEffect = new AntiqueEffect(flippedimage);
        m_renderer = new SwapChainPanelRenderer(antiqueEffect, SwapChainPanelTarget);
        await m_renderer.RenderAsync();
    }
    

    Also there is a sample about Lumia Imaging SDK projects, see https://github.com/Microsoft/Lumia-imaging-sdk.

    Best Regards,
    Jayden Gu

    • Marked as answer by pierresa Monday, May 16, 2016 3:50 PM
    Monday, May 16, 2016 8:25 AM
  • Thank you. Sorry for stupid beginner question ;-)!

    Monday, May 16, 2016 3:53 PM