From d7f1312c4aa7662d09f7bc9f61a85aff76a0bd22 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 3 Oct 2010 00:12:31 +0000 Subject: Calculate annotation appearance stream transform according to algorithm 8.1 in the spec. --- mupdf/pdf_annot.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 @@ -152,6 +152,26 @@ pdf_freeannot(pdf_annot *annot) fz_free(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) { @@ -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; } } -- cgit v1.2.3