C#.NET2005,如何在32色下实现不规则窗体??谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/23 02:41:46
我要的是32色下的。。各位给个意见啊。

TransparencyKay更改为位图背景色,只能在16色下实现。。还请大家不要给这个方法啊。。。提前汗个。
另外,是,用Panel来覆盖的方法也不用说了,它只能压出直角。。。

谢谢大家

1.选择好图片
2.得到图片轮廓
3.设置窗体的Region属性(之前先把标题栏去掉)
4.试试看,祝你好运
//得到图片轮廓
private 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 Form1_Load(object sender, S