Results 1 to 6 of 6

Thread: Transparent BMP's

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    15

    Transparent BMP's

    Is it possible to change the alpha colour on a transparent BMP, in VB .NET?

    The reason is, when I load a transparent image, and store it in an image list with transparency, and then save that image from there, it gives it a black background… which is not what I want.

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i have the feeling BMP format doesnt support transparency...i think u are talking about WMF or PNG or GIF right?
    \m/\m/

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    15
    Scan the image for transparent pixels, and convert them to a colour.
    Code:
            Dim x As Integer, y As Integer
            For x = 0 To Img.Width - 1
                For y = 0 To Img.Height - 1
                    If Img.GetPixel(x, y).ToArgb = 0 Then Img.SetPixel(x, y, Color.FromArgb(0, 0, 255, 0))
                Next
            Next

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    15
    If you load a BMP into a picture box, or image list, etc, it does support transparency. However, when you save it to disk, the transparent layer is issued a colour – I don’t know how and why it works like this… it just does. My solution is above.

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by guiledotNET
    Scan the image for transparent pixels, and convert them to a colour.
    Code:
            Dim x As Integer, y As Integer
            For x = 0 To Img.Width - 1
                For y = 0 To Img.Height - 1
                    If Img.GetPixel(x, y).ToArgb = 0 Then Img.SetPixel(x, y, Color.FromArgb(0, 0, 255, 0))
                Next
            Next
    that would be quite inefficient dont have my book with me now, otherwise I would post something better ...
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    15
    If you are able to, later, I would appreciate it.

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