Code can be used in both WinXP and WinCE5.0. The effect is 2 graphs superimposed, the background image is unchanged, the foreground figure specifies the color to do transparent processing.
The SetColorKey is used to set the transparent color.
Graphics g = this. CreateGraphics ();
Bitmap Bitmap = new Bitmap (@ "E:/xxx/testb.png");
Bitmap bmp = new Bitmap (@ "E:/xxx/mouse.png");
imageattr = new ImageAttributes ();
Imageattr.setcolorkey (BMP. GetPixel, BMP. GetPixel (20, 20));
G.drawimage (Bitmap, new Rectangle (0, 0, bitmap.) Width, Bitmap. Height));
G.drawimage (BMP,//overlay diagram
New Rectangle (5, 8, BMP. Width, BMP. Height),//to overlay the position of the background image, size
0, 0, BMP. Width, BMP. Height,//size to be superimposed
GraphicsUnit.Pixel, imageattr); Transparent valve Value
Dispose
G.dispose ();
Background image
The graph to overlay
Actual operation effect (WinXP)