Decoding base64 Stream to image

前端 未结 2 919
夕颜
夕颜 2020-12-31 09:05

I am sending base64 encoded image from client side using javascript (I am creating Screenshot uploader applet for asp.net application using http://supa.sourceforge.net/) and

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 09:30

    First, you need to convert the base 64 back into bytes:

    byte[] data = System.Convert.FromBase64String(fromBase64);
    

    Then, you can load it into an instance of Image:

    MemoryStream ms = new MemoryStream(data);
    Image img = Image.FromStream(ms);
    

    If you want to save it to a file instead, use System.IO.File.WriteAllBytes

提交回复
热议问题