https://issues.apache.org/bugzilla/show_bug.cgi?id=49516
Advertising
Summary: FOP with SVG - gradient fill opacity incorrectly
inherits stroke opacity of previous svg element
Product: Fop
Version: all
Platform: PC
OS/Version: Windows Vista
Status: NEW
Severity: normal
Priority: P2
Component: pdf
AssignedTo: fop-dev@xmlgraphics.apache.org
ReportedBy: dle...@iress.com.au
Created an attachment (id=25652)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=25652)
SVG with three rectangles. The bottom left rectangle should have a fully opaque
gradient fill, but does not in FOP's PDF output.
To reproduce:
1) Have an FO file in which an SVG (I have only tested with external-graphics)
2) Inside the SVG, have a gradient defined and two elements e.g. rectangles.
Set the stroke opacity of the first element to a value near 0. NOTE: The order
is important - the stroke opacity must be set on the element preceding the
gradient filled element.
3) Make the second element have a gradient fill.
RESULT: The second element's gradient fill will have the same opacity as the
stroke of the preceding element.
** Possible cause **
This is due to Batik's GraphicContext.setPaint() method replacing the
"foreground" Color attribute if it receives a Color instance as a parameter
(due to a "paint instanceof Color" check). The "foreground" of the
GraphicsContext is later used to set the fill opacity in the line inside
PDFGraphics2D.fill() method:
applyAlpha(c.getAlpha(), OPAQUE);
However in this case, batik's GraphicContext.setPaint() is receiving a
LinearGradientPaint object which does not inherit from Color. Thus it does not
set the "foreground" attribute, meaning that an alpha from a previous
setPaint() will be used - in this case, the stroke opacity of the preceding SVG
elemnt.
** Possible hack **
Since the applyAlpha line in PDFGraphics2D.fill() will not be correct when the
paint returned by getPaint() is a gradient, I added an instanceof check so that
it only runs when getPaint() returns an instance of Color. This is not a
thouroughly thought-out fix and therefore should just be regarded as a
workaround hack.
Attaching SVG file and FO, plus hack (most likely not suitable as fix) to get
around issue.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.