Solved

Transparent GIFs

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now