Skip to content

Commit

Permalink
mupdf: allow zoom levels that are not a multiple of 10
Browse files Browse the repository at this point in the history
Based on a patch by Nicolas Caramelli.
  • Loading branch information
aligrudi committed Jun 14, 2020
1 parent e89e36c commit 27c9e28
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions djvulibre.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void *doc_draw(struct doc *doc, int p, int zoom, int rotate, int *rows, int *col
ddjvu_page_set_rotation(page, (4 - (rotate / 90 % 4)) & 3);
ddjvu_document_get_pageinfo(doc->doc, p - 1, &info);
dpi = ddjvu_page_get_resolution(page);
iw = ddjvu_page_get_width(page) * zoom * 10 / dpi;
ih = ddjvu_page_get_height(page) * zoom * 10 / dpi;
iw = ddjvu_page_get_width(page) * zoom / dpi;
ih = ddjvu_page_get_height(page) * zoom / dpi;
if (!(bmp = malloc(ih * iw * 3))) {
ddjvu_page_release(page);
return NULL;
Expand Down
14 changes: 7 additions & 7 deletions fbpdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))

#define PAGESTEPS 8
#define MAXZOOM 100
#define MAXZOOM 1000
#define MARGIN 1
#define CTRLKEY(x) ((x) - 96)
#define ISMARK(x) (isalpha(x) || (x) == '\'' || (x) == '`')
Expand All @@ -47,8 +47,8 @@ static int mark[128]; /* mark page number */
static int mark_row[128]; /* mark head position */
static int num = 1; /* page number */
static int numdiff; /* G command page number difference */
static int zoom = 15;
static int zoom_def = 15; /* default zoom */
static int zoom = 150;
static int zoom_def = 150; /* default zoom */
static int rotate;
static int count;
static int invert; /* invert colors? */
Expand Down Expand Up @@ -137,7 +137,7 @@ static void printinfo(void)
{
printf("\x1b[H");
printf("FBPDF: file:%s page:%d(%d) zoom:%d%% \x1b[K\r",
filename, num, doc_pages(doc), zoom * 10);
filename, num, doc_pages(doc), zoom);
fflush(stdout);
}

Expand Down Expand Up @@ -227,7 +227,7 @@ static void mainloop(void)
numdiff = num - getcount(num);
break;
case 'Z':
zoom_def = getcount(zoom);
zoom_def = getcount(zoom / 10) * 10;
break;
case 'i':
printinfo();
Expand Down Expand Up @@ -268,7 +268,7 @@ static void mainloop(void)
srow = prow;
break;
case 'z':
zoom_page(getcount(zoom_def));
zoom_page(getcount(zoom_def / 10) * 10);
break;
case 'w':
zoom_page(pcols ? zoom * scols / pcols : zoom);
Expand Down Expand Up @@ -372,7 +372,7 @@ int main(int argc, char *argv[])
rotate = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]);
break;
case 'z':
zoom = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]);
zoom = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]) * 10;
break;
case 'p':
num = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]);
Expand Down
2 changes: 1 addition & 1 deletion mupdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void *doc_draw(struct doc *doc, int p, int zoom, int rotate, int *rows, int *col
fz_pixmap *pix;
fbval_t *pbuf;
int x, y;
ctm = fz_scale((float) zoom / 10, (float) zoom / 10);
ctm = fz_scale((float) zoom / 100, (float) zoom / 100);
ctm = fz_pre_rotate(ctm, rotate);
pix = fz_new_pixmap_from_page_number(doc->ctx, doc->pdf,
p - 1, ctm, fz_device_rgb(doc->ctx), 0);
Expand Down
3 changes: 2 additions & 1 deletion poppler.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void *doc_draw(struct doc *doc, int p, int zoom, int rotate, int *rows, int *col
unsigned char *dat;
pr.set_render_hint(poppler::page_renderer::antialiasing, true);
pr.set_render_hint(poppler::page_renderer::text_antialiasing, true);
poppler::image img = pr.render_page(page, 72 * zoom / 10, 72 * zoom / 10,
poppler::image img = pr.render_page(page,
(float) 72 * zoom / 100, (float) 72 * zoom / 100,
-1, -1, -1, -1, rotation((rotate + 89) / 90));
h = img.height();
w = img.width();
Expand Down

0 comments on commit 27c9e28

Please sign in to comment.