Skip to content

Commit

Permalink
fixed zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse McClure committed May 13, 2014
1 parent 28ad371 commit dd52162
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/actions.c
Expand Up @@ -138,17 +138,15 @@ static void zoom_rect(int x1, int y1, int x2, int y2) {
poppler_page_get_size(page, &pdfw, &pdfh);
cairo_set_source_rgba(ctx, 1, 1, 1, 1);
cairo_paint(ctx);
/**** testing: ******/
double scx = show->w / pdfw, scy = show->h / pdfh;
double dx = 0.0, dy = 0.0;
if (conf.lock_aspect) {
if (scx > scy) dx = (show->w - pdfw * (scx=scy)) / 2.0;
else dy = (show->h - pdfh * (scy=scx)) / 2.0;
}
cairo_scale(ctx, show->w /(double) (x2-x1), show->h /(double) (y2-y1));
cairo_translate(ctx, dx - x1, dy - y1);
if (!conf.lock_aspect) cairo_scale(ctx, scx, scy);
/********************/
double scx = show->w / pdfw, scy = show->h / pdfh;
double dx = 0.0, dy = 0.0;
if (conf.lock_aspect) {
if (scx > scy) dx = (show->w - pdfw * (scx=scy)) / 2.0;
else dy = (show->h - pdfh * (scy=scx)) / 2.0;
}
cairo_scale(ctx, scx * show->w /(double) (x2-x1),
scy * show->h /(double) (y2-y1));
cairo_translate(ctx, (dx - x1)/scx, (dy - y1)/scy);
poppler_page_render(page, ctx);
cairo_set_source_surface(show->target[0].ctx, buf, 0, 0);
int i;
Expand Down

0 comments on commit dd52162

Please sign in to comment.