首页 新闻 搜索 专区 学院

GDI绘制柱状图,用图片填充柱形,不清晰

0
悬赏园豆:40 [待解决问题]

我用指定图片填充柱状图中的柱子后,图片一点都不清晰,上面有一层网格的线条。就像我填充用颜色填充柱子,颜色不是很纯,有一格一格的样子。我要怎么把那些网格去掉呢?完全显示我的图片的效果.

有查到资料说把背景色设置为透明的,但是我g.Clear(Color.Transparent);颜色却是黑色的。

下面是我调用图片的代码:

newImage = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("../images/bar_chart_yellow.png"));
                   g.DrawImage(newImage, barOrigin.X - 2, barOrigin.Y, barWidth + 5, barHeight);

zhou_3355的主页 zhou_3355 | 初学一级 | 园豆:140
提问于:2010-08-30 17:21
< >
分享
所有回答(3)
0

你的柱状图用的啥控件?

测试用绘制代码:

 

protected void Page_Load(object sender, EventArgs e)
{
Bitmap bm
= new Bitmap(500, 300);
Graphics g
= Graphics.FromImage(bm);
g.Clear(Color.Black);

g.DrawString(
string.Format("Background PixelFormat:{0}", Enum.GetName(typeof(PixelFormat), bm.PixelFormat)), new Font("宋体", 9), Brushes.White, new Point(5, 5));

g.DrawString(
string.Format("Graphics InterpolationMode:{0}", Enum.GetName(typeof(InterpolationMode), g.InterpolationMode)), new Font("宋体", 9), Brushes.White, new Point(5, 20));
g.DrawString(
string.Format("Graphics CompositingMode:{0}", Enum.GetName(typeof(CompositingMode), g.CompositingMode)), new Font("宋体", 9), Brushes.White, new Point(5, 35));
g.DrawString(
string.Format("Graphics CompositingQuality:{0}", Enum.GetName(typeof(CompositingQuality), g.CompositingQuality)), new Font("宋体", 9), Brushes.White, new Point(5, 50));
g.DrawString(
string.Format("Graphics PageUnit:{0}", Enum.GetName(typeof(GraphicsUnit), g.PageUnit)), new Font("宋体", 9), Brushes.White, new Point(5, 65));
g.DrawString(
string.Format("Graphics SmoothingMode:{0}", Enum.GetName(typeof(SmoothingMode), g.SmoothingMode)), new Font("宋体", 9), Brushes.White, new Point(5, 80));

g.DrawLine(
new Pen(Color.White, 1), 250, 250, 450, 250); //绘制横向
g.DrawLine(new Pen(Color.White, 1), 250, 50, 250, 250); //绘制纵向

using (System.Drawing.Image newImage = System.Drawing.Image.FromFile("E:\\AspNetDrawing\\2010083110444572.png"))
{
g.DrawString(
string.Format("Image PixelFormat:{0}", Enum.GetName(typeof(PixelFormat), newImage.PixelFormat)), new Font("宋体", 9), Brushes.White, new Point(5, 95));

// 绘制柱状图
g.DrawImage(newImage, 260, 149, 36, 100);
g.DrawImage(newImage,
300, 199, 36, 50);
g.DrawImage(newImage,
400, 49, 41, 200);
}

bm.Save(Response.OutputStream, ImageFormat.Jpeg);

bm.Dispose();
g.Dispose();
}

 

 

绘制的图片:

Launcher | 园豆:45045 (高人七级) | 2010-08-30 17:33
用的是Image控件!
支持(0) 反对(0) zhou_3355 | 园豆:140 (初学一级) | 2010-08-31 08:49
0

你可以试试用MSChart 来自动生成 柱状图形啊,

HUHU慈悲 | 园豆:9973 (大侠五级) | 2010-08-31 12:21
0
Jimson.Ma | 园豆:225 (菜鸟二级) | 2011-12-06 23:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册