[ 
https://issues.apache.org/jira/browse/PDFBOX-5547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17638487#comment-17638487
 ] 

Tilman Hausherr edited comment on PDFBOX-5547 at 11/25/22 4:05 PM:
-------------------------------------------------------------------

I found some really weird code at 
https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java

this stores the graphics configuration per BufferedImage types, which makes no 
sense re: bounds. This code shows the problem:
{code}
BufferedImage bim1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
BufferedImage bim2 = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g1 = (Graphics2D) bim1.getGraphics();
Graphics2D g2 = (Graphics2D) bim2.getGraphics();
System.out.println("bounds1: " + g1.getDeviceConfiguration().getBounds());
System.out.println("bounds2: " + g2.getDeviceConfiguration().getBounds());
System.out.println("bounds1: " + g1.getDeviceConfiguration().getBounds());
{code}
the output is
{quote}
bounds1: java.awt.Rectangle[x=0,y=0,width=100,height=100]
bounds2: java.awt.Rectangle[x=0,y=0,width=100,height=100]
bounds1: java.awt.Rectangle[x=0,y=0,width=100,height=100]
{quote}
and it turns out it is a known bug
https://bugs.openjdk.org/browse/JDK-8072682

link found in the Aspose forum
https://forum.aspose.com/t/aspose-slide-18-12-java-11-rendertographics-from-bufferedimage-size-issue/189950/3

I see that I did link that JDK issue in the other JIRA issue, but I failed to 
fully understand it in 2019. I did understand that this workaround wouldn't 
work for jdk9 (because the bounds would be MAXINT) but failed to understand 
that for jdk8, it didn't really work at all. 🤦‍♂


was (Author: tilman):
I found some really weird code at 
https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/awt/image/BufferedImageGraphicsConfig.java

this stores the graphics configuration per BufferedImage types, which makes no 
sense re: bounds. This code shows the problem:
{code}
BufferedImage bim1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
BufferedImage bim2 = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g1 = (Graphics2D) bim1.getGraphics();
Graphics2D g2 = (Graphics2D) bim2.getGraphics();
System.out.println("bounds1: " + g1.getDeviceConfiguration().getBounds());
System.out.println("bounds2: " + g2.getDeviceConfiguration().getBounds());
System.out.println("bounds1: " + g1.getDeviceConfiguration().getBounds());
{code}
the output is
{quote}
bounds1: java.awt.Rectangle[x=0,y=0,width=100,height=100]
bounds2: java.awt.Rectangle[x=0,y=0,width=100,height=100]
bounds1: java.awt.Rectangle[x=0,y=0,width=100,height=100]
{quote}
and it turns out it is a known bug
https://bugs.openjdk.org/browse/JDK-8072682

link found in the Aspose forum
https://forum.aspose.com/t/aspose-slide-18-12-java-11-rendertographics-from-bufferedimage-size-issue/189950/3


> Wrong rectangle in image with stencil
> -------------------------------------
>
>                 Key: PDFBOX-5547
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5547
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: Tilman Hausherr
>            Priority: Minor
>         Attachments: PATTYP2.pdf-1.png, PATTYP2.pdf-1.png-diff.png, 
> PDFBOX-5403-p1.pdf-1.png, PDFBOX-5403-p1.pdf-1.png-diff.png
>
>
> This is to track my efforts on a bug that has happened for years, but not 
> very often, in my rendering regression tests.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to