| RubenPieters wrote: |
|
Is that command also possible for a picturebox? (tried, but didn't work.) | |
Now that I'm here I can answer your question as well. What I did is I loaded the picture in a bitmap first and then replaced the white color with a transparant one. After that I placed the bitmap in the picturebox in the onpaint event of the picturebox
So the whole source looks like this:
private Bitmap waitingIcon;
/// <summary>OnLoad of the form. Show progress animation</summary>
private void WaitingSplash_Load(object sender, EventArgs e)
{
pictureBoxWaiting.Paint += new PaintEventHandler(pictureBoxWaiting_Paint);
waitingIcon = Resources.WaitingIcon;
pictureBoxWaiting.BackColor = BackColor;
}
/// <summary>Paints the PictureBox</summary>
private void pictureBoxWaiting_Paint(object sender, PaintEventArgs e)
{
using (Bitmap waitImageTmp = new Bitmap(waitingIcon, waitingIcon.Width, waitingIcon.Width))
{
waitImageTmp.MakeTransparent(Color.White);
e.Graphics.Clear(pictureBoxWaiting.BackColor);
e.Graphics.DrawImage(waitImageTmp, new Point(0, 0));
}
}
Hope it's usefull
