-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
5.0_06
A DESCRIPTION OF THE PROBLEM :
Method Graphics2D.drawImage(...) stops a run of program in case, the image is modified by Photoshop version 8.0.1 . See source code for detail.
Notes:
- no exception appears
- using the method setRenderingHint(...) is fundamental
- the method drawImage() envokes an never ending loop probably.
- resize solution by AfineTransformOp class is the same wrong.
- the image files are not corrupted and can be opened simply by MSIE, Mozilla and more viewers.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Resize an image.
ACTUAL -
Method Graphics2D.drawImage(...) stops a program
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* Source include Photoshop image:
* http://java_img_test.pponec.net/TEST.ZIP
*/
package test;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
public class PhotoTest {
public void test() throws Throwable {
// The Image was modifiled by Photoshop:
InputStream file = getClass().getResourceAsStream("/test/img.jpg");
Iterator readers = ImageIO.getImageReadersBySuffix("jpg");
ImageReader reader = (ImageReader) readers.next();
ImageInputStream iis = ImageIO.createImageInputStream(file);
reader.setInput(iis, true); // true means SingleFrame
ImageReadParam param = reader.getDefaultReadParam();
BufferedImage imgOriginal = reader.read(0, param);
iis.close();
// Make a thumbnail:
BufferedImage imgSmall = new BufferedImage(700, 75, imgOriginal.getType());
Graphics2D graphics2D = imgSmall.createGraphics();
graphics2D.setRenderingHint
( RenderingHints.KEY_INTERPOLATION
, RenderingHints.VALUE_INTERPOLATION_BILINEAR
) ;
System.out.println("STARTING drawImage(...)");
// --- THE LAST STATEMENT: ----
graphics2D.drawImage(imgOriginal, 0, 0, 100, 75, null);
System.out.println("FINISHED drawImage(...)");
graphics2D.dispose();
}
/** Run the class */
public static void main(String[] args) {
try {
new PhotoTest().test();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
5.0_06
A DESCRIPTION OF THE PROBLEM :
Method Graphics2D.drawImage(...) stops a run of program in case, the image is modified by Photoshop version 8.0.1 . See source code for detail.
Notes:
- no exception appears
- using the method setRenderingHint(...) is fundamental
- the method drawImage() envokes an never ending loop probably.
- resize solution by AfineTransformOp class is the same wrong.
- the image files are not corrupted and can be opened simply by MSIE, Mozilla and more viewers.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Resize an image.
ACTUAL -
Method Graphics2D.drawImage(...) stops a program
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* Source include Photoshop image:
* http://java_img_test.pponec.net/TEST.ZIP
*/
package test;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
public class PhotoTest {
public void test() throws Throwable {
// The Image was modifiled by Photoshop:
InputStream file = getClass().getResourceAsStream("/test/img.jpg");
Iterator readers = ImageIO.getImageReadersBySuffix("jpg");
ImageReader reader = (ImageReader) readers.next();
ImageInputStream iis = ImageIO.createImageInputStream(file);
reader.setInput(iis, true); // true means SingleFrame
ImageReadParam param = reader.getDefaultReadParam();
BufferedImage imgOriginal = reader.read(0, param);
iis.close();
// Make a thumbnail:
BufferedImage imgSmall = new BufferedImage(700, 75, imgOriginal.getType());
Graphics2D graphics2D = imgSmall.createGraphics();
graphics2D.setRenderingHint
( RenderingHints.KEY_INTERPOLATION
, RenderingHints.VALUE_INTERPOLATION_BILINEAR
) ;
System.out.println("STARTING drawImage(...)");
// --- THE LAST STATEMENT: ----
graphics2D.drawImage(imgOriginal, 0, 0, 100, 75, null);
System.out.println("FINISHED drawImage(...)");
graphics2D.dispose();
}
/** Run the class */
public static void main(String[] args) {
try {
new PhotoTest().test();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-4883787 REG: Rendering a TYPE_CUSTOM buffered image (read using ImageIO) takes long time
- Open
-
JDK-4705399 drawImage can be extremely slow for drawing scaled instances
- Resolved
-
JDK-6399616 PIT:JPGReader throws exception when using TYPE_CUSTOM TypeSpecifier returned by Reader.getImageTypes
- Closed