I want to give a pictureBox the shape of an image I have. The image off course is rectangular, but there is the backgroundcolor that should be ignored, which leads to the desired form. So if there is a picture of a banana on a white background, I should have a pictureBox in shape of a banana at the end.. This is needed so that I can move shaped PictureBox in front of a AxWMPLib Mediaplayer without having the rectangle surrounding the banana covering all of the video.
My approach is to create a new class that extends PictureBox and then setting the region to the shape. Problem is, I don't know how to get the shape.
class ShapedPBox : PictureBox
{
public ShapedPBox()
{
this.Paint += this.shapedPaint;
}
void shapedPaint(object sender, paintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath gP = new System.Drawing.Drawing2D.GraphicsPath();
//do something to give gP.addPicture? perhaps something with transparency key?
this.Region = new Region(graphicsPath);
}
public Image image;
}