Cần giúp đỡ về Winform bằng C#

  • Thread starter Thread starter Eron
  • Ngày gửi Ngày gửi

Eron

Mr & Ms Pac-Man
Tham gia ngày
20/7/06
Bài viết
271
Reaction score
4
Mã:
class ControlRegion
    {
        public static GraphicsPath CreateControlGraphicPath(Bitmap image)
        {
            GraphicsPath g = new GraphicsPath();
            Color transparent = image.GetPixel(0, 0);
            int col0;
            for (int row = 0; row < image.Height; row++)
            {
                col0 = 0;
                for (int col = 0; col < image.Width; col++)
                {
                    if (image.GetPixel(col, row) != transparent)
                    {
                        col0 = col;
                        int colNext = col;
                        for (colNext = col0; colNext < image.Width; colNext++)
                            if (image.GetPixel(colNext, row) == transparent)
                                break;
                        g.AddRectangle(new Rectangle(col0, row, colNext - col0, 1));
                        col = colNext;
                    }
                }
            }
            return g;
        }
        public static void CreateControlRegion(object control, Bitmap image)
        {
            if (control == null || image == null)
                return;
            Form form = (Form)control;
            form.Width = image.Width + 15;
            form.Height = image.Height + 30;
            form.FormBorderStyle = FormBorderStyle.None;
            form.BackgroundImage = image;
            form.Region = new Region(CreateControlGraphicPath(image));
        }
    }
NgheNhac.jpg

Ở trên là 2 hàm cắt form của mình, hok hỉu sao xung quanh form bị vệt trắng, nhờ các pro chỉ giúp T_T thx
 
Mình fix đc bug gòy, hok cần trả lời :-*
 
Back
Top