Solved

Transparent GIFs

Posted on 1998-07-19
3
290 Views
Last Modified: 2010-03-30
How can I find out the transparent color (RGB) of a GIF in Java app. I have succeeded in finding transparent color INDEX, but this doesn't help, unless I can get the color pallete of the image. Unfortunately my knowledge of Java isn't that good yet.

0
Comment
Question by:shimon_crown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:tomd012698
ID: 1227044
 Are you simply trying to display a transparent image, or are you attempting to process the image?
0
 

Author Comment

by:shimon_crown
ID: 1227045
I would like to process the image.
0
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1227046
You can find the colour that is being used as the transparent one by writing an imagefilter; the following one will do:

class TransFilter extends RGBImageFilter
{      static int transcol;

      TransFilter()
      {      canFilterIndexColorModel=true;
            return;
      }

      public int filterRGB(int x,int y,int rgb)
      {      if((rgb&0xff000000)==0)transcol=rgb;
            return(rgb);
      }
}

Colour is encoded in the rgb variable as: alpha channel, red, green and blue in the respective four bytes. So when the alpha channel is 0 (transparent) store the colour in transcol for later inspection.

Remember that for the filter to be activated the image must get "used" in some fashion, for instance displaying it, or loading it with a mediatracker etc.

If you need more specifics on how to use a filter, feel free to ask.

0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaFX TableView not displaying correctly 3 145
program arguments vs VM arguments 4 53
How to log java errors in tomcat 8 34
Firefox and firebub 5 21
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question