Solved

Transparent GIFs

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

831 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