Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up using FJCore <a href="http://code.google.com/p/fjcore/" rel="nofollow noreferrer">http://code.google.com/p/fjcore/</a> to encode my WriteableBitmap into JPEG and then converted that to BASE64 using code I found at this question <a href="https://stackoverflow.com/questions/1139200/using-fjcore-to-encode-silverlight-writeablebitmap">Using FJCore to encode Silverlight WriteableBitmap</a> THANKS!. Then in turn converted that out to a byte[] array and sent it to MVC using your code and now its working great. I'm pretty new at all this stuff and didn't quite understand the encoding process enough before. Below is the code I used for this. Thanks again for your help!</p> <pre><code> private static string GetBase64Jpg(WriteableBitmap bitmap) { int width = bitmap.PixelWidth; int height = bitmap.PixelHeight; int bands = 3; byte[][,] raster = new byte[bands][,]; for (int i = 0; i &lt; bands; i++) { raster[i] = new byte[width, height]; } for (int row = 0; row &lt; height; row++) { for (int column = 0; column &lt; width; column++) { int pixel = bitmap.Pixels[width * row + column]; raster[0][column, row] = (byte)(pixel &gt;&gt; 16); raster[1][column, row] = (byte)(pixel &gt;&gt; 8); raster[2][column, row] = (byte)pixel; } } ColorModel model = new ColorModel { colorspace = ColorSpace.RGB }; FluxJpeg.Core.Image img = new FluxJpeg.Core.Image(model, raster); MemoryStream stream = new MemoryStream(); JpegEncoder encoder = new JpegEncoder(img, 90, stream); encoder.Encode(); stream.Seek(0, SeekOrigin.Begin); byte[] binaryData = new Byte[stream.Length]; long bytesRead = stream.Read(binaryData, 0, (int)stream.Length); string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); return base64String; } private void SendImage() { var client = new WebClient(); var uri = new Uri("http://localhost:4600/GuestBadge/GetCameraImage"); client.OpenWriteCompleted += (sender, e) =&gt; { var buffer = (byte[])e.UserState; e.Result.Write(buffer, 0, buffer.Length); e.Result.Close(); }; client.OpenWriteAsync(uri, "POST", Convert.FromBase64String(GetBase64Jpg(SnapShot))); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload