summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-10-03 00:12:31 +0000
committerTor Andersson <tor@ghostscript.com>2010-10-03 00:12:31 +0000
commitd7f1312c4aa7662d09f7bc9f61a85aff76a0bd22 (patch)
treee15b1257e3a4933428f14c3b878122372de8ba96
parent7288ed3f1e9d13873bf4d04b91df496fa06133b5 (diff)
downloadmupdf-d7f1312c4aa7662d09f7bc9f61a85aff76a0bd22.tar.xz
Calculate annotation appearance stream transform according to algorithm 8.1 in the spec.
-rw-r--r--mupdf/pdf_annot.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mupdf/pdf_annot.c b/mupdf/pdf_annot.c
index 0af7fa18..5c142f04 100644
--- a/mupdf/pdf_annot.c
+++ b/mupdf/pdf_annot.c
@@ -153,6 +153,26 @@ pdf_freeannot(pdf_annot *annot)
}
void
+pdf_transformannot(pdf_annot *annot)
+{
+ fz_matrix matrix = annot->ap->matrix;
+ fz_rect bbox = annot->ap->bbox;
+ fz_rect rect = annot->rect;
+ float w, h, x, y;
+ fz_matrix a, aa;
+
+ bbox = fz_transformrect(matrix, bbox);
+ w = (rect.x1 - rect.x0) / (bbox.x1 - bbox.x0);
+ h = (rect.y1 - rect.y0) / (bbox.y1 - bbox.y0);
+ x = rect.x0 - bbox.x0;
+ y = rect.y0 - bbox.y0;
+ a = fz_concat(fz_scale(w, h), fz_translate(x, y));
+ aa = fz_concat(a, matrix);
+
+ annot->ap->matrix = aa;
+}
+
+void
pdf_loadannots(pdf_annot **headp, pdf_xref *xref, fz_obj *annots)
{
pdf_annot *head, *annot;
@@ -192,6 +212,9 @@ pdf_loadannots(pdf_annot **headp, pdf_xref *xref, fz_obj *annots)
annot->rect = pdf_torect(rect);
annot->ap = form;
annot->next = head;
+
+ pdf_transformannot(annot);
+
head = annot;
}
}