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

Thảo luận trong 'Lập trình & Đồ hoạ' bắt đầu bởi Eron, 25/4/09.

  1. Eron

    Eron Mr & Ms Pac-Man

    Tham gia ngày:
    20/7/06
    Bài viết:
    271
    Nơi ở:
    The Hidden World
    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));
            }
        }
    
    [​IMG]
    Ở 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
     
  2. Eron

    Eron Mr & Ms Pac-Man

    Tham gia ngày:
    20/7/06
    Bài viết:
    271
    Nơi ở:
    The Hidden World
    Mình fix đc bug gòy, hok cần trả lời :-*
     

Chia sẻ trang này