[ 
https://issues.apache.org/jira/browse/PDFBOX-2881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14628725#comment-14628725
 ] 

Tilman Hausherr edited comment on PDFBOX-2881 at 7/15/15 9:38 PM:
------------------------------------------------------------------

Reopening, now the radial shadings fail. Try e.g. the files asy-ring.pdf, 
asy-shadestroke.pdf, color_gradient.pdf, 
eci_altona-test-suite-v2_technical_H.pdf, PDFBOX-1931.pdf, 
jagpdf_doc_patterns.pdf, GWG060_Shading_x1a.pdf, GWG061_Shading_x1a.pdf, 
jagpdf_sun.pdf

I'm also wondering why you put back the complexity. If I've understood you 
correctly, the device bounds values are pixels. So all there would have to be 
done would be that greek formula, or just add the two values instead (would be 
too high, but this doesn't hurt much).


was (Author: tilman):
Reopening, now the radial shadings fail. Try e.g. the files asy-ring.pdf, 
asy-shadestroke.pdf, color_gradient.pdf, 
eci_altona-test-suite-v2_technical_H.pdf

I'm also wondering why you put back the complexity. If I've understood you 
correctly, the device bounds values are pixels. So all there would have to be 
done would be that greek formula, or just add the two values instead (would be 
too high, but this doesn't hurt much).

> Radial and Axial shading steps are calculated incorrectly
> ---------------------------------------------------------
>
>                 Key: PDFBOX-2881
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2881
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.0
>            Reporter: John Hewson
>            Assignee: John Hewson
>              Labels: shading
>             Fix For: 2.0.0
>
>
> I found a shading bug while writing some code to dump all shadings in a PDF. 
> I don't know if this affects PDF rendering within PageDrawer or not.
> RadialShadingContext and AxialShadingContext use the following code in their 
> constructors to calculate the number of steps (pixels) in the shading and 
> build a lookup table for each step:
> {code}
> // transform the distance to actual pixel space
> // use transform, because xform.getScaleX() does not return correct scaling 
> on 90° rotated matrix
> Point2D point = new Point2D.Double(longestDistance, longestDistance);
> matrix.transform(point);
> xform.transform(point, point);
> factor = (int) Math.max(Math.abs(point.getX()), Math.abs(point.getY()));
> colorTable = calcColorTable();
> {code}
> The variable "factor" is the number of steps and "matrix" is the parent 
> stream's matrix + the pattern matrix, so this code is taking the current 
> scale and assuming that that is equal to the number of pixels. This works 
> when a pattern is painted onto a 0...1 scaled surface, but otherwise it 
> produces incorrect results.
> There's no way to calculate the number of pixels in the device from its 
> scale, or its matrix. Paint#createContext() provides the device bounds 
> Rectangle, which is what we should be using. Indeed, this is handled 
> correctly in the other shading contexts.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to