PDA

Click to See Complete Forum and Search --> : Transparent image background


A.P.Gumby
Dec 4th, 2006, 08:25 AM
Hi,
I am using VB.NET in VS2005 to develop a Windows CE 5.0 application.
I want to display a .gif or .ico or .bmp (basically don't care which) in a picturebox with a transparent background.
It would appear that the CF does not support transparent image backgrounds.

I have spent a few hours searching for a solution to this but to no avail.
The best I can find is a suggestion that I redraw the image setting the background colour equal to the picturebox colour but I don't know how to do this.

Any help appreciated.

Strider
Dec 4th, 2006, 10:12 AM
www.openentcf.org sdk has a extended picturebox that has a transparancy feature....

also this link might be of some use
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx

A.P.Gumby
Dec 4th, 2006, 11:30 AM
Thanks for the reply :thumb:

I have got something going by using a picture box (visible = false) which has the image loaded into it at design time and then drawing the picture box image into a panel at runtime.


Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
'Draw the picture box image onto the panel image with a transparent background.
Dim g As Graphics = e.Graphics
Dim g_attribute As New System.Drawing.Imaging.ImageAttributes()
Dim destRect As New Rectangle(0, 0, PictureBox1.Image.Width, PictureBox1.Image.Height)
g_attribute.SetColorKey(Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255))
g.DrawImage(PictureBox1.Image, destRect, 0, 0, PictureBox1.Image.Width, PictureBox1.Image.Height, GraphicsUnit.Pixel, g_attribute)
End Sub