我想从字符串保存图像。如何以英寸为单位设置图像高度和宽度?
所以我想知道如何在保存图像时以英寸为单位设置图像的高度和宽度。
我的代码如下图像保存:
private void Base64ToImage(string base64String)
{
Image fullSizeImg = null;
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes);
fullSizeImg = Image.FromStream(ms, true);
System.Drawing.Image.GetThumbnailImageAbort dummyCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(700, 800, dummyCallBack, IntPtr.Zero);
thumbNailImg.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Png);
fullSizeImg.Dispose();
thumbNailImg.Dispose();
}
你为什么要这么做? –
@Tarun,这是一个奇特而消极的评论。我可以想出十几个创建基于base64编码的图像的原因,并且希望能够在物理尺寸上显示/打印图像而不是按比例显示图像 - 这是一个非常常见的问题,WPF在很大程度上决定解决这个问题。 – Smudge202
@Smudge对不起,如果我听起来负面/粗鲁,只是想知道,为什么他/她想以英寸而不是像素保存图像! –