请教一个关于gdi+渐变的问题 本帖最后由 s000rd 于 2012-02-24 15:08:41 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为啥不一样不知道,要不你用 LinearGradientBrush 试试渐变色? LinearGradientBrush好像无法填充圆形 protected void Page_Load(object sender, EventArgs e) { Bitmap bmp = new Bitmap(200, 200); Graphics g = Graphics.FromImage(bmp); Color cStart = Color.FromArgb(40, 0, 0, 0); Color cEnd = Color.FromArgb(255, 0, 0, 255); int radius = 100; GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, radius * 2, radius * 2); PathGradientBrush pthGrBrush = new PathGradientBrush(path); pthGrBrush.CenterColor = cEnd; Color[] colors = { cStart }; pthGrBrush.SurroundColors = colors; g.FillEllipse(pthGrBrush, 0, 0, radius * 2, radius * 2); bmp.Save("d:\\1.png"); bmp.Dispose(); g.Dispose(); } 或者path渐变是否能实现多种颜色的渐变?比如中心红色,中间位黄色,边上为蓝色?调试半天没有效果 Color cStart = Color.FromArgb(40, 0, 0, 0); //alpha是否要为0?pthGrBrush.InterpolationColors = new ColorBlend(3){ Colors = new[] { Color.Blue, Color.Yellow, Color.Red }, Positions = new[] { 0f, .5f, 1f },}; Gradients made easy 我现在实现了就是这种效果,但看了下html5中的效果,貌似是在这个基础上,有中心向两边透明渐变。但在gdi+中,如果第二种渐变色为透明,则显示的效果如上图,只有一种颜色。 datagridview单元格存放图片 关于C#操作ACESS的问题 C#中接口实现的问题,疑惑中... 文件下载 如何得到这样的字符串? 能不能用代码创建数据库 有没有比较空闲的人 ----“中国铁路中国造 坚决反对日本介入”网络大签名 新手求助 C#频繁获取google搜索结果,被google限制怎么解决? 绘图的问题 将表中多层数据绑定到treeview c#
试试渐变色?
{
Bitmap bmp = new Bitmap(200, 200);
Graphics g = Graphics.FromImage(bmp);
Color cStart = Color.FromArgb(40, 0, 0, 0);
Color cEnd = Color.FromArgb(255, 0, 0, 255);
int radius = 100;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, radius * 2, radius * 2);
PathGradientBrush pthGrBrush = new PathGradientBrush(path);
pthGrBrush.CenterColor = cEnd;
Color[] colors = { cStart };
pthGrBrush.SurroundColors = colors;
g.FillEllipse(pthGrBrush, 0, 0, radius * 2, radius * 2);
bmp.Save("d:\\1.png");
bmp.Dispose();
g.Dispose(); }
{
Colors = new[] { Color.Blue, Color.Yellow, Color.Red },
Positions = new[] { 0f, .5f, 1f },
};