summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-01-12 01:12:28 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-01-12 01:12:28 +0100
commit9994b3f49db7bd925a7ae7874cbc99025469ee9e (patch)
treec718919738e0c70cc94959aad1b5b4997f11389f /apps
parent09086b236af6e49f2f090f80a450b1d82f217f30 (diff)
downloadmupdf-9994b3f49db7bd925a7ae7874cbc99025469ee9e.tar.xz
Use the same coordinate system for pdf and xps pages in the interface.
Move coordinate space tweaks into pdf_ and xps_run_page, and provide neutral pdf_ and xps_bound_page functions to return the page size as a zero-origined bounding box.
Diffstat (limited to 'apps')
-rw-r--r--apps/pdfapp.c18
-rw-r--r--apps/pdfapp.h1
-rw-r--r--apps/pdfdraw.c8
-rw-r--r--apps/xpsdraw.c10
4 files changed, 11 insertions, 26 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 0f8dd7e3..250ca198 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -260,13 +260,8 @@ void pdfapp_close(pdfapp_t *app)
static fz_matrix pdfapp_viewctm(pdfapp_t *app)
{
fz_matrix ctm;
- ctm = fz_identity;
- ctm = fz_concat(ctm, fz_translate(0, -app->page_bbox.y1));
- if (app->xref)
- ctm = fz_concat(ctm, fz_scale(app->resolution/72.0f, -app->resolution/72.0f));
- else
- ctm = fz_concat(ctm, fz_scale(app->resolution/96.0f, app->resolution/96.0f));
- ctm = fz_concat(ctm, fz_rotate(app->rotate + app->page_rotate));
+ ctm = fz_scale(app->resolution/72.0f, app->resolution/72.0f);
+ ctm = fz_concat(ctm, fz_rotate(app->rotate));
return ctm;
}
@@ -308,8 +303,7 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app)
pdfapp_error(app, "cannot load page");
}
- app->page_bbox = page->mediabox;
- app->page_rotate = page->rotate;
+ app->page_bbox = pdf_bound_page(app->xref, page);
app->page_links = page->links;
page->links = NULL;
@@ -343,11 +337,7 @@ static void pdfapp_loadpage_xps(pdfapp_t *app)
pdfapp_error(app, "cannot load page");
}
- app->page_bbox.x0 = 0;
- app->page_bbox.y0 = 0;
- app->page_bbox.x1 = page->width;
- app->page_bbox.y1 = page->height;
- app->page_rotate = 0;
+ app->page_bbox = xps_bound_page(app->xps, page);
app->page_links = NULL;
/* Create display list */
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index 84d00979..b23f939a 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -45,7 +45,6 @@ struct pdfapp_s
/* current page params */
int pageno;
fz_rect page_bbox;
- float page_rotate;
fz_display_list *page_list;
fz_text_span *page_text;
fz_link *page_links;
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c
index 885103bc..d811df07 100644
--- a/apps/pdfdraw.c
+++ b/apps/pdfdraw.c
@@ -193,17 +193,17 @@ static void drawpage(pdf_xref *xref, int pagenum)
{
float zoom;
fz_matrix ctm;
+ fz_rect bounds;
fz_bbox bbox;
fz_pixmap *pix = NULL;
fz_var(pix);
+ bounds = pdf_bound_page(xref, page);
zoom = resolution / 72;
- ctm = fz_translate(0, -page->mediabox.y1);
- ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
- ctm = fz_concat(ctm, fz_rotate(page->rotate));
+ ctm = fz_scale(zoom, zoom);
ctm = fz_concat(ctm, fz_rotate(rotation));
- bbox = fz_round_rect(fz_transform_rect(ctm, page->mediabox));
+ bbox = fz_round_rect(fz_transform_rect(ctm, bounds));
/* TODO: banded rendering and multi-page ppm */
diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c
index 1058c390..50a2c3e3 100644
--- a/apps/xpsdraw.c
+++ b/apps/xpsdraw.c
@@ -137,13 +137,9 @@ static void drawpage(xps_document *doc, int pagenum)
fz_bbox bbox;
fz_pixmap *pix;
- rect.x0 = rect.y0 = 0;
- rect.x1 = page->width;
- rect.y1 = page->height;
-
- zoom = resolution / 96;
- ctm = fz_translate(0, -page->height);
- ctm = fz_concat(ctm, fz_scale(zoom, zoom));
+ rect = xps_bound_page(doc, page);
+ zoom = resolution / 72;
+ ctm = fz_scale(zoom, zoom);
bbox = fz_round_rect(fz_transform_rect(ctm, rect));
/* TODO: banded rendering and multi-page ppm */