Jyn*_*ynn 0 c# model-view-controller azure
我在这里搜索过这方面的帮助,但没有什么能比得上我需要的.我有一个上传的图像,我想在保存到azure之前更改大小.
所以目前我的代码是:
public ActionResult UserDetails(HttpPostedFileBase photo)
{ var inputFile = new Photo()
{
FileName = photo.FileName,
Data = () => photo.InputStream
};
//then I save to Azure
Run Code Online (Sandbox Code Playgroud)
我如何将photo.InputStream更改为100x 100像素?
我是这样做的:
byte[] imageBytes;
//Of course image bytes is set to the bytearray of your image
using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
{
using (Image img = Image.FromStream(ms))
{
int h = 100;
int w = 100;
using (Bitmap b = new Bitmap(img, new Size(w,h)))
{
using (MemoryStream ms2 = new MemoryStream())
{
b.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);
imageBytes = ms2.ToArray();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
从那里,我用a MemoryStream来上传.我使用blob存储并使用UploadFromStreamAsync加载到blob.
这是它的基本观点.〜干杯
| 归档时间: |
|
| 查看次数: |
4688 次 |
| 最近记录: |