locked
How to Convert RenderTargetBitmap to WriteableBitmap?

    Question

  • I've tried all possible ways but not successful..

    Below are the methods I've tried

    //1st method
    RenderTargetBitmap UIBitmap = new RenderTargetBitmap();
    await UIBitmap.RenderAsync(Rectangle);
    var pixelBuffer = await UIBitmap.GetPixelsAsync();
    using(var source = new StreamImageSource(pixelBuffer.AsStream()))
    using (var renderer = new WriteableBitmapRenderer(source, writeableBitmap))
    {
        await renderer.RenderAsync();
    }
    
    //2nd Method
    RenderTargetBitmap UIBitmap = new RenderTargetBitmap();
    await UIBitmap.RenderAsync(Rectangle);
    var pixelBuffer = await UIBitmap.GetPixelsAsync();
    
    var wbm = new WriteableBitmap((int)UIBitmap.PixelWidth, (int)UIBitmap.PixelHeight);
    
     wbm.SetSource(pixelBuffer.AsStream().AsRandomAccessStream());
    
    //3rd method
    RenderTargetBitmap UIBitmap = new RenderTargetBitmap();
    await UIBitmap.RenderAsync(Rectangle);
    var pixelBuffer = await UIBitmap.GetPixelsAsync();
    
    var wbm = new WriteableBitmap((int)UIBitmap.PixelWidth, (int)UIBitmap.PixelHeight);
    
    var stream = new MemoryStream();
    pixelBuffer.AsStream().CopyTo(stream);
    
    wbm.SetSource(stream.AsRandomAccessStream())

    Am I doing in a wrong way?


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

    Wednesday, October 29, 2014 9:30 PM

Answers

All replies