Skip to content

Commit 9266108

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov, closes #368
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930426 13f79535-47bb-0310-9956-ffa450edef68
1 parent fa498ad commit 9266108

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,13 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
610610
return parentPaint;
611611
}
612612
PDColor backdropColor = null;
613-
if (COSName.LUMINOSITY.equals(softMask.getSubType()))
613+
COSName subType = softMask.getSubType();
614+
PDTransparencyGroup form = softMask.getGroup();
615+
if (COSName.LUMINOSITY.equals(subType))
614616
{
615617
COSArray backdropColorArray = softMask.getBackdropColor();
616618
if (backdropColorArray != null)
617619
{
618-
PDTransparencyGroup form = softMask.getGroup();
619620
PDColorSpace colorSpace = form.getGroup().getColorSpace(form.getResources());
620621
if (colorSpace != null &&
621622
colorSpace.getNumberOfComponents() == backdropColorArray.size()) // PDFBOX-5795
@@ -624,7 +625,7 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
624625
}
625626
}
626627
}
627-
TransparencyGroup transparencyGroup = new TransparencyGroup(softMask.getGroup(), true,
628+
TransparencyGroup transparencyGroup = new TransparencyGroup(form, true,
628629
softMask.getInitialTransformationMatrix(), backdropColor);
629630
BufferedImage image = transparencyGroup.getImage();
630631
if (image == null)
@@ -634,19 +635,19 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
634635
return parentPaint;
635636
}
636637
BufferedImage gray = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
637-
if (COSName.ALPHA.equals(softMask.getSubType()))
638+
if (COSName.ALPHA.equals(subType))
638639
{
639640
gray.setData(image.getAlphaRaster());
640641
}
641-
else if (COSName.LUMINOSITY.equals(softMask.getSubType()))
642+
else if (COSName.LUMINOSITY.equals(subType))
642643
{
643644
Graphics g = gray.getGraphics();
644645
g.drawImage(image, 0, 0, null);
645646
g.dispose();
646647
}
647648
else
648649
{
649-
throw new IOException("Invalid soft mask subtype.");
650+
throw new IOException("Invalid soft mask subtype: " + subType);
650651
}
651652
gray = adjustImage(gray);
652653

0 commit comments

Comments
 (0)