1


I want to save a bitmap image using memory stream object in emf format. When I used save method, it throws following exception:enter image description here

Code:

        Bitmap image = new Bitmap(Server.MapPath("Stacking.Png"));
        MemoryStream stream = new MemoryStream();

        image.Save(stream, ImageFormat.Emf);

Please explain me what is causing this error and how can I save the file in emf format?

Thanks and regards,
Anand

4

3 回答 3

1

我找到了一个简单的解决方法。我使用了以下代码:

        image.Save(Server.MapPath(FileName));
        MemoryStream stream1 = new MemoryStream(System.IO.File.ReadAllBytes(Server.MapPath(Filename)));
        System.IO.File.Delete(Server.MapPath(Filename));

这帮助我使用内存流对象将图像下载到 emf 文件中,但我仍然必须将图像临时保存在服务器中。

谢谢大家的回复。

于 2013-05-28T11:41:14.030 回答
1

问题是,EMF 是图像的矢量类型,而 PNG、BMP、GIF 等是光栅图像

除非您为此使用一些额外的指定软件,否则不能简单地将光栅转换为矢量。

于 2013-05-13T11:46:17.197 回答
0
string image = Convert.ToBase64String(System.IO.File.ReadAllBytes("c:\\1.43-Branches-and-Birds.png")); 

byte[] encodedDataAsBytes = Convert.FromBase64String(image);
Stream ImageStream = new MemoryStream(encodedDataAsBytes);
string UniqueFileName = Guid.NewGuid().ToString("n") + ".bmp";
string UniqueFileName = userregistration.Id + "_abcd.png";
string uploadFolderPath = "~/ProfileImage/";
string filePath = HttpContext.Current.Server.MapPath(uploadFolderPath);

System.Drawing.Image img = System.Drawing.Image.FromStream(ImageStream);
img.Save(HttpContext.Current.Request.PhysicalApplicationPath + "ProfileImage\\" + UniqueFileName, System.Drawing.Imaging.ImageFormat.Emf);*/
于 2013-05-27T08:19:58.553 回答