Results 1 to 12 of 12

Thread: Picture Transparency

  1. #1

    Thread Starter
    Lively Member Spider-Freak's Avatar
    Join Date
    Mar 2005
    Posts
    76

    Question Picture Transparency

    How do I make a picture transparent in Paintshop Pro 7 or VB6 so that when I add image and put the picture, the background will show behind it?

  2. #2
    New Member
    Join Date
    Apr 2005
    Posts
    4

    Re: Picture Transparency

    I have paint shop pro, when you create your "new image" set the background to transparent. then save your image.

    When you place it in VB you have to put it in an "Image box"

    DONT USE A PICTURE BOX OR THE BACKGROUND WILL NEVER SHOW UP TRANSPARENT.

    Thats it. If you have more questions about "Paint Shop Pro" I can help you out with that to. Let me know.

    Doc

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Picture Transparency

    If you have to use a PictureBox then there is a technique called Regioning which will allow you to turn the PictureBox into a funny shape, thus allowing you to cut around the image, simulating transparency. But as Doc_loveless said the Image control is easier to use. It just lacks some of the functionality of the PictureBox.

  4. #4

    Thread Starter
    Lively Member Spider-Freak's Avatar
    Join Date
    Mar 2005
    Posts
    76

    Re: Picture Transparency

    When i put it as transparent when i click new image, can i paste the pic in there? Im not making any images... Here is the image i have : I was going to cut each pic out, for example, im making a browser, so i was going to cut out the back arrow and put it in vb but that pink bg comes up. Just wondering how do you do that "Regioning" thing?
    Attached Images Attached Images  
    Last edited by Spider-Freak; Apr 24th, 2005 at 03:39 PM.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Picture Transparency

    To use Regioning make a picture box without a border (BorderStyle=0) and paste your image in there.

    Here's a demo showing the code you need to turn it into a nice circular picturebox. It works by taking the colour of the 1st pixel of the image (at 0,0) as the background colour and then cutting that colour from the outside of the image; so it's pretty flexible in that you can paste an image with any colour in. Even pink.
    Attached Files Attached Files

  6. #6
    Addicted Member
    Join Date
    Mar 2006
    Posts
    159

    Re: Picture Transparency

    penagate,

    Nice example.

    However, I would like to do the reverse; make the central part transparent.
    I need to use the picturebox control in order to utilise its drawing functions ability to contain a shape.

    What I would like to do is to round off the corners of a webbrowser control.
    At the moment I've placed a picturebox over the webbrowser control and am using the Rounded Rectangle Shape to define the area I want visible. I am now trying to make the area contained in the Rounded Rectangle transparent, leaving the corners opaque.

    Any suggestions how to that?

    Cheers,
    Nap
    Last edited by Napoleon; Apr 25th, 2007 at 06:50 PM.

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Picture Transparency

    @Napoleon,
    You can do so without regioning - by using a transparent usercontrol instead.

    1. Create a UserControl.
    2. Set it's ControlContainer = True and BackStyle = Transparent
    3. FILL the usercontrol with a Rounded Rectangle shape. (For smoother effect,set the Shape's BorderStyle to Transparent.)
    4. Set the shape's FillStyle to Solid.
    5. Now use this user control as the container of your WebBrowser Cotrol.


    PS. It is better idea to create a new thread (with link to the original one) rather than digging up an old one.
    (Possibly CodeBank threads are only exceptions)
    Last edited by iPrank; Apr 27th, 2007 at 03:15 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Picture Transparency

    Hey guys, just a question. Whenever I make a picture with transparent background, the transparent always comes out as black, not pink like the examples in here, and when I put it in an image list it's still black. How can I make my images with transparent bg?

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

    Re: Picture Transparency

    Encoder, this thread is 4 years old. Suggest you start your own thread and supply pertinent details as to how you are creating your bitmaps/images and how you are loading them
    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}

  10. #10
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: Picture Transparency

    Quote Originally Posted by iPrank View Post
    @Napoleon,
    You can do so without regioning - by using a transparent usercontrol instead.

    1. Create a UserControl.
    2. Set it's ControlContainer = True and BackStyle = Transparent
    3. FILL the usercontrol with a Rounded Rectangle shape. (For smoother effect,set the Shape's BorderStyle to Transparent.)
    4. Set the shape's FillStyle to Solid.
    5. Now use this user control as the container of your WebBrowser Cotrol.


    PS. It is better idea to create a new thread (with link to the original one) rather than digging up an old one.
    (Possibly CodeBank threads are only exceptions)
    can you give me a sample?
    my usercontrol show it's black,not Transparent,why?

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,738

    Re: Picture Transparency

    This is 14 years old..

  12. #12
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    437

    Re: Picture Transparency

    Quote Originally Posted by xiaoyao View Post
    my usercontrol show it's black,not Transparent,why?
    To make something transparent for loading a .gif with a specific background color, such as Magenta, all form elements that have a magenta BackColor will become transparent.
    Code:
    Option Explicit
    
    Private Const LWA_COLORKEY    As Long = 1
    Private Const WS_EX_LAYERED   As Long = &H80000
    Private Const GWL_EXSTYLE     As Long = -20
     
    Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
                             ByVal hWnd As Long, _
                             ByVal crKey As Long, _
                             ByVal bAlpha As Byte, _
                             ByVal dwFlags As Long) As Boolean
    Private Declare Function SetWindowLong Lib "user32" _
                             Alias "SetWindowLongW" ( _
                             ByVal hWnd As Long, _
                             ByVal nIndex As Long, _
                             ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" _
                             Alias "GetWindowLongW" ( _
                             ByVal hWnd As Long, _
                             ByVal nIndex As Long) As Long
    Private Sub Form_Load()
        SetWindowLong Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
        SetLayeredWindowAttributes Me.hWnd, vbMagenta, 0, LWA_COLORKEY
    End Sub

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