Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How do I make an icon's background transparent?

Reply
Thread Tools

How do I make an icon's background transparent?

 
 
Todd
Guest
Posts: n/a
 
      09-25-2007
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.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      09-25-2007
Todd 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.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200709/1

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      09-25-2007
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.asp...neral/200709/1

 
Reply With Quote
 
Manish Pandit
Guest
Posts: n/a
 
      09-25-2007
On Sep 25, 8:55 am, Todd <(E-Mail Removed)> 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

 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      09-25-2007
Thanks for all the input - success has been found!!

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-25-2007
On Tue, 25 Sep 2007 08:55:41 -0700, Todd <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
DIV background-repeat background-image? For shadow effect jc ASP .Net 3 03-19-2008 04:19 PM
not able to click on background tab and backgrounds in properties to change the background. rex Computer Support 2 12-06-2006 02:26 AM
Background transparent when 'background' is used JWL HTML 4 09-26-2006 05:37 PM
Background Check - Background search - People search mason66 ASP .Net 0 07-27-2006 10:20 AM



Advertisments