Results 1 to 3 of 3

Thread: Soften Edges of a Transparent Image

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Soften Edges of a Transparent Image

    I have an image in a PictureBox and have made it transparent by removing the color I don't want. I would now like to soften the edges of the remaining transparent image. Any ideas on how to do so?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Soften Edges of a Transparent Image

    Not really possible without a ton of work/workarounds, I would think.

    You are using regions to shape the picturebox, correct? Shaped child windows don't support semi-transparency/soft edges, but are supported on top-level windows via the UpdateLayeredWindow API. The option to use that API on child windows was introduced in Windows 8. The closest I think you can come to this with using child controls would be something similar to how XP+ softened their edges on some controls. They actually render themselves with a bit of a buffer/reserved space along the edges, and ask the parent window (i.e., the form or whatever) to draw the overlapped portion into the control's reserved space. Now the control can draw itself blended onto what the parent drew.

    Edited: This is not so simple to do manually. Suggestions follow:
    - Assumption: no animation is occurring wherever the edges of this picbox would end up
    - You'll need a screen capture of your form without the picbox in the capture
    - Your picbox should be sized slightly larger (by a couple pixels) than the image it's shape was created from
    - When you place the picbox, paint the capture to the form to the picbox (or offscreen buffer) using the appropriate offset so what is painted would align up perfectly to the form.
    - Now you can use GDI+ or other blending routines to alpha-blend the picbox's image over the buffered screen capture & then that painted onto the picbox.
    - The overall effect would be similar to Windows themed controls. In fact, if done this way, you wouldn't even need to shape the picbox to begin with
    Last edited by LaVolpe; Mar 10th, 2015 at 06:11 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

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