How do I load and save an image from an SQL Server database using GDI+ and C++?

前端 未结 2 859
别跟我提以往
别跟我提以往 2021-01-13 19:24

I need specifically to load a JPG image that was saved as a blob. GDI+ makes it very easy to retrieve images from files but not from databases...

2条回答
  •  孤城傲影
    2021-01-13 19:33

    First fetch your blog into a byte array then use something like this:

    public static Image CreateImage(byte[] pict)
    {
       System.Drawing.Image img = null;
       using (System.IO.MemoryStream stream = new System.IO.MemoryStream(pict)) {
        img = System.Drawing.Image.FromStream(stream);
       }
       return img;
    }
    

提交回复
热议问题