显示透明背景,谢谢大家 我自定义一个控件,我想在控件内显示一个球,怎样让球的周围透明。我用this.drawimage方法找不到透明项。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //设置透明在构造函数里写SetStyle(ControlStyles.SupportsTransparentBackColor, true);this.BackColor = Color.Transparent; this.TransparencyKey = this.BackColor(你想透明的颜色,比如COLOR.WHITE); 我在msdn中查到了usint system.draw.imageing;// Create image.Image newImage = imagePaint;// Create rectangle for source image.Rectangle srcRect = new Rectangle(new Point(0,0),imageFore.Size );GraphicsUnit units = GraphicsUnit.Pixel;// Create parallelogram for drawing adjusted image.Point ulCorner2 = new Point(0, 0);Point urCorner2 = new Point(imagePaint.Width, 0);Point llCorner2 = new Point(0, imagePaint.Height);Point[] destPara2 = { ulCorner2, urCorner2, llCorner2 };// Create image attributes and set large gamma.ImageAttributes imageAttr = new ImageAttributes();imageAttr.SetColorKey(Color.White, Color.White);// Draw adjusted image to screen.e.Graphics.DrawImage(newImage, destPara2, srcRect, units, imageAttr); 监测远程数据库连接状态的线程,我的实现有问题。 C#数据库 进程字符串替换 VS2005 dataset 无法使用 IN 查询!!! duwamish7中是如何实现插入记录的啊 窗口问题小问 UML an assembly C#编译后的文件可否脱离.net Framework运行? 求C#工作或者学习的人,一起学习求指导帮助 问一个有关mediaplayer实现连续播放媒体文件的问题 求助如何取唯一值 请教使用C#绘制拓扑图的解决方案
//设置透明在构造函数里写
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
Image newImage = imagePaint;// Create rectangle for source image.
Rectangle srcRect = new Rectangle(new Point(0,0),imageFore.Size );
GraphicsUnit units = GraphicsUnit.Pixel;// Create parallelogram for drawing adjusted image.
Point ulCorner2 = new Point(0, 0);
Point urCorner2 = new Point(imagePaint.Width, 0);
Point llCorner2 = new Point(0, imagePaint.Height);
Point[] destPara2 = { ulCorner2, urCorner2, llCorner2 };// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorKey(Color.White, Color.White);// Draw adjusted image to screen.
e.Graphics.DrawImage(newImage, destPara2, srcRect, units, imageAttr);