-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0, 1.4.2
-
generic, x86
-
generic, windows_xp
Name: rmT116609 Date: 05/27/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
jai_imageio-1_0-rc-lib-windows-i586.zip
A DESCRIPTION OF THE PROBLEM :
When applying a java.awt.image.LookupOp or java.awt.image.RescaleOp on a JPEG image loaded with javax.imageio.ImageIO the result has the wrong colors or throws eM-^^xceptions in native code. The behaviour seems to depend on the ImageReader used. For some cases it helps to create a destination image before calling filter instead of relying on LookupOp.createCompatibleDestImage. The problems do not arise with images loaded via com.sun.image.codec.jpeg.JPEGImageDecoder.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the provided case and run it. Make sure the demo/jfc/Java2D/Java2Demo.jar is in the CLASSPATH since the JPEG picture is taken from this JAR.
The program displays the show the image twice. The image on the left side should show the correct image, the one on the right is wrong.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both images should be the same. This is the case if you comment in (4) and comment out (5) in the source code of the test case.
ACTUAL -
In the provided version of the test case the right image is tinted blue.
If you comment out (2) and comment in (3) the the source code the program fails with the exception given below.
If you now comment out (1) the exception is avoided but the rescaled image has totally wrong (psychodelic) colors.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x2DB7FB8
Function=Java_sun_awt_image_ImagingLib_init+0x22167
Library=C:\java\j2sdk1.4.2\jre\bin\awt.dll
Current Java thread:
at sun.awt.image.ImagingLib.lookupByteRaster(Native Method)
at sun.awt.image.ImagingLib.filter(ImagingLib.java:130)
at java.awt.image.LookupOp.filter(LookupOp.java:273)
at java.awt.image.RescaleOp.filter(RescaleOp.java:498)
at java.awt.image.RescaleOp.filter(RescaleOp.java:415)
at BugLookupOp.<init>(BugLookupOp.java:45)
at BugLookupOp.main(BugLookupOp.java:32)
Dynamic libraries:
0x00400000 - 0x00407000 C:\java\j2sdk1.4.2\bin\javaw.exe
0x77F40000 - 0x77FEE000 C:\WINDOWS\System32\ntdll.dll
0x77E40000 - 0x77F38000 C:\WINDOWS\system32\kernel32.dll
0x77DA0000 - 0x77E3C000 C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78086000 C:\WINDOWS\system32\RPCRT4.dll
0x77D10000 - 0x77D9C000 C:\WINDOWS\system32\USER32.dll
0x77C40000 - 0x77C80000 C:\WINDOWS\system32\GDI32.dll
0x77BE0000 - 0x77C33000 C:\WINDOWS\system32\MSVCRT.dll
0x10000000 - 0x10008000 C:\PROGRA~1\NetInst\NiAMH.dll
0x08000000 - 0x08136000 C:\java\j2sdk1.4.2\jre\bin\client\jvm.dll
0x76AF0000 - 0x76B1D000 C:\WINDOWS\system32\WINMM.dll
0x00920000 - 0x00927000 C:\java\j2sdk1.4.2\jre\bin\hpi.dll
0x00940000 - 0x0094E000 C:\java\j2sdk1.4.2\jre\bin\verify.dll
0x00950000 - 0x00968000 C:\java\j2sdk1.4.2\jre\bin\java.dll
0x00970000 - 0x0097D000 C:\java\j2sdk1.4.2\jre\bin\zip.dll
0x02D60000 - 0x02E6A000 C:\java\j2sdk1.4.2\jre\bin\awt.dll
0x72F70000 - 0x72F93000 C:\WINDOWS\System32\WINSPOOL.DRV
0x76330000 - 0x7634C000 C:\WINDOWS\System32\IMM32.dll
0x77180000 - 0x772A1000 C:\WINDOWS\system32\ole32.dll
0x5B0F0000 - 0x5B124000 C:\WINDOWS\System32\uxtheme.dll
0x030E0000 - 0x03130000 C:\java\j2sdk1.4.2\jre\bin\fontmanager.dll
0x736D0000 - 0x73714000 C:\WINDOWS\System32\ddraw.dll
0x73B30000 - 0x73B36000 C:\WINDOWS\System32\DCIMAN32.dll
0x738B0000 - 0x73977000 C:\WINDOWS\System32\D3DIM700.DLL
0x746A0000 - 0x746E4000 C:\WINDOWS\System32\MSCTF.dll
0x67000000 - 0x6700E000 C:\Programme\WebWasher\wwasher.dll
0x04220000 - 0x04227000 C:\Programme\Logitech\MouseWare\System\LgWndHk.dll
0x04230000 - 0x04253000 C:\java\j2sdk1.4.2\jre\bin\cmm.dll
0x04360000 - 0x0437E000 C:\java\j2sdk1.4.2\jre\bin\jpeg.dll
0x76C50000 - 0x76C72000 C:\WINDOWS\system32\imagehlp.dll
0x6DA00000 - 0x6DA7D000 C:\WINDOWS\system32\DBGHELP.dll
0x77BD0000 - 0x77BD7000 C:\WINDOWS\system32\VERSION.dll
0x76BB0000 - 0x76BBB000 C:\WINDOWS\System32\PSAPI.DLL
Heap at VM Abort:
Heap
def new generation total 576K, used 227K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 40% used [0x10010000, 0x10043ab0, 0x10090000)
from space 64K, 32% used [0x10090000, 0x10095470, 0x100a0000)
to space 64K, 0% used [0x100a0000, 0x100a0000, 0x100b0000)
tenured generation total 1408K, used 829K [0x104f0000, 0x10650000, 0x14010000)
the space 1408K, 58% used [0x104f0000, 0x105bf750, 0x105bf800, 0x10650000)
compacting perm gen total 4096K, used 3877K [0x14010000, 0x14410000, 0x18010000)
the space 4096K, 94% used [0x14010000, 0x143d96a8, 0x143d9800, 0x14410000)
Local Time = Mon May 26 11:52:02 2003
Elapsed Time = 1
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2-beta-b19 mixed mode)
#
# An error report file has been saved as hs_err_pid3524.log.
# Please refer to the file for further information.
#
Process terminated with exit code 1
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import java.awt.image.LookupOp;
import java.awt.image.BufferedImageOp;
import java.awt.image.RescaleOp;
import java.awt.image.ByteLookupTable;
import java.io.IOException;
import java.util.Iterator;
/**
* Wrong colours converting images with {@link LookupOp}.
* The problems seems to lie in {@link LookupOp#createCompatibleDestImage}
* in combination with specific JAI image readers.
* <p>
* Wrong colours/excpetion converting images with {@link RescaleOp}.
* The problems seems to have to do with specific JAI image readers.
*/
public class BugLookupOp
extends JFrame
{
public static void main(String[] args)
{
new BugLookupOp().show();
}
public BugLookupOp()
{
super("BugLookupOp");
setDefaultCloseOperation(EXIT_ON_CLOSE);
// correct conversion for LookupOp/wrong conversion for RescaleOp
BufferedImage i1 = load();
i1 = createBufferedOp().filter(i1, i1);
getContentPane().add(new JLabel(new ImageIcon(i1)), BorderLayout.WEST);
// wrong conversion/exceptions
BufferedImage i2 = load();
i2 = createBufferedOp().filter(i2, null); // (1) comment out this line to avoid the exception with RescaleOp
getContentPane().add(new JLabel(new ImageIcon(i2)), BorderLayout.EAST);
pack();
}
private BufferedImageOp createBufferedOp()
{
// (2) create LookupOp
byte[] lut = new byte[256];
for ( int i = 0; i < 256; i++ )
{
lut[i] = (byte)((i*2/3) & 0x00ff);
}
return new LookupOp(new ByteLookupTable(0, lut), null);
/*
// (3) create RescaleOp
return new RescaleOp(2.0f, 0.0f, null);
*/
}
/** Load image from j2sdk1.4.1_02/demo/jfc/Java2D/Java2Demo.jar. */
private BufferedImage load()
{
try
{
/*
// (4) no problems with this reader
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(getClass().getResourceAsStream("/images/bld.jpg"));
return decoder.decodeAsBufferedImage();
*/
// (5) problems with JAI readers
ImageInputStream iis = ImageIO.createImageInputStream(getClass().getResourceAsStream("/images/bld.jpg"));
ImageReader reader = null;
for ( Iterator i = ImageIO.getImageReaders(iis); i.hasNext(); )
{
reader = (ImageReader)i.next();
if ( reader.getClass() == com.sun.imageio.plugins.jpeg.JPEGImageReader.class ) break; // (6) problems with this reader
// if ( reader.getClass() != com.sun.imageio.plugins.jpeg.JPEGImageReader.class ) break; // (7) no problems with this reader for LookupOp
}
reader.setInput(iis);
return reader.read(0, null);
}
catch(IOException e)
{
e.printStackTrace();
System.exit(1);
return null;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Load images with com.sun.image.codec.jpeg.JPEGImageDecoder.
Give a destination image when calling filter() [does not work for all problems].
(Review ID: 186487)
======================================================================
- duplicates
-
JDK-4886732 AffineTransformOp does not work properly for some of the rendering hints
- Closed