diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mudraw.c | 1 | ||||
-rw-r--r-- | apps/mupdfextract.c | 5 | ||||
-rw-r--r-- | apps/mupdfshow.c | 3 | ||||
-rw-r--r-- | apps/pdfapp.c | 3 | ||||
-rw-r--r-- | apps/pdfapp.h | 7 | ||||
-rw-r--r-- | apps/win_main.c | 2 | ||||
-rw-r--r-- | apps/x11_image.c | 8 | ||||
-rw-r--r-- | apps/x11_main.c | 44 |
8 files changed, 43 insertions, 30 deletions
diff --git a/apps/mudraw.c b/apps/mudraw.c index 46da1949..8b3aebf5 100644 --- a/apps/mudraw.c +++ b/apps/mudraw.c @@ -3,7 +3,6 @@ */ #include "fitz.h" -#include "mupdf.h" #ifdef _MSC_VER #include <winsock2.h> diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c index 069f7233..1f53541b 100644 --- a/apps/mupdfextract.c +++ b/apps/mupdfextract.c @@ -2,8 +2,7 @@ * pdfextract -- the ultimate way to extract images and fonts from pdfs */ -#include "fitz.h" -#include "mupdf-internal.h" +#include "mupdf.h" static pdf_document *doc = NULL; static fz_context *ctx = NULL; @@ -180,7 +179,7 @@ int main(int argc, char **argv) if (fz_optind == argc) { - for (o = 0; o < doc->len; o++) + for (o = 0; o < pdf_count_objects(doc); o++) showobject(o); } else diff --git a/apps/mupdfshow.c b/apps/mupdfshow.c index 475dc5a9..94aa90d6 100644 --- a/apps/mupdfshow.c +++ b/apps/mupdfshow.c @@ -2,7 +2,6 @@ * pdfshow -- the ultimate pdf debugging tool */ -#include "fitz.h" #include "mupdf-internal.h" static pdf_document *doc = NULL; @@ -145,7 +144,7 @@ static void showgrep(char *filename) pdf_obj *obj; int i; - for (i = 0; i < doc->len; i++) + for (i = 0; i < pdf_count_objects(doc); i++) { if (doc->table[i].type == 'n' || doc->table[i].type == 'o') { diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 68b4b945..4f093508 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -1,8 +1,7 @@ -#include "fitz.h" +#include "pdfapp.h" #include "mupdf.h" #include "muxps.h" #include "mucbz.h" -#include "pdfapp.h" #include <ctype.h> /* for tolower() */ diff --git a/apps/pdfapp.h b/apps/pdfapp.h index bb067bb4..0c1b6ac4 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -1,3 +1,8 @@ +#ifndef PDFAPP_H +#define PDFAPP_H + +#include "fitz.h" + /* * Utility object for handling a pdf application / view * Takes care of PDF loading and displaying and navigation, @@ -106,3 +111,5 @@ void pdfapp_onresize(pdfapp_t *app, int w, int h); void pdfapp_invert(pdfapp_t *app, fz_bbox rect); void pdfapp_inverthit(pdfapp_t *app); + +#endif diff --git a/apps/win_main.c b/apps/win_main.c index 1052ccdd..6cb1f7e1 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -1,5 +1,5 @@ #include "fitz.h" -#include "mupdf.h" +#include "mupdf-internal.h" #include "muxps.h" #include "mucbz.h" #include "pdfapp.h" diff --git a/apps/x11_image.c b/apps/x11_image.c index 35b32c7e..06764313 100644 --- a/apps/x11_image.c +++ b/apps/x11_image.c @@ -22,6 +22,12 @@ extern int ffs(int); +static int is_big_endian(void) +{ + static const int one = 1; + return *(char*)&one == 0; +} + typedef void (*ximage_convert_func_t) ( const unsigned char *src, @@ -212,7 +218,7 @@ select_mode(void) unsigned long rs, gs, bs; byteorder = ImageByteOrder(info.display); - if (fz_is_big_endian()) + if (is_big_endian()) byterev = byteorder != MSBFirst; else byterev = byteorder != LSBFirst; diff --git a/apps/x11_main.c b/apps/x11_main.c index 281618ef..091f0ec6 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -1,7 +1,3 @@ -#include "fitz.h" -#include "mupdf.h" -#include "muxps.h" -#include "mucbz.h" #include "pdfapp.h" #include <X11/Xlib.h> @@ -253,6 +249,9 @@ 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; XWindowChanges values; int mask, width, height; @@ -287,7 +286,7 @@ void winresize(pdfapp_t *app, int w, int h) } XSetForeground(xdpy, xgc, WhitePixel(xdpy, xscr)); - XFillRectangle(xdpy, xwin, xgc, 0, 0, gapp.image->w, gapp.image->h); + XFillRectangle(xdpy, xwin, xgc, 0, 0, image_w, image_h); XFlush(xdpy); if (width != reqw || height != reqh) @@ -338,10 +337,15 @@ static void winblitsearch(pdfapp_t *app) static void winblit(pdfapp_t *app) { + fz_bbox bb = fz_bound_pixmap(gapp.image); + int image_w = bb.x1 - bb.x0; + int image_h = bb.y1 - bb.y0; + int image_n = fz_pixmap_components(gapp.ctx, gapp.image); + unsigned char *image_samples = fz_pixmap_pixels(gapp.ctx, gapp.image); int x0 = gapp.panx; int y0 = gapp.pany; - int x1 = gapp.panx + gapp.image->w; - int y1 = gapp.pany + gapp.image->h; + int x1 = gapp.panx + image_w; + int y1 = gapp.pany + image_h; XSetForeground(xdpy, xgc, xbgcolor.pixel); fillrect(0, 0, x0, gapp.winh); @@ -350,8 +354,8 @@ static void winblit(pdfapp_t *app) fillrect(0, y1, gapp.winw, gapp.winh - y1); XSetForeground(xdpy, xgc, xshcolor.pixel); - fillrect(x0+2, y1, gapp.image->w, 2); - fillrect(x1, y0+2, 2, gapp.image->h); + fillrect(x0+2, y1, image_w, 2); + fillrect(x1, y0+2, 2, image_h); if (gapp.iscopying || justcopied) { @@ -361,21 +365,21 @@ static void winblit(pdfapp_t *app) pdfapp_inverthit(&gapp); - if (gapp.image->n == 4) + if (image_n == 4) ximage_blit(xwin, xgc, x0, y0, - gapp.image->samples, + image_samples, 0, 0, - gapp.image->w, - gapp.image->h, - gapp.image->w * gapp.image->n); - else if (gapp.image->n == 2) + image_w, + image_h, + image_w * image_n); + else if (image_n == 2) { - int i = gapp.image->w*gapp.image->h; + int i = image_w*image_h; unsigned char *color = malloc(i*4); if (color) { - unsigned char *s = gapp.image->samples; + unsigned char *s = image_samples; unsigned char *d = color; for (; i > 0 ; i--) { @@ -387,9 +391,9 @@ static void winblit(pdfapp_t *app) x0, y0, color, 0, 0, - gapp.image->w, - gapp.image->h, - gapp.image->w * 4); + image_w, + image_h, + image_w * 4); free(color); } } |