@@ -1150,16 +1150,18 @@ public void drawImage(PDImage pdImage) throws IOException
11501150 // draw the mask
11511151 BufferedImage mask = pdImage .getImage ();
11521152 AffineTransform imageTransform = new AffineTransform (at );
1153- imageTransform .scale (1.0 / mask .getWidth (), -1.0 / mask .getHeight ());
1154- imageTransform .translate (0 , -mask .getHeight ());
1153+ int maskWidth = mask .getWidth ();
1154+ int maskHeight = mask .getHeight ();
1155+ imageTransform .scale (1.0 / maskWidth , -1.0 / maskHeight );
1156+ imageTransform .translate (0 , -maskHeight );
11551157 AffineTransform full = new AffineTransform (g .getTransform ());
11561158 full .concatenate (imageTransform );
11571159 Matrix m = new Matrix (full );
11581160 double scaleX = Math .abs (m .getScalingFactorX ());
11591161 double scaleY = Math .abs (m .getScalingFactorY ());
11601162
1161- boolean smallMask = mask . getWidth () <= 8 && mask . getHeight () <= 8 ;
1162- if (mask . getWidth () == 1 && mask . getHeight () == 1 )
1163+ boolean smallMask = maskWidth <= 8 && maskHeight <= 8 ;
1164+ if (maskWidth == 1 && maskHeight == 1 )
11631165 {
11641166 // PDFBOX-5802: force usage of the lookup table if it is only 1 pixel
11651167 // (See the comment for PDFBOX-5403 that it isn't done for some
@@ -1180,7 +1182,7 @@ public void drawImage(PDImage pdImage) throws IOException
11801182 // PDFBOX-2171-002-002710-p14.pdf where the "New Harmony Consolidated" and
11811183 // "Sailor Springs" patterns became almost invisible.
11821184 // (We may have to decide this differently in the future, e.g. on b/w relationship)
1183- BufferedImage tmp = new BufferedImage (mask . getWidth (), mask . getHeight () , BufferedImage .TYPE_INT_RGB );
1185+ BufferedImage tmp = new BufferedImage (maskWidth , maskHeight , BufferedImage .TYPE_INT_RGB );
11841186 mask = new LookupOp (getInvLookupTable (), graphics .getRenderingHints ()).filter (mask , tmp );
11851187 }
11861188
@@ -1195,16 +1197,16 @@ public void drawImage(PDImage pdImage) throws IOException
11951197 }
11961198 else if (scaleX != 0 && scaleY != 0 )
11971199 {
1198- while (scaleX < 0.25 || Math .round (mask . getWidth () * scaleX ) < 1 )
1200+ while (scaleX < 0.25 || Math .round (maskWidth * scaleX ) < 1 )
11991201 {
12001202 scaleX *= 2.0 ;
12011203 }
1202- while (scaleY < 0.25 || Math .round (mask . getHeight () * scaleY ) < 1 )
1204+ while (scaleY < 0.25 || Math .round (maskHeight * scaleY ) < 1 )
12031205 {
12041206 scaleY *= 2.0 ;
12051207 }
1206- int w2 = (int ) Math .round (mask . getWidth () * scaleX );
1207- int h2 = (int ) Math .round (mask . getHeight () * scaleY );
1208+ int w2 = (int ) Math .round (maskWidth * scaleX );
1209+ int h2 = (int ) Math .round (maskHeight * scaleY );
12081210
12091211 Image scaledMask = mask .getScaledInstance (w2 , h2 , Image .SCALE_SMOOTH );
12101212 imageTransform .scale (1f / Math .abs (scaleX ), 1f / Math .abs (scaleY ));
@@ -2312,4 +2314,4 @@ private LookupTable getInvLookupTable()
23122314 }
23132315 return invTable ;
23142316 }
2315- }
2317+ }
0 commit comments