怎么用c#存储显示图象数据! using System.Drawing.Imaginghttp://www.c-sharpcorner.com/winforms/ImageViewerST.asp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Bitmap image=new Bitmap(this.Width,this.Height);Graphics gimage=Graphics.FromImage(image);gimage.Clear(this.BackColor);//gimage.draw...image.Save("MyDrawing.jpg",ImageFormat.Jpeg); 要存到数据库里,然后可以提出来,谢谢啊,我用的是sqlserver 呵呵,果然加分了下面是我的一个小程序的代码,你按你的需要改一下就可以了//读取图片字段private void ReadPic(){ if (this.BindingContext[sqlDTS,curDaTbl.TableName].Position<0) return; SqlConnection sqlConn = new SqlConnection(cmnLib.GetSqlCnn()); string strQry="select 照片 from CarInfo where 车牌号码='"+this.txt车牌号码.Text+"'"; SqlCommand sqlCmd = new SqlCommand(strQry, sqlConn); object tmpPhoto=null; try { sqlConn.Open(); tmpPhoto=sqlCmd.ExecuteScalar(); sqlConn.Close(); } catch (Exception exp) { cmnLib.ShowMsg(exp.Message,3); } if (tmpPhoto==DBNull.Value) { picCar.Image=null; return; } try { //BLOB is read into Byte array, then used to construct MemoryStream, //then passed to PictureBox. Byte[] byteBLOBData = new Byte[0]; byteBLOBData = (Byte[])tmpPhoto; MemoryStream stmBLOBData = new MemoryStream(byteBLOBData); picCar.Image= Image.FromStream(stmBLOBData); } catch(Exception ex) { cmnLib.ShowMsg(ex.Message); }} C# 文本框问题 DataGrid上的数据导入到Excel的时候 C# 调用DLL问题 菜菜小问题 关于贪吃蛇 求一个测试题答案和解释 重要的是解释 如何在一个DataTable中得到特定id的所有Children? 文件读写可以可以插入吗? 通过反射遍历dll中所有类的属性默认值和常量值呢 WPF,ToolTip工具提示的位置怎么没对啊 C# 中是否允许一个类同时继承多个父类? 可以继承BUTTON创建USER_CONTROL吗? 谁有asp.net C# 读写excel的实例?
Graphics gimage=Graphics.FromImage(image);
gimage.Clear(this.BackColor);
//gimage.draw...
image.Save("MyDrawing.jpg",ImageFormat.Jpeg);
下面是我的一个小程序的代码,你按你的需要改一下就可以了//读取图片字段
private void ReadPic()
{
if (this.BindingContext[sqlDTS,curDaTbl.TableName].Position<0)
return; SqlConnection sqlConn = new SqlConnection(cmnLib.GetSqlCnn());
string strQry="select 照片 from CarInfo where 车牌号码='"+this.txt车牌号码.Text+"'";
SqlCommand sqlCmd = new SqlCommand(strQry, sqlConn);
object tmpPhoto=null; try
{
sqlConn.Open();
tmpPhoto=sqlCmd.ExecuteScalar();
sqlConn.Close();
}
catch (Exception exp)
{
cmnLib.ShowMsg(exp.Message,3);
} if (tmpPhoto==DBNull.Value)
{
picCar.Image=null;
return;
} try
{
//BLOB is read into Byte array, then used to construct MemoryStream,
//then passed to PictureBox.
Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])tmpPhoto;
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
picCar.Image= Image.FromStream(stmBLOBData);
}
catch(Exception ex)
{
cmnLib.ShowMsg(ex.Message);
}
}