From 9cbfb766564d0e80d259e3e0a919d72a75bbb6ee Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 13 Mar 2012 12:40:09 +0100 Subject: Split XPS header. Update Makefile dependencies. Add pixmap w/h accessors. --- apps/mupdfextract.c | 2 +- apps/pdfapp.c | 56 ++++++++++++++++++++++++++++------------------------- apps/win_main.c | 5 ++--- apps/x11_main.c | 5 ++--- 4 files changed, 35 insertions(+), 33 deletions(-) (limited to 'apps') diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c index 398ff6d9..e86a7db1 100644 --- a/apps/mupdfextract.c +++ b/apps/mupdfextract.c @@ -61,7 +61,7 @@ static void savefont(pdf_obj *dict, int num) FILE *f; char *fontname = "font"; int n, len; - char *data; + unsigned char *data; obj = pdf_dict_gets(dict, "FontName"); if (obj) diff --git a/apps/pdfapp.c b/apps/pdfapp.c index e5742645..7c64cdbb 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -199,20 +199,23 @@ static fz_matrix pdfapp_viewctm(pdfapp_t *app) static void pdfapp_panview(pdfapp_t *app, int newx, int newy) { + int image_w = fz_pixmap_width(app->ctx, app->image); + int image_h = fz_pixmap_height(app->ctx, app->image); + if (newx > 0) newx = 0; if (newy > 0) newy = 0; - if (newx + app->image->w < app->winw) - newx = app->winw - app->image->w; - if (newy + app->image->h < app->winh) - newy = app->winh - app->image->h; + if (newx + image_w < app->winw) + newx = app->winw - image_w; + if (newy + image_h < app->winh) + newy = app->winh - image_h; - if (app->winw >= app->image->w) - newx = (app->winw - app->image->w) / 2; - if (app->winh >= app->image->h) - newy = (app->winh - app->image->h) / 2; + if (app->winw >= image_w) + newx = (app->winw - image_w) / 2; + if (app->winh >= image_h) + newy = (app->winh - image_h) / 2; if (newx != app->panx || newy != app->pany) winrepaint(app); @@ -313,8 +316,8 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai if (app->shrinkwrap) { - int w = app->image->w; - int h = app->image->h; + int w = fz_pixmap_width(app->ctx, app->image); + int h = fz_pixmap_height(app->ctx, app->image); if (app->winw == w) app->panx = 0; if (app->winh == h) @@ -711,22 +714,22 @@ void pdfapp_onkey(pdfapp_t *app, int c) break; case 'h': - app->panx += app->image->w / 10; + app->panx += fz_pixmap_width(app->ctx, app->image) / 10; pdfapp_showpage(app, 0, 0, 1); break; case 'j': - app->pany -= app->image->h / 10; + app->pany -= fz_pixmap_height(app->ctx, app->image) / 10; pdfapp_showpage(app, 0, 0, 1); break; case 'k': - app->pany += app->image->h / 10; + app->pany += fz_pixmap_height(app->ctx, app->image) / 10; pdfapp_showpage(app, 0, 0, 1); break; case 'l': - app->panx -= app->image->w / 10; + app->panx -= fz_pixmap_width(app->ctx, app->image) / 10; pdfapp_showpage(app, 0, 0, 1); break; @@ -901,12 +904,13 @@ void pdfapp_onkey(pdfapp_t *app, int c) void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state) { + fz_bbox rect = fz_bound_pixmap(app->image); fz_link *link; fz_matrix ctm; fz_point p; - p.x = x - app->panx + app->image->x; - p.y = y - app->pany + app->image->y; + p.x = x - app->panx + rect.x0; + p.y = y - app->pany + rect.y0; ctm = pdfapp_viewctm(app); ctm = fz_invert_matrix(ctm); @@ -990,10 +994,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta if (app->iscopying) { app->iscopying = 0; - app->selr.x0 = MIN(app->selx, x) - app->panx + app->image->x; - app->selr.x1 = MAX(app->selx, x) - app->panx + app->image->x; - app->selr.y0 = MIN(app->sely, y) - app->pany + app->image->y; - app->selr.y1 = MAX(app->sely, y) - app->pany + app->image->y; + app->selr.x0 = MIN(app->selx, x) - app->panx + rect.x0; + app->selr.x1 = MAX(app->selx, x) - app->panx + rect.x0; + app->selr.y0 = MIN(app->sely, y) - app->pany + rect.y0; + app->selr.y1 = MAX(app->sely, y) - app->pany + rect.y0; winrepaint(app); if (app->selr.x0 < app->selr.x1 && app->selr.y0 < app->selr.y1) windocopy(app); @@ -1008,7 +1012,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta int newy = app->pany + y - app->sely; /* Scrolling beyond limits implies flipping pages */ /* Are we requested to scroll beyond limits? */ - if (newy + app->image->h < app->winh || newy > 0) + if (newy + fz_pixmap_height(app->ctx, app->image) < app->winh || newy > 0) { /* Yes. We can assume that deltay != 0 */ int deltay = y - app->sely; @@ -1030,7 +1034,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta { app->pageno--; pdfapp_showpage(app, 1, 1, 1); - newy = -app->image->h; + newy = -fz_pixmap_height(app->ctx, app->image); } app->beyondy = 0; } @@ -1061,10 +1065,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta else if (app->iscopying) { - app->selr.x0 = MIN(app->selx, x) - app->panx + app->image->x; - app->selr.x1 = MAX(app->selx, x) - app->panx + app->image->x; - app->selr.y0 = MIN(app->sely, y) - app->pany + app->image->y; - app->selr.y1 = MAX(app->sely, y) - app->pany + app->image->y; + app->selr.x0 = MIN(app->selx, x) - app->panx + rect.x0; + app->selr.x1 = MAX(app->selx, x) - app->panx + rect.x0; + app->selr.y0 = MIN(app->sely, y) - app->pany + rect.y0; + app->selr.y1 = MAX(app->sely, y) - app->pany + rect.y0; winrepaint(app); } diff --git a/apps/win_main.c b/apps/win_main.c index 3417a11e..b8a18535 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -355,9 +355,8 @@ void winblitsearch() void winblit() { - fz_bbox bb = fz_bound_pixmap(gapp.image); - int image_w = bb.x1-bb.x0; - int image_h = bb.y1-bb.y0; + int image_w = fz_pixmap_width(gapp.ctx, gapp.image); + int image_h = fz_pixmap_height(gapp.ctx, gapp.image); int image_n = fz_pixmap_components(context, gapp.image); unsigned char *samples = fz_pixmap_pixels(context, gapp.image); int x0 = gapp.panx; diff --git a/apps/x11_main.c b/apps/x11_main.c index fe0196fc..0d7d6375 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -249,9 +249,8 @@ void winhelp(pdfapp_t *app) void winresize(pdfapp_t *app, int w, int h) { - fz_bbox bb = fz_bound_pixmap(gapp.image); - int image_w = bb.x1 - bb.x0; - int image_h = bb.y1 - bb.y0; + int image_w = fz_pixmap_width(gapp.ctx, gapp.image); + int image_h = fz_pixmap_height(gapp.ctx, gapp.image); XWindowChanges values; int mask, width, height; -- cgit v1.2.3