@@ -683,12 +683,13 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
683683 return parentPaint ;
684684 }
685685 PDColor backdropColor = null ;
686- if (COSName .LUMINOSITY .equals (softMask .getSubType ()))
686+ COSName subType = softMask .getSubType ();
687+ PDTransparencyGroup form = softMask .getGroup ();
688+ if (COSName .LUMINOSITY .equals (subType ))
687689 {
688690 COSArray backdropColorArray = softMask .getBackdropColor ();
689691 if (backdropColorArray != null )
690692 {
691- PDTransparencyGroup form = softMask .getGroup ();
692693 PDColorSpace colorSpace = form .getGroup ().getColorSpace (form .getResources ());
693694 if (colorSpace != null &&
694695 colorSpace .getNumberOfComponents () == backdropColorArray .size ()) // PDFBOX-5795
@@ -697,7 +698,7 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
697698 }
698699 }
699700 }
700- TransparencyGroup transparencyGroup = new TransparencyGroup (softMask . getGroup () , true ,
701+ TransparencyGroup transparencyGroup = new TransparencyGroup (form , true ,
701702 softMask .getInitialTransformationMatrix (), backdropColor );
702703 BufferedImage image = transparencyGroup .getImage ();
703704 if (image == null )
@@ -707,19 +708,19 @@ private Paint applySoftMaskToPaint(Paint parentPaint, PDSoftMask softMask) throw
707708 return parentPaint ;
708709 }
709710 BufferedImage gray = new BufferedImage (image .getWidth (), image .getHeight (), BufferedImage .TYPE_BYTE_GRAY );
710- if (COSName .ALPHA .equals (softMask . getSubType () ))
711+ if (COSName .ALPHA .equals (subType ))
711712 {
712713 gray .setData (image .getAlphaRaster ());
713714 }
714- else if (COSName .LUMINOSITY .equals (softMask . getSubType () ))
715+ else if (COSName .LUMINOSITY .equals (subType ))
715716 {
716717 Graphics g = gray .getGraphics ();
717718 g .drawImage (image , 0 , 0 , null );
718719 g .dispose ();
719720 }
720721 else
721722 {
722- throw new IOException ("Invalid soft mask subtype." );
723+ throw new IOException ("Invalid soft mask subtype: " + subType );
723724 }
724725 gray = adjustImage (gray );
725726 Rectangle2D tpgBounds = transparencyGroup .getBounds ();
0 commit comments