@@ -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