Skip to content

Commit

Permalink
Merge pull request #7 from chrox/kopt_opt
Browse files Browse the repository at this point in the history
update k2pdfopt to version 1.65 & avoid resampling in most case
  • Loading branch information
houqp committed Apr 11, 2013
2 parents 21a34af + 3b857f4 commit 89b5d13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,21 +572,19 @@ static int reflowPage(lua_State *L) {
bounds.x1 = kctx->bbox.x1;
bounds.y1 = kctx->bbox.y1;

double dpp,zoom;
zoom = kctx->zoom;
double dpi = 250*zoom*kctx->quality;

do {
dpp = dpi / 72.;
ctm = fz_scale(dpp, dpp);
// ctm=fz_concat(ctm,fz_rotate(rotation));
bounds2 = fz_transform_rect(ctm, bounds);
bbox = fz_round_rect(bounds2);
printf("reading page:%d,%d,%d,%d zoom:%.2f dpi:%.0f\n",bbox.x0,bbox.y0,bbox.x1,bbox.y1,zoom,dpi);
kctx->zoom = zoom;
zoom *= kctx->shrink_factor;
dpi *= kctx->shrink_factor;
} while (bbox.x1 > kctx->read_max_width | bbox.y1 > kctx->read_max_height);
// probe scale
double zoom = kctx->zoom*kctx->quality;
float scale = 1.0;
ctm = fz_scale(scale, scale);
bounds2 = fz_transform_rect(ctm, bounds);
bbox = fz_round_rect(bounds2);
scale /= ((double)bbox.x1 / (2*zoom*kctx->dev_width) + \
(double)bbox.y1 / (2*zoom*kctx->dev_height))/2;
// do real scale
ctm = fz_scale(scale, scale);
bounds2 = fz_transform_rect(ctm, bounds);
bbox = fz_round_rect(bounds2);
printf("reading page:%d,%d,%d,%d scale:%.2f\n",bbox.x0,bbox.y0,bbox.x1,bbox.y1,scale);

pix = fz_new_pixmap_with_bbox(page->doc->context, fz_device_gray, bbox);
fz_clear_pixmap_with_value(page->doc->context, pix, 0xff);
Expand Down

0 comments on commit 89b5d13

Please sign in to comment.