G
Guest
hi,All
I have a gif image(done by photoshop, and the background is transparent)
I want to draw it on my forms.
But the background is not transparent.
How to do it?
I try source below:but it does not work?
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorKey(Color.FromArgb(0,255,0),Color.FromArgb(0,255,0));
//imageAttr.SetColorKey(Color.Blue,Color.Blue);
// Draw the image with the color key set.
System.Drawing.Rectangle rect;
try
{
rect = new Rectangle(0, 0, this.m_bmp.Width, this.m_bmp.Height);
e.Graphics.DrawImage(m_bmp, // Image
rect, // Dest. rect.
0, // srcX
0, // srcY
this.m_bmp.Width, // srcWidth
this.m_bmp.Height, // srcHeight
GraphicsUnit.Pixel, // srcUnit
imageAttr); // ImageAttributes
}
catch(Exception ex){}
thanks in advance
I have a gif image(done by photoshop, and the background is transparent)
I want to draw it on my forms.
But the background is not transparent.
How to do it?
I try source below:but it does not work?
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorKey(Color.FromArgb(0,255,0),Color.FromArgb(0,255,0));
//imageAttr.SetColorKey(Color.Blue,Color.Blue);
// Draw the image with the color key set.
System.Drawing.Rectangle rect;
try
{
rect = new Rectangle(0, 0, this.m_bmp.Width, this.m_bmp.Height);
e.Graphics.DrawImage(m_bmp, // Image
rect, // Dest. rect.
0, // srcX
0, // srcY
this.m_bmp.Width, // srcWidth
this.m_bmp.Height, // srcHeight
GraphicsUnit.Pixel, // srcUnit
imageAttr); // ImageAttributes
}
catch(Exception ex){}
thanks in advance