【发布时间】:2014-01-16 16:57:11
【问题描述】:
我不想在 C# 中更改 Bitmap 的分辨率,并且已经找到了 Bitmap.setResolution 方法,但该方法实际上并没有更改物理分辨率。 然后我发现了这个:http://www.nullskull.com/q/10269424/change-the-resolution-of-png-image-and-save-it.aspx 但遗憾的是它没有奏效。 使用此代码,生成的图像只是原始图像的一部分。 这是我的代码:
Bitmap b = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(0, 0, 0, 0, b.Size);
Bitmap b2 = new Bitmap(100, 100);
g = Graphics.FromImage(b2);
g.DrawImage(b, new Rectangle(0, 0, b2.Width, b2.Height), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel);
b2.Save(Strings.common_documents + "tmp_screenshot.jpg", ImageFormat.Jpeg);
有没有办法在相同内容的情况下为图像提供较低的分辨率?
【问题讨论】:
-
我看不到明显的错误。您的代码应该可以正常工作...
标签: c# graphics bitmap screenshot