【问题标题】:The type or namespace name 'Imageformat' does not exist类型或命名空间名称“Imageformat”不存在
【发布时间】:2014-11-15 08:36:14
【问题描述】:

我正在编写 MVC5 互联网应用程序,并且正在将图像上传到 Azure blob 存储。当用户上传图片时,我希望创建一个缩略图并将此图片保存到 blob 存储中。

我有图像的输入流,并将其用作我函数的Stream fileStream 参数。

这是我当前的代码:

public void CreateImageThumbnailFromStream(Stream fileStream, string filename, int width, int height)
{
    System.Drawing.Image image = System.Drawing.Image.FromStream(fileStream);
    System.Drawing.Image thumbnailImage = image.GetThumbnailImage(width, height, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
    MemoryStream imageStream = new MemoryStream();
    thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);
    if (imageStream.Length > 0)
    {
        string containerName = User.Identity.GetUserName();
        CloudBlobContainer blobContainer = _blobStorageService.GetCloudBlobContainer(containerName);
        CloudBlockBlob blob = blobContainer.GetBlockBlobReference(filename);
        blob.UploadFromStream(imageStream);
    }
}

我收到以下错误:

The type or namespace name 'Imageformat' does not exist in the namespace 'System.Drawing.Imaging' (are you missing an assembly reference?

在这行代码处:

thumbnailImage.Save(imageStream, System.Drawing.Imaging.Imageformat.Jpeg);

我参考了以下程序集:

System.Drawing (in System.Drawing.dll)

这是 MSDN 类文档:

http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat(v=vs.110).aspx

我可以对我的代码提供一些帮助吗?

提前致谢

【问题讨论】:

    标签: image azure visual-studio-2013 asp.net-mvc-5


    【解决方案1】:

    'ImageFormat',不是Imageformat,区分大小写。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-01
      • 2012-06-19
      • 1970-01-01
      • 2012-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多