资源简介
使用C#真正实现的透明控件,不是什么透明色或者仿背景色,直接把目标颜色给扣掉了,使用的是UI区域裁剪自定义方法,积分可能涨

代码片段和文件信息
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace UControlTran
{
public static class APub
{
static APub()
{
}
///
/// 根据图片计算GraphicsPath路径(低效率)
///
/// 图像资源
/// 欲透明掉的颜色
/// 路径画布已过滤掉了透明颜色
public static GraphicsPath ImageToGraphicsPath(Image imgxColor TranColor)
{
if (imgx == null) return null;
GraphicsPath g = new GraphicsPath(FillMode.Alternate);
Bitmap bitmap = null;
if (typeof(Bitmap) == imgx.GetType())
bitmap = (Bitmap)imgx;
else
bitmap = new Bitmap(imgx);
int ImWidth = bitmap.Width;
int ImHeight = bitmap.Height;
Color curColor;
Rectangle curRect = new Rectangle();
curRect.Height = 1;
bool isTransRgn;
for (int y = 0; y < ImHeight; y++)
{
isTransRgn = true;
for (int x = 0; x < ImWidth; x++)
{
curColor = bitmap.GetPixel(x y);
if (curColor == TranColor || x == ImWidth - 1)//如果遇到透明色或行尾
{
if (isTransRgn == false)//退出有效区
{
curRect.Width = x - curRect.X;
g.AddRectangle(curRect);
}
}
else//非透明色
{
if (isTransRgn == true)//进入有效区
{
curRect.X = x;
curRect.Y = y;
}
}//if curColor
isTransRgn = curColor == TranColor;
}
}
return g;
}
///
/// 根据图片计算Region路径(低效率)
///
/// 图像资源
/// 欲透明掉的颜色
/// 一个离散的路径信息
public static Region ImageToRegion(Image imgx Color TranColor)
{
if (imgx == null) return null;
Region rRegion = new Region();
rRegion.MakeEmpty();
Bitmap bitmap = null;
if (typeof(Bitmap) == imgx.GetType())
bitmap = (Bitmap)imgx;
else
bitmap = new Bitmap(imgx);
int ImWidth = bitmap.Width;
int ImHeight = bitmap.Height;
Color curColor;
Rectangle curRect = new Rectangle();
curRect.Height = 1;
bool isTransRgn;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 926 2017-02-07 15:41 UControlTran.sln
文件 7207 2017-02-07 16:31 UControlTran\APub.cs
文件 124416 2017-02-07 16:28 UControlTran\bin\Debug\UControlTran.exe
文件 34304 2017-02-07 16:28 UControlTran\bin\Debug\UControlTran.pdb
文件 14328 2017-02-07 16:28 UControlTran\bin\Debug\UControlTran.vshost.exe
文件 362 2017-02-07 16:02 UControlTran\Form1.cs
文件 3092 2017-02-07 16:02 UControlTran\Form1.Designer.cs
文件 5814 2017-02-07 16:02 UControlTran\Form1.resx
文件 4608 2017-02-07 15:54 UControlTran\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 615 2017-02-07 16:28 UControlTran\obj\Debug\UControlTran.csproj.FileListAbsolute.txt
文件 883 2017-02-07 16:02 UControlTran\obj\Debug\UControlTran.csproj.GenerateResource.Cache
文件 124416 2017-02-07 16:28 UControlTran\obj\Debug\UControlTran.exe
文件 180 2017-02-07 16:27 UControlTran\obj\Debug\UControlTran.Form1.resources
文件 34304 2017-02-07 16:28 UControlTran\obj\Debug\UControlTran.pdb
文件 113412 2017-02-07 16:27 UControlTran\obj\Debug\UControlTran.Properties.Resources.resources
文件 493 2017-02-07 15:41 UControlTran\Program.cs
文件 1374 2017-02-07 15:41 UControlTran\Properties\AssemblyInfo.cs
文件 3085 2017-02-07 15:54 UControlTran\Properties\Resources.Designer.cs
文件 6192 2017-02-07 15:54 UControlTran\Properties\Resources.resx
文件 1097 2017-02-07 15:41 UControlTran\Properties\Settings.Designer.cs
文件 249 2017-02-07 15:41 UControlTran\Properties\Settings.settings
文件 112946 2017-02-07 15:54 UControlTran\Resources\90.bmp
文件 4149 2017-02-07 16:27 UControlTran\UControlTran.csproj
文件 803 2017-02-07 16:28 UControlTran\UserControl1.cs
文件 1123 2017-02-07 15:54 UControlTran\UserControl1.Designer.cs
目录 0 2017-02-07 15:43 UControlTran\obj\Debug\Refactor
目录 0 2017-02-07 15:54 UControlTran\obj\Debug\TempPE
目录 0 2017-02-07 15:56 UControlTran\bin\Debug
目录 0 2017-02-07 16:28 UControlTran\obj\Debug
目录 0 2017-02-07 15:42 UControlTran\bin
............此处省略8个文件信息
相关资源
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
评论
共有 条评论