C#: Draw one Bitmap onto Another, with Transparency

前端 未结 3 559
天涯浪人
天涯浪人 2021-02-05 07:13

I have two Bitmaps, named largeBmp and smallBmp. I want to draw smallBmp onto largeBmp, then draw the result onto the screen. SmallBmp\'s white pixels should be transparent. Her

3条回答
  •  梦毁少年i
    2021-02-05 07:33

    Specify the transparency color of your small bitmap. e.g.

    Bitmap largeImage = new Bitmap();
    Bitmap smallImage = new Bitmap();
    --> smallImage.MakeTransparent(Color.White);
    Graphics g = Graphics.FromImage(largeImage);
    g.DrawImage(smallImage, new Point(10,10);
    

提交回复
热议问题