Results 1 to 3 of 3

Thread: Transparent image background

  1. #1

    Thread Starter
    Addicted Member A.P.Gumby's Avatar
    Join Date
    Oct 2005
    Location
    Outside the assylum
    Posts
    147

    Transparent image background

    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.
    Using Visual Studio 2008.
    I am not young enough to know everything - Oscar Wilde

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Transparent image background

    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/quickst...kgndimage.aspx
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Addicted Member A.P.Gumby's Avatar
    Join Date
    Oct 2005
    Location
    Outside the assylum
    Posts
    147

    Re: Transparent image background

    Thanks for the reply

    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.

    VB Code:
    1. Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
    2.         'Draw the picture box image onto the panel image with a transparent background.
    3.         Dim g As Graphics = e.Graphics
    4.         Dim g_attribute As New System.Drawing.Imaging.ImageAttributes()
    5.         Dim destRect As New Rectangle(0, 0, PictureBox1.Image.Width, PictureBox1.Image.Height)
    6.         g_attribute.SetColorKey(Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255))
    7.         g.DrawImage(PictureBox1.Image, destRect, 0, 0, PictureBox1.Image.Width, PictureBox1.Image.Height, GraphicsUnit.Pixel, g_attribute)
    8.     End Sub
    Using Visual Studio 2008.
    I am not young enough to know everything - Oscar Wilde

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width