如何将图像文件读取为byte[]?
这就是我保存图像的方式。
[HttpPost]
public ActionResult Create(HttpPostedFileBase file)
{
if (file != null)
{
var extension = Path.GetExtension(file.FileName);
var fileName = Guid.NewGuid().ToString() + extension;
var path = Path.Combine(Server.MapPath("~/Content/Photos"), fileName);
file.SaveAs(path);
//...
}
}
我不想显示该位置的图像。我想先阅读它以进行进一步处理。
在这种情况下如何读取图像文件?
This is how I save images.
[HttpPost]
public ActionResult Create(HttpPostedFileBase file)
{
if (file != null)
{
var extension = Path.GetExtension(file.FileName);
var fileName = Guid.NewGuid().ToString() + extension;
var path = Path.Combine(Server.MapPath("~/Content/Photos"), fileName);
file.SaveAs(path);
//...
}
}
I don't want to display the image from that location. I want rather to read it first for further processing.
How do I read the image file in that case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:将图像读取到字节[]
为了历史的缘故,这是我在问题澄清之前的回答。
您的意思是将其加载为 BitMap 实例?
Update: Reading the image to a byte[]
For history's sake, here's my answer before the question was clarified.
Do you mean loading it as a BitMap instance?