ToByteArray() Issue

Oct 15, 2011 at 6:07 AM

 WriteableBitmap bitmap = new WriteableBitmap( 500, 50);

 

 

 

bitmap.Render(uielement, uielement.RenderTransform);

bitmap.Invalidate();

byte[]  arr= ToByteArray(bitmap); // WritableBitmapEx's method

1. Hi my requirement is to capture the image of a UIElement and convert into byte[] and store in database.

2. Then the byte array can be accessed in HTML to display as image.

I am done with the first step, but the converted byte[] cannot be coverted to image in html/aspx.

Thanks.

 

Coordinator
Oct 15, 2011 at 6:40 PM

The ToByteArray returns the raw ARGB data. Your browser expects a jpeg or png format.

I blogged about how to encode a WriteableBitmap as JPEG here  http://kodierer.blogspot.com/2009/11/convert-encode-and-decode-silverlight.html

- Rene Schulte

 

Oct 17, 2011 at 5:18 AM

Ya thanks a lot. This blog is wonderful.