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