Solved

Transparent GIFs

Posted on 1998-07-19
3
287 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 61
diffSum example 4 50
jdbc error in jsp application 20 63
sql import cannot be resolved jsp 3 45
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

808 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