图片更改大小保存至数据库并读取
2013-11-12 11:29
344 查看
//保存图片至数据库
//读取
HttpPostedFile upfile = null ; byte[] bt = null; if (context.Request.Files.Count > 0) { upfile = context.Request.Files[0]; System.Drawing.Image imgOutput = System.Drawing.Bitmap.FromStream(upfile.InputStream); //修改图片宽度为800,高度等比例缩放 System.Drawing.Image imgOutput2 = imgOutput.GetThumbnailImage(800,imgOutput.Height * 800 / imgOutput.Width, null, IntPtr.Zero); MemoryStream ms = new MemoryStream(); imgOutput2.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); bt = ms.ToArray();//SQL image类型直接保存 }
//读取
Response.Clear(); Response.ContentType = "image/gif"; Response.BinaryWrite(sqlimg);
相关文章推荐
- jdbc保存图片到数据库并读取代码
- C#保存图片到数据库,读取图片显示
- 如何读取保存在数据库中的图片显示在DataGrid中
- 图片保存到数据库以及C#读取图片
- Android_读取Excel_更改Excel内容,数据库保存数据
- SpringMVC 上传图片保存到服务器 同时更改图片名称保存至数据库
- 保存/读取图片到数据库
- 【转】c#读取图像保存到数据库中(数据库保存图片)
- c# winform 把数据库里读取出来的图片保存到本地硬盘上,图片下载
- 读取相册图片,保存至另外一个文件夹图片大小变大
- 使用jdbcTemplate 保存图片 至数据库 以及 从数据库读取 保存到本地
- Gridview 读取数据库图片并 改变大小
- c# 图片保存到数据库和从数据库读取图片并显示
- 如何将pictureBox里的图片保存到数据库,然后从数据读取显示
- 如何读取保存在数据库中的图片显示在DataGrid中
- 将图片保存到数据库中,并从数据库中读取
- C#保存图片到数据库并读取显示图片的方法
- 图片保存到数据库和从数据库读取图片并显示(C#)
- 图片保存到数据库和从数据库读取图片并显示
- 图片保存到数据库和从数据库读取图片并显示(C#)