Results 1 to 8 of 8

Thread: transparent PNG on picturebox

  1. #1

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Post transparent PNG on picturebox

    I've been googling this issue for hours now. Found a lot of examples, but they are all not workable for me.

    I have a windows forms app, with a picturebox, and I want a transparent PNG on it with Alpha blending.

    Seen a lot of exmples, but most of them are on transparent main forms. I just need to add the PNG to the picture box, without the ugly white/black edges.

    Thnx!

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: transparent PNG on picturebox

    and I want a transparent PNG on it with Alpha blending.
    Well it might help if you made yourself clear as to what exactly you want. Alpha blending kinda needs something to blend with so what exactly are you trying to achieve? You say that examples are not workable for you so tell us why. And here's a crazy idea! If you want us to see what you want and what you don't want from an image how about you actually provide us with some screenshots? After 200+ posts you really ought to know that vague questions get vague answers (if they get answers at all!)
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,753

    Re: transparent PNG on picturebox

    The only time I've ever worked with Alpha Blending in vb.net is with XNA, which does have sort of a steep learning curve.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  4. #4

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Post Re: transparent PNG on picturebox

    Basicly, I want this to look pretty; (see picture attachment)

    It looks good on a white background, but not a on black background.

    (I've extended my form transparency with: DwmExtendFrameIntoClientArea)
    Attached Images Attached Images  

  5. #5
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: transparent PNG on picturebox

    Those light-coloured pixels are part of your icon image. They usually result from anti-aliasing.

    If you have the icon as an image you can erase the unwanted pixels to transparent in a program like Paint.Net. If necessary, capture the icon image on a plain background, and erase all the background. Then save the cleaned-up image as a new icon for example with MS-Paint.

    BB

  6. #6

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Re: transparent PNG on picturebox

    Name:  Knipsel2.PNG
Views: 6508
Size:  11.1 KB

    They not from anti-aliasing, it's the 'transparent' part of the PNG. Which needs to blend with the background...

  7. #7
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: transparent PNG on picturebox

    If you put a "transparent" Image in a PictureBox with Backcolor=Transparent, partly transparent pixels of the image will alpha-blend with the parent control's client area. Here the parent control is the Form. But the black area isn't the client area! You used ExtendFrameIntoClientArea, so it's the frame. The frame uses different painting code to the client area, and there is no way to force it to do alpha blending for you.

    So instead of trying to get alpha blending, make an opaque icon. That isn't hard to do because your background (the extended border) is a solid, unchanging colour. Get the icon image, strip off any unwanted pixels and blend into into a black background. You could do the last step in code, but I think you could get better results in a Paint program with layers and a Feather filter such as Paint.Net.

    BB

    edit: You may want to try making the background colour of the icon image transparent black (0,0,0,0) instead of Color.Black. That way, the icon background will be black over the frame and transparent over the client area.

  8. #8

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Re: transparent PNG on picturebox

    Thanks BB!

Tags for this Thread

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