【发布时间】:2014-09-15 18:06:44
【问题描述】:
我将图表从本质上是 72dpi 更新为 300dpi。这是因为我正在使用 itextsharp 将图像添加到我的 pdf 并且质量很差。所以我将图像的大小增加了 3 倍,图像看起来确实更好,但问题就在这里。
DPI 增加了,但细节变得非常难以看到。
原始图表图像
重构的图表图像
代码
这就是我调整图表大小的方式。
private static System.Drawing.Bitmap GetChartBitmap()
{
System.Drawing.Rectangle targetBounds = new System.Drawing.Rectangle(0, 0, chart_runs.Width, chart_runs.Height);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(targetBounds.Width, targetBounds.Height);
bitmap.SetResolution(1000, 1000);
chart_runs.DrawToBitmap(bitmap, targetBounds);
bitmap.Save(@"C:\Temp\OriginalChartImage.bmp");
System.Drawing.Bitmap bitmap3 = new System.Drawing.Bitmap(1650, 990);
bitmap3.SetResolution(300, 300);
chart_runs.DrawToBitmap(bitmap3, new System.Drawing.Rectangle(0, 0, 1650, 990));
bitmap3.Save(@"C:\Temp\RefactoredChartImage.png");
//This stuff below is for my code elsewhere. Using bitmap3 to be added to pdf.
//chart_runs.DrawToBitmap(bitmap, targetBounds);
string path = System.IO.Path.GetTempPath();
bitmap1.Save(path + @"\Image.png");
return bitmap1;
}
我查看了 Microsoft msdn 示例,但没有找到任何解决我问题的方法。也就是说,我怎样才能增加标签的大小,以便人们可以再次阅读它们。或者,我有没有办法增加 DPI 并保持与第一张图片中使用的标签 x 和标签 y 比例相同?也就是说,有更大的图像和 300DPI,但按 20 的比例缩放 0 到 300 而不是像我重构的图片那样的 5?
尝试修复
- 缩放轴?见here。我不认为这是正确的。这里没有太大的成功。
- 一直试图在 Chart 类中找到一种方法来查看是否有一种方法可以指定严格的比例。 (y 尺度上为 20 秒,x 尺度上为 15 秒)。
- 大多数在线资源都乐于增加图片的比例并走开。像这样的事情here.
我将不胜感激任何帮助和帮助。
【问题讨论】:
标签: c# image charts scale data-visualization