[
https://issues.apache.org/jira/browse/PDFBOX-1960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13921173#comment-13921173
]
John Hewson commented on PDFBOX-1960:
-------------------------------------
Yes, that appears to be the problem. Our JavaDoc has it backwards, it states
quite clearly that the current matrix will be multiplied by the parameter so
that {{\[this] = \[this] x \[Tx]}} which would indeed be "multiplication".
{code}
/**
* This will take the current matrix and multipy it with a matrix that is
passed in.
*
* @param b The matrix to multiply by.
*
* @return The result of the two multiplied matrices.
*/
public Matrix multiply( Matrix b )
{code}
If this was actually happening then the results would match that of
{{AffineTransform#concatenate}} which performs the same operation, namely
{{\[this] = \[this] x \[Tx]}}.
However, as we've seen "multiply" does not perform the expected multiplication
but actually performs a "premultiply" which is {{\[this] = \[Tx] x \[this]}}.
I've looked in the PDF spec (PDF 32000, p120) and the premultiplication is the
correct thing to do, the PDF spec even uses the term "premultiply".
Suggestion: we should rename "multiply" to "premultiply" and fix the JavaDoc on
Matrix's two "multiply" methods.
> Matrix is wrong
> ---------------
>
> Key: PDFBOX-1960
> URL: https://issues.apache.org/jira/browse/PDFBOX-1960
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 1.8.4, 2.0.0
> Reporter: John Hewson
> Assignee: Maruan Sahyoun
> Priority: Critical
>
> I've been driven insane recently by trying to get pattern fills to render
> correctly. Patterns have their own matrix which is concatenated to the CTM
> and no matter how I applied the transformation, the results were wrong.
> It turns out that org.apache.pdfbox.util.Matrix is not behaving as expected,
> here's an example from a pattern I'm working on. I performed the same
> concatenation (i.e. multiplication) using our Matrix and Java's
> AffineTransform, the results are as follows:
> Java AffineTransform:
> [[2.0, 0.0, 1.251E-12], [0.0, 2.0, 1684.0]] *
> [[0.6, 0.0, 302.6], [0.0, 0.6, 1091.38]] =
> [[1.2, 0.0, 605.2000000000013], [0.0, 1.2, 3866.76]]
> PDFBox Matrix:
> [[2.0,0.0,0.0][0.0,2.0,0.0][1.251E-12,1684.0,1.0]] *
> [[0.6,0.0,0.0][0.0,0.6,0.0][302.6,1091.38,1.0]] =
> [[1.2,0.0,0.0][0.0,1.2,0.0][302.6,2101.78,1.0]]
> I suggest that we remove Matrix and replace it with AffineTransform.
--
This message was sent by Atlassian JIRA
(v6.2#6252)