PHOTOSHOP做的事情呀,关注,帮你UP
解决方案 »
- 求助:winform 中datagridview选择部分列(非固定)导出为excel
- 请问一个交集问题
- 大家好,我想问几个关于Oracle Stream AQ的问题。
- 求一验证计算公式是否合法的正则
- win控制台程序,怎么实现按一个特定的键,比如字母“e”,不用打回车,直接退出?
- 安装了VS后不能创建工程。
- vs2008问题
- 关于BYTE[]字节数组处理的问题
- cs文件中更换母版页
- 为什么从一张图片上截取一块后,截取的图片比原图清晰度差了。
- 打包问题:哪里能找到MDAC2.7 我做安装程序要用
- 怎么回事:未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中。
System.Drawing.Image myImage = System.Drawing.Image.FromFile("c:\\222.jpg");
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(myImage);
graphics.DrawString("我写的文字", new Font("宋体", 12), new SolidBrush(Color.Red), new Point(10, 10));
graphics.DrawImage(myImage, 0F, 0F);
myImage.Save("c:\\222-1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
graphics.Dispose();
string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection conn = new SqlConnection(connStr);
string sql = "select * from t_imgs where id = @ImgID";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@ImgID", SqlDbType.Int).Value = ImgID;
conn.Open();
SqlDataReader read = cmd.ExecuteReader();
read.Read();
byte[] bytes = (byte[])read["imgData"];
read.Close();
conn.Close();
//把byte[]写到流中
MemoryStream stream = new MemoryStream();
byte[] bytes = new Byte[1];
stream.Write(bytes, 0, bytes.Length);
//从流中实例化图片对象
System.Drawing.Image myImage = System.Drawing.Image.FromStream(stream);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(myImage);
//写字
graphics.DrawString("我写的文字", new Font("宋体", 12), new SolidBrush(Color.Red), new Point(10, 10));
//重新写一下图片
graphics.DrawImage(myImage, 0F, 0F);
//保存为jpg格式
myImage.Save("c:\\222-1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//释放对象
graphics.Dispose();
stream.Close();
byte[] bytes = new Byte[1]; //这句多了写了,删掉它
stream.Write(bytes, 0, bytes.Length);