locked
RenderTargetBitmap, WriteableBitmap,BitmapImage

    Question

  • Objects: RenderTargetBitmap, WriteableBitmap,BitmapImage

    I'm confused how these objects interact. Like are they cast or converted from one another. This would be beneficial as each seems to provide different functionality that when used together can accomplish more complicated tasks.

    The specific part I'm getting stuck is after I successfully render XAML to a "RenderTargetBitmap", I then want a "WriteableBitmap" version of that. I don't know how to go from a RenderTargetBitmap to a Writeablebitmap. I don't even know if its a cast, copying an underlying property value, or having to copy the pixels between the two. I want the writeable bitmap because it appears to do things the RenderTargetBitmap does not.

    I have looked for help, but it always seems to just confuse the issue more as I seem to be finding examples that are NET but not the type for windows store.

    A helpful example for me would be a function that takes a "RenderTargetBitmap" and returns a "WriteableBitmap" written in VB NET for Windows store.

    Thank you.


    • Edited by RamboBill Wednesday, March 26, 2014 12:23 AM Put bold heading on so its clearer what I'm talking about.
    Wednesday, March 26, 2014 12:22 AM

Answers

  • I think that I found the answer is they are not easily convertible. I accomplished converting them by reading the pixel data from one and then writing that pixel data into the other type. Seems like a long way around, but I think that it's the only available route.
    • Marked as answer by RamboBill Wednesday, March 26, 2014 6:00 PM
    Wednesday, March 26, 2014 6:00 PM

All replies

  • I think that I found the answer is they are not easily convertible. I accomplished converting them by reading the pixel data from one and then writing that pixel data into the other type. Seems like a long way around, but I think that it's the only available route.
    • Marked as answer by RamboBill Wednesday, March 26, 2014 6:00 PM
    Wednesday, March 26, 2014 6:00 PM
  • You can do this by using Nokia Imaging SDK.

    RenderTargetBitmap UIBitmap = new RenderTargetBitmap();
    await UIBitmap.RenderAsync(Canvas);
    var pixelBuffer = await UIBitmap.GetPixelsAsync();
    using(var source = new StreamImageSource(pixelBuffer.AsStream()))
    using (var renderer = new WriteableBitmapRenderer(source, writeableBitmap))
    {
        await renderer.RenderAsync();
    }


    Clipr : Best ever clipping tool in Windows Phone!
    Download here

    Wednesday, October 29, 2014 8:18 AM