【发布时间】:2012-04-09 14:06:41
【问题描述】:
我已将 .jpg 图像转换为位图缩略图。我现在要做的是将该缩略图转换为 MS Access 的 blob。我最近开始学习计算机编程,所以我的代码可能很草率,但是,我现在的代码是:
foreach (String files in Directory.GetFiles(dig.SelectedPath))
{
if (files.EndsWith(".JPG"))
{
//convert .jpg to thumbnail
Image image = new Bitmap(files);
Image pThumbnail = image.GetThumbnailImage(100, 100, null, new IntPtr());
//need code entered here to convert pThumbnail into a byte to be able to convert
//the thumbnail into blob
//To insert thumbnail into access if I can convert into blob
string cmdstr = "INSERT into IMGSTR(Path, Images) values(?, ?)";
OleDbCommand com = new OleDbCommand(cmdstr, vcon);
com.Parameters.AddWithValue("?", files);
com.Parameters.AddWithValue("?", pThumbnail);
com.ExecuteNonQuery();
image.Dispose();
}
}
【问题讨论】:
-
请不要在标题前加上“C# Visual Express”之类的前缀。这就是标签的用途。
标签: c# bitmap blob thumbnails