会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
sunrack
博客园
::
首页
::
联系
::
管理
根据位图绘制控件外观
Posted on
2006-11-20 08:57
sunrack
阅读(
199
) 评论(
0
)
编辑
收藏
举报
private
static
GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap)
{
GraphicsPath graphicsPath
=
new
GraphicsPath();
Color colorTransparent
=
bitmap.GetPixel(
0
,
0
);
int
colOpaquePixel
=
0
;
for
(
int
row
=
0
; row
<
bitmap.Height; row
++
)
{
colOpaquePixel
=
0
;
for
(
int
col
=
0
; col
<
bitmap.Width; col
++
)
{
if
(bitmap.GetPixel(col, row)
!=
colorTransparent)
{
colOpaquePixel
=
col;
int
colNext
=
col;
for
(colNext
=
colOpaquePixel; colNext
<
bitmap.Width; colNext
++
)
if
(bitmap.GetPixel(colNext, row)
==
colorTransparent)
break
;
graphicsPath.AddRectangle(
new
Rectangle(colOpaquePixel,
row, colNext
-
colOpaquePixel,
1
));
col
=
colNext;
}
}
}
return
graphicsPath;
}
private
void
simpleButton1_Paint(
object
sender, System.Windows.Forms.PaintEventArgs e)
{
this
.simpleButton1.Cursor
=
Cursors.Hand;
Bitmap bmpBob
=
(Bitmap)
this
.simpleButton1.Image;
GraphicsPath graphicsPath
=
CalculateControlGraphicsPath(bmpBob);
this
.simpleButton1.Region
=
new
Region(graphicsPath);
}
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 sunrack
Powered by .NET 8.0 on Kubernetes