CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2006
    Posts
    64

    Question Picturebox image transparency

    Hi

    Controls used : picturebox control,placed a bmp image on it thru image property of picturebox.Made picturebox back color to transparent.(I have taken an arrow image downloaded from net,it has white background)

    When we place image on the picturebox control and run the application white background is visible. I doent need the white background it should be transparent.

    did with this code also

    Bitmap Logo = new Bitmap(this.pboxMain.Image);
    Logo.MakeTransparent(Logo.GetPixel(1, 1));
    this.pboxMain.Image = (Image)Logo;
    pboxMain.Refresh();

    but still not working....

    help me...

    advance thanks

  2. #2
    Join Date
    Apr 2009
    Location
    Ottawa, ON, Canada
    Posts
    34

    Re: Picturebox image transparency

    Maybe this info can help:

    I store transparent PNG images in an ImageList; but my understanding is, the transparent background is automatically converted to white as ImageList can only store bitmaps. So "transparent" = white for my images.

    Then I programatically load images from ImageList to a Picture that sits on top of a Panel. The background is white unless I set the BackColor property of the Picture to white and Panel to Transparent, in which case the Picture background is transparent as expected.
    Last edited by tr00don; April 1st, 2009 at 09:55 AM.

  3. #3
    Join Date
    Jan 2006
    Posts
    64

    [Resolved] Picturebox image transparency

    Hi,

    That didnt solved my problem.

    I have tried in other way.Took help from one of my friend knowing photoshop to make the image have only arrow.No whitebackground.that made my work.

    Thanks
    vinni

  4. #4
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: Picturebox image transparency

    Code:
    Bitmap Logo = new Bitmap(this.pboxMain.Image);
    Logo.MakeTransparent(Logo.GetPixel(1, 1));
    this.pboxMain.Image = (Image)Logo;
    i have used such code before and mine worked.
    i think yours did not work because the pixel at (1,1) is not purly white.
    in ARGB mode pure with is: Color [A=0, R=0, G=0, B=0]
    even if you had a value like this: Color [A=0, R=1, G=0, B=0] at pixel (1,1) it is not pure white and it is likly that MakeTransparent have only trasparented that pixel only which is not visible to you unless you ZOOM and enlarge image.
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  5. #5
    Join Date
    Oct 2008
    Posts
    116

    Arrow Re: Picturebox image transparency

    A other way is design your image again.

    Example in Yahoo Message, it has many emotions such as ( ) :-? ... so on )

    when you use such image, it'll transparent. And you can make your own image like that.
    My English is very bad. So tell me if Something I talked make u confuse.
    My Ebook Store: www.coding.vn/book.php

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

Featured