使PictureBox图片半透明

    Image img = pictureBox1.Image;
    Bitmap bmp = new Bitmap(img);

    for (int i = 0; i < bmp.Width; i++)
    {
        for (int j = 0; j < bmp.Height; j++)
        {
            Color bmpcolor = bmp.GetPixel(i, j);
            byte A = bmpcolor.A;
            byte R = bmpcolor.R;
            byte G = bmpcolor.G;
            byte B = bmpcolor.B;
            bmpcolor = Color.FromArgb(128, R, G, B);
            bmp.SetPixel(i, j, bmpcolor);
        }
    }


    pictureBox1.Image = bmp;

posted @ 2009-07-20 14:25  cindymeng  阅读(942)  评论(0编辑  收藏  举报