1
我想提出一個背景圖像和背景圖像上面我想疊加透明圖片框,並試圖把第二個PictureBox的,像這樣:覆蓋C#窗口應用程序窗體中的透明圖片框?
pictureBox2.BackColor = Color.Transparent;
但沒有奏效。基本上,我想這樣做:
我想提出一個背景圖像和背景圖像上面我想疊加透明圖片框,並試圖把第二個PictureBox的,像這樣:覆蓋C#窗口應用程序窗體中的透明圖片框?
pictureBox2.BackColor = Color.Transparent;
但沒有奏效。基本上,我想這樣做:
透明度Windows Forms尚未實現正如人們所期望。具有透明背景實際上意味着控件使用其父項的背景。這意味着你需要讓你的覆蓋控制原始圖片框的子:
PictureBox overlay = new PictureBox();
overlay.Dock = DockStyle.Fill;
overlay.BackColor = Color.FromArgb(128, Color.Blue);
pictureBox2.Controls.Add(overlay);
如果你想覆蓋圖片框包含你需要真正改變圖像的透明圖像:
PictureBox overlay = new PictureBox();
overlay.Dock = DockStyle.Fill;
overlay.BackColor = Color.Transparent;
Bitmap transparentImage = new Bitmap(overlayImage.Width, overlayImage.Height);
using (Graphics graphics = Graphics.FromImage(transparentImage))
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = 0.5f;
ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
graphics.DrawImage(overlayImage, new Rectangle(0, 0, transparentImage.Width, transparentImage.Height), 0, 0, overlayImage.Width, overlayImage.Height, GraphicsUnit.Pixel, attributes);
}
overlay.Image = transparentImage;
pictureBox2.Controls.Add(overlay);
非常感謝你,我正在尋找= D – user2948720