JDK-4645304 : REGRESSION: red and green disapear in TYPE_USHORT_565_RGB BufferedImage
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-03-01
  • Updated: 2002-05-22
  • Resolved: 2002-05-22
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 02/28/2002


FULL PRODUCT VERSION :
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]



EXTRA RELEVANT SYSTEM CONFIGURATION :
bug appears also in beta3 but not in beta1 or beta2 and not
in any 1.3 versions.

A DESCRIPTION OF THE PROBLEM :
BufferedImage TYPE_USHORT_565_RGB do not copy green and red
channel

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I create a BufferedImage with

Image Image1 = new BufferedImage(getWidth(), getHeight(),
> BufferedImage.TYPE_USHORT_565_RGB);

and paint something (he flag of the RGB country) this
BufferedImage with :
> Graphics2D Graphics1 = (Graphics2D)Image1.getGraphics();
> Graphics1.setColor(Color.blue);
> Graphics1.fillRect(0, 0, getWidth(), getHeight()/3);
> Graphics1.setColor(Color.red);
> Graphics1.fillRect(0, getHeight()/3, getWidth(), getHeight
()/3);
> Graphics1.setColor(Color.green);
> Graphics1.fillRect(0, 2*getHeight()/3, getWidth(),
getHeight()/3);

before beta3 it worked with all kind of bufferedImages
(i.e.TYPE_INT_RGB) but TYPE_USHORT_565_RGB looked more
performant as I paint later produced image in an other
bufferedImage USHORT_565_RGB.
Now all the others bufferedImage continue to work and look
faster but this one is not working anymore (only the blue
works and the green and red are transparent). Once angain I
have others versions of java installed on my computer and
the same code (not recompiled) works with 1.3.1, 1.4beta2
but not with beta3 and RC1.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected the green to be green and the red to be red.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error message

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;

// toto is french equivalent of foo
// works with j2sdk1.3.1, 14.beta2 but not with beta3 and RC1
public class toto
{
  // The JComponent which display the BufferedImage
  private static JComponent JComponent1 = new JComponent()
  {
    public void paint (Graphics Graphics_Arg)
    {
      Image Image2 = new BufferedImage(getWidth(), getHeight(),
                                       BufferedImage.TYPE_USHORT_565_RGB );

      // get a graphics to draw in it
      Graphics2D Graphics2 = (Graphics2D)Image2.getGraphics();

      // for the rotation
      AffineTransform AffineTransform1  = new AffineTransform();

      // The second key of the bug : the rotation !
      AffineTransform1.rotate(0.1);
      Graphics2.setTransform(AffineTransform1);

      // create the "problematic" BufferedImage
      Image Image1 = new BufferedImage(getWidth(), getHeight(),
                                       BufferedImage.TYPE_USHORT_565_RGB );

      // get a graphics to draw in it
      Graphics2D Graphics1 = (Graphics2D)Image1.getGraphics();

      // The 3 color flag of RGB country (don't even try to find it on a map !)
      Graphics1.setColor(Color.blue);
      Graphics1.fillRect(0, 0, getWidth(), getHeight()/3);

      Graphics1.setColor(Color.red);
      Graphics1.fillRect(0, getHeight()/3, getWidth(), getHeight()/3);

      Graphics1.setColor(Color.green);
      Graphics1.fillRect(0, 2*getHeight()/3, getWidth(), getHeight()/3);

      // display the Image1 int the graphics2
      Graphics2.drawImage(Image1, 0, 0, null);

      // display the image2 in the given Graphics_Arg
      Graphics_Arg.drawImage(Image2, 0, 0, null);
      
    }// paint()
  };// new JComponent()
    
  static public void main(String[] Args)
  {
    // we have to put the JComponent in smthg
    JFrame JFrame1 = new JFrame("toto");
    JFrame1.getContentPane().setLayout(new BorderLayout());
    JFrame1.getContentPane().add(JComponent1);
    JFrame1.setSize(200, 200);
    JFrame1.show();
  }
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
I use an other type of BufferedImage because I don't care
the type but others peoples may need a well defined
BufferedImage type

Release Regression From : 1.3.1_02
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 139260) 
======================================================================

Comments
EVALUATION This bug is caused by the same problem as in 4507322 (medialib fails to expand USHORT_565_RGB data properly on little endian systems). Therefore, I'm closing this as a dup of 4507322. ###@###.### 2002-05-22
22-05-2002