Getting an Image object from a byte array

前端 未结 4 1188
Happy的楠姐
Happy的楠姐 2021-02-07 08:37

I\'ve got a byte array for an image (stored in the database). I want to create an Image object, create several Images of different sizes and store them back in the database (sa

4条回答
  •  -上瘾入骨i
    2021-02-07 09:02

    Only answering the first half of the question: Here's a one-liner solution that works fine for me with a byte array that contains an image of a JPEG file.

    Image x = (Bitmap)((new ImageConverter()).ConvertFrom(jpegByteArray));
    

    EDIT: And here's a slightly more advanced solution: https://stackoverflow.com/a/16576471/253938

提交回复
热议问题