【问题标题】:Convert binary from ms access into Image for Imagelist将二进制从 ms 访问转换为 Image for Imagelist
【发布时间】:2012-03-27 01:56:19
【问题描述】:

我刚刚将位图缩略图转换为二进制代码以存储到我的 MS Access 数据库中。我现在正在尝试将该二进制数据转换回图像格式以存储到我的 Imagelist 中。我现在的代码是。

private void Form1_Load(object sender, EventArgs e)
    {
        vcon.Open();
        string get = "Select Path, Images FROM IMGSTR";
        OleDbCommand cmdget = new OleDbCommand(get, vcon);
        OleDbDataReader reader;
        reader = cmdget.ExecuteReader();

        while (reader.Read())
        {
            string path = reader["Path"].ToString();

            // should I convert binary into a string?
            string thumbnail = reader["Images"].ToString();

            // How to convert the binary data from the
            // MS database back to a bitmap image.

            //I need to convert the binary back to bitmap to work
            //in this imagelist.
            this.imageList1.Images.Add(thumbnail);

        }



    }

如果有人可以帮助我,那就太好了。谢谢!

【问题讨论】:

    标签: c# image ms-access bitmap binary


    【解决方案1】:

    您需要将其转换为字节数组:

    Image.FromStream(new MemoryStream((byte[]) reader["Images"]))
    

    【讨论】:

      猜你喜欢
      • 2012-04-10
      • 2015-03-19
      • 1970-01-01
      • 2016-10-02
      • 2020-04-28
      • 2020-06-28
      • 2015-04-24
      • 1970-01-01
      相关资源
      最近更新 更多