How do I make an icon's background transparent?

Discussion in 'Java' started by Todd, Sep 25, 2007.

  1. Todd

    Todd Guest

    Hello all,

    I have created two icons, one with a triangle pointing to the right
    and one with a triangle pointing down. Both of the triangles sit upon
    a white background in the .jpg files. I am using these icons on
    togglebuttons to indicate closed and opened states, respectively.

    However, the white background is annoying on a colored panel. I tried
    setting the opacity to false, no luck. Does anyone know how I can
    make the white background translucent so that the panel color comes
    through?

    Thanks,
    Todd

    p.s. The only thing that I have come up with so far is changing the
    UI, however, I don't want to write one, if there is one that can do
    this for me.
    Todd, Sep 25, 2007
    #1
    1. Advertising

  2. Andrew Thompson, Sep 25, 2007
    #2
    1. Advertising

  3. Andrew Thompson wrote:
    >...
    >>I have created two icons, one with a triangle pointing to the right
    >>and one with a triangle pointing down. Both of the triangles sit upon
    >>a white background in the .jpg files.

    >
    >JPEG images do not support transparency, GIF &
    >PNG formats do.


    ..and also. JPEG is a terrible format for simple 'line'
    drawings. At high compression, the lines will be blurred,
    at low compression, the images will be larger than the
    equivalent GIF or PNG.

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
    Andrew Thompson, Sep 25, 2007
    #3
  4. On Sep 25, 8:55 am, Todd <> wrote:
    > Hello all,
    >
    > I have created two icons, one with a triangle pointing to the right
    > and one with a triangle pointing down. Both of the triangles sit upon
    > a white background in the .jpg files. I am using these icons on
    > togglebuttons to indicate closed and opened states, respectively.
    >
    > However, the white background is annoying on a colored panel. I tried
    > setting the opacity to false, no luck. Does anyone know how I can
    > make the white background translucent so that the panel color comes
    > through?
    >
    > Thanks,
    > Todd
    >
    > p.s. The only thing that I have come up with so far is changing the
    > UI, however, I don't want to write one, if there is one that can do
    > this for me.


    If you are on Windows, use irfanview (http://www.irfanview.com) to
    open the jpg images. Then click 'save as', select 'gif' and check the
    box that says 'transparent background' or something along those
    lines.

    For Linux I believe Gimp has something similar.

    -cheers,
    Manish
    Manish Pandit, Sep 25, 2007
    #4
  5. Todd

    Todd Guest

    Thanks for all the input - success has been found!!
    Todd, Sep 25, 2007
    #5
  6. Todd

    Roedy Green Guest

    On Tue, 25 Sep 2007 08:55:41 -0700, Todd <>
    wrote, quoted or indirectly quoted someone who said :

    >
    >I have created two icons, one with a triangle pointing to the right
    >and one with a triangle pointing down. Both of the triangles sit upon
    >a white background in the .jpg files.


    Ordinary JPGs do not support transparency. You need a png or gif.

    You normally insert the transparency with your paint program. You can
    also create images programatically with transparency using the alpha
    channel.

    See http://mindprod.com/applet/masker.html
    for an example.

    You could also create such an image by painting on a custom JPanel.
    Don't clear the background. Just paint the arrow. You don't need to
    fool about with the alpha channel.

    One other way to do it is to find suitable Unicode glyph and use it in
    a JLabel with a font that supports it.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Sep 25, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miro Durcik

    app.rc resource's icon to .net Icon

    Miro Durcik, Oct 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,381
    Miro Durcik
    Oct 9, 2004
  2. VB Programmer
    Replies:
    0
    Views:
    373
    VB Programmer
    Jun 30, 2003
  3. JWL
    Replies:
    4
    Views:
    576
    Michael Winter
    Sep 26, 2006
  4. Dan Polansky
    Replies:
    3
    Views:
    787
    Larry Barowski
    Feb 12, 2007
  5. Bodi
    Replies:
    1
    Views:
    272
    Lasse Reichstein Nielsen
    Nov 18, 2003
Loading...

Share This Page