1) Create the Image attribute
System.Drawing.Imaging.ImageAttributes attrib = new System.Drawing.Imaging.ImageAttributes();
System.Drawing.Imaging.ImageAttributes attrib = new System.Drawing.Imaging.ImageAttributes();
2) Set the transparency color key (black for the example)
attrib.SetColorKey(Color.Black, Color.Black);
: 투명으로 지정될 Color를 정해준다.
3) Draw the image using the image attribute
e.Graphics.DrawImage(backgroundIm, destRect, 0, 0, backgroundIm.Width, backgroundIm.Height, GraphicsUnit.Pixel, attrib);
e.Graphics.DrawImage(backgroundIm, destRect, 0, 0, backgroundIm.Width, backgroundIm.Height, GraphicsUnit.Pixel, attrib);
And here is the result with a light green background!