GlowButton - 发光的按钮控件
2016-08-23
0 0 0
4.0 分
其他
如何获取积分?
翻译 maninwest@Codeforge 作者:John Underhill @ Codeproject
最近我在查看 KMP Player 软件上的一些图形元素(如果你想看看好的图形设计,我建议你也查看一下)。我在项目中需要的是一个简单的发光按钮控件,用于玩家控制的,这不是什么太神奇的东西,只是在鼠标悬停时能够改变颜色。
让图像更改颜色很简单,只需修改 ImageAttribute 的颜色矩阵:
private void DrawColoredImage(Graphics g, Image img, Rectangle bounds, Color clr) { using (ImageAttributes ia = new ImageAttributes()) { ColorMatrix cm = new ColorMatrix(); // convert and refactor color palette cm.Matrix00 = ParseColor(clr.R); cm.Matrix11 = ParseColor(clr.G); cm.Matrix22 = ParseColor(clr.B); cm.Matrix33 = ParseColor(clr.A); cm.Matrix44 = 1f; // set matrix ia.SetColorMatrix(cm); // draw g.DrawImage(img, bounds, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia); } }
示例代码中的 ParseColor 会将位转化为浮点值。
请点击左侧文件开始预览
!预览只提供20%的代码片段,完整代码需下载后查看
侵权举报
c#
控件
按钮
发光
GlowButton
相关源码推荐
第186号:DX0110-小区物业管理系统源码
0
0
暂无评分
第219号:DX0149-小区物业管理系统源码
0
0
暂无评分
验证码识别
0
0
暂无评分
CSV数据分析工具
0
0
暂无评分
医院病历信息管理系统源码
0
0
暂无评分
暂无评论