如何设置为Microsoft图表控件的分辨率(DPI)产生的asp.net图片 [英] How to set the resolution (DPI) for Microsoft Chart Control generated Images in asp.net

查看:159
本文介绍了如何设置为Microsoft图表控件的分辨率(DPI)产生的asp.net图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何定义图像分辨率(DPI)由Microsoft图表控件.NET创建的映像(用于创建png格式,图像)。

How can I define the image resolution (in DPI) for images created by the microsoft chart controls for .net (for the creation of .png-images).

本的WinForms版本的图表控件的有<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.chart.renderingdpix.aspx"相对=nofollow> Chart.RenderingDpi [X | Y] - 的财产,但是对于asp.net控制,我找不到这样的属性。

The winforms version of the charting control has the Chart.RenderingDpi[X|Y]- property, however for the asp.net control, I can not find such a property.

有人能导致我这样做的一个解决方案?

Can someone lead me to a solution for doing this?

更新
在寻找解决的办法,我已经看到,图表控件有油漆的方法。有了这个,我能创造与其他DPI-设置的图像。我不知道这是否是走正确的路,但结果看起来不是对我不好。我已经发布了code作为一个答案。如果任何人有一个更整洁的解决方案,请让我知道。

Update
During searching for a solution, I have seen that the chart-control has a Paint-method. With this I was able to create images with other DPI-settings. I'm not sure if this is the correct way to go, but the result looks not to bad to me. I have posted the code as an answer. If anyone has a more neat solution, please let me know.

推荐答案

下面一个解决方案,我发现,产生了较好的效果。

Here a solution I have found that produces good results.

Bitmap bmp = new Bitmap(size.Width, size.Height);
bmp.SetResolution(resX,resY);
using (Graphics g = Graphics.FromImage(bmp)) {
     chart.Paint(g,new Rectangle(new Point(0,0),GetSizeOrDefault(context)));
}

这篇关于如何设置为Microsoft图表控件的分辨率(DPI)产生的asp.net图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆