-
Bug
-
Resolution: Unresolved
-
P3
-
9, 10, 11
ADDITIONAL SYSTEM INFORMATION :
Running on Windows 10, Java 10.0.1.
A DESCRIPTION OF THE PROBLEM :
In some cases, a simple transform and clip region will cause the drawLine() method in Graphics2D not to work at all.
The Graphics2D is created from a BufferedImage.createGraphics() call, the image type is TYPE_INT_RGB.
This works fine on earlier versions of Java up to 1.8.0, but it is broken in Java 9 and Java 10.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new BufferedImage of type TYPE_INT_RGB. Create a Graphics2D object to draw onto the image by calling BufferedImage.createGraphics().
Fill the image with a white background, then apply a simple transform and clip.
Set the color to black and call the drawLine() method in Graphics2D.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The line should appear at the given location on the image.
ACTUAL -
No line.
The line shows up in Java 6, Java 7, Java 8, but not in Java 9.0.4 and not in Java 10.0.1.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class LineBug
{
public static void main(String [] args)
{
try
{
// Create image and get Graphics2D
BufferedImage bi = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
// Fill white and set basic properties
g2.setColor(Color.white);
g2.fillRect(0, 0, 1000, 1000);
g2.setColor(Color.black);
g2.setStroke(new BasicStroke(1));
// Set transform and clip
g2.setTransform(new AffineTransform(0.5, 0, 0, 0.5, 100, 100));
g2.setClip(new Rectangle2D.Double(-1, 0, 2, 386));
// Draw the line
g2.drawLine(0, 0, 0, 385);
// Write the output image
ImageIO.write(bi, "png", new File("linebug.png"));
}
catch(Throwable t)
{
t.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround found yet.
FREQUENCY : always
Running on Windows 10, Java 10.0.1.
A DESCRIPTION OF THE PROBLEM :
In some cases, a simple transform and clip region will cause the drawLine() method in Graphics2D not to work at all.
The Graphics2D is created from a BufferedImage.createGraphics() call, the image type is TYPE_INT_RGB.
This works fine on earlier versions of Java up to 1.8.0, but it is broken in Java 9 and Java 10.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new BufferedImage of type TYPE_INT_RGB. Create a Graphics2D object to draw onto the image by calling BufferedImage.createGraphics().
Fill the image with a white background, then apply a simple transform and clip.
Set the color to black and call the drawLine() method in Graphics2D.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The line should appear at the given location on the image.
ACTUAL -
No line.
The line shows up in Java 6, Java 7, Java 8, but not in Java 9.0.4 and not in Java 10.0.1.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class LineBug
{
public static void main(String [] args)
{
try
{
// Create image and get Graphics2D
BufferedImage bi = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
// Fill white and set basic properties
g2.setColor(Color.white);
g2.fillRect(0, 0, 1000, 1000);
g2.setColor(Color.black);
g2.setStroke(new BasicStroke(1));
// Set transform and clip
g2.setTransform(new AffineTransform(0.5, 0, 0, 0.5, 100, 100));
g2.setClip(new Rectangle2D.Double(-1, 0, 2, 386));
// Draw the line
g2.drawLine(0, 0, 0, 385);
// Write the output image
ImageIO.write(bi, "png", new File("linebug.png"));
}
catch(Throwable t)
{
t.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround found yet.
FREQUENCY : always