繁体   English   中英

使用Graphics.DrawImage()在窗体上绘制图像

[英]Drawing image on a form using Graphics.DrawImage()

我正在尝试在所有其他控件前面的窗体上绘制图像。 我试图在控件前面制作一个透明面板,但它仅显示背景,而控件未显示。 我的代码是:(我正在使用它来产生褪色效果)

Player1ColorMatrix.Matrix33 = Player1Transparency;

Player1ImageAttributes.SetColorMatrix(Player1ColorMatrix,
                    ColorMatrixFlag.Default,
                    ColorAdjustType.Bitmap);

    e.Graphics.DrawImage(Player1ScoreImage, Player1rect, 0, 0, 200, 62, GraphicsUnit.Pixel, Player1ImageAttributes);
    Player1Transparency = 0.0f;

player1scoreimage是图像,player1rect是我要在其中绘制图像的矩形

我如何使此图像位于其他控件的前面?

谢谢,ofir

尝试为此使用自定义面板:

private class PanelX : Panel
{
  protected override CreateParams CreateParams
  {
    get
    {
      CreateParams cp = base.CreateParams;
      cp.ExStyle |= 0x20;
      return cp;
    }
  }

  protected override void OnPaint(PaintEventArgs e)
  {
    using (SolidBrush brush = new SolidBrush(Color.FromArgb(128, 0, 0, 0)))
    {
      e.Graphics.FillRectangle(brush, this.ClientRectangle);
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM