JDK-5054242 : Constants wrong in GIF decoder: GIFs that work in browser are munged by Java
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.1,1.4.2
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-05-27
  • Updated: 2014-03-18
Description

Name: tb29552			Date: 05/27/2004


FULL PRODUCT VERSION :
All JDK back to 1.1

ADDITIONAL OS VERSION INFORMATION :
All OSs

A DESCRIPTION OF THE PROBLEM :
GIF support several "disposal methods" to clear the frame before rendering.  These are represented by constants 0 thru 3.  Your implementation of GIF decoding has these wrong: the constant for "leave the frame alone" which should be 1 is set to 3 in your code, and the constant for "back up the appearance before making this change" which should be 3 is set to 1.  The result is garbage when rendering GIFs which use either of these methods.  Most GIFs use disposal 0, which is why this hasn't been detected in so long.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Decode an animated gif using diposal method=1.  Here's an example:
http://www.benoit-smith.net/sunBug.gif
This works fine in every browser, but it's completly munged by Java.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The GIF should decode correctly.
ACTUAL -
The GIF is decoded incorrectly.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import java.awt.*;

public class GIFTest extends Canvas {
    Image _image;

    public GIFTest(String s) {
        _image = Toolkit.getDefaultToolkit().getImage(s);
    }

    public void paint(Graphics g) {
        if(_image != null)
            g.drawImage(_image, 0, 0, this);
    }

    public static void main(String[] args) {
        String img = "sunBug.gif";

        Frame f = new Frame();
        f.setLayout(new BorderLayout());
        f.add(new GIFTest(img), BorderLayout.CENTER);
        f.pack();
        f.setSize(100, 100);
        f.show();
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Writing the wrong constant into the GIF seems to cause the right code to run, causing the above image to be decoded correctly.  This confirms my observation that you just blew the constant definitions in your GIF decoder.

Also, using full frames with no disposal effects, which results in much larger GIF images, will work around the problem.
(Incident Review ID: 275354) 
======================================================================

Comments
Please re-open if - if fix is in progress or on the plan to fix soon - if this is a P3 (file as P3, not P4)
18-03-2014

EVALUATION Not for tiger.
21-08-2004

PUBLIC COMMENTS .
21-08-2004