From 148dc4855642678acfee1a4b15b86623faa94cf2 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 27 Oct 2012 14:55:50 +0800 Subject: [PATCH] add column detection in koptconfig Conflicts: koptconfig.lua koptreader.lua --- djvu.c | 6 ++++-- k2pdfopt.c | 7 +++++-- k2pdfopt.h | 3 ++- pdf.c | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/djvu.c b/djvu.c index fd26a1c44..24e1c526f 100644 --- a/djvu.c +++ b/djvu.c @@ -483,9 +483,11 @@ static int reflowPage(lua_State *L) { double word_spacing = luaL_checknumber(L, 9); int text_wrap = luaL_checkint(L, 10); int justification = luaL_checkint(L, 11); - double contrast = luaL_checknumber(L, 12); + int columns = luaL_checkint(L, 12); + double contrast = luaL_checknumber(L, 13); - k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, text_wrap, justification, contrast); + k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, \ + text_wrap, justification, columns, contrast); k2pdfopt_djvu_reflow(page->page_ref, page->doc->context, mode, page->doc->pixelformat); k2pdfopt_rfbmp_size(&width, &height); k2pdfopt_rfbmp_zoom(&dc->zoom); diff --git a/k2pdfopt.c b/k2pdfopt.c index 63274bb0e..a9b5049c7 100644 --- a/k2pdfopt.c +++ b/k2pdfopt.c @@ -475,14 +475,17 @@ static void k2pdfopt_reflow_bmp(MASTERINFO *masterinfo, WILLUSBITMAP *src) { void k2pdfopt_set_params(int bb_width, int bb_height, \ double font_size, double page_margin, \ double line_space, double word_space, \ - int wrapping, int justification, double contrast) { + int wrapping, int justification, \ + int columns, double contrast) { dst_userwidth = bb_width; // dst_width is adjusted in adjust_params_init dst_userheight = bb_height; + zoom_value = font_size; vertical_line_spacing = line_space; word_spacing = word_space; text_wrap = wrapping; + max_columns = columns; gamma_correction = contrast; // contrast is only used by k2pdfopt_mupdf_reflow - zoom_value = font_size; + // margin dst_mar = page_margin; dst_martop = -1.0; diff --git a/k2pdfopt.h b/k2pdfopt.h index bb6978c4b..8ddf8f4de 100644 --- a/k2pdfopt.h +++ b/k2pdfopt.h @@ -29,7 +29,8 @@ void k2pdfopt_set_params(int bb_width, int bb_height, \ double font_size, double page_margin, \ double line_space, double word_space, \ - int wrapping, int justification, double contrast); + int wrapping, int justification, \ + int columns, double contrast); void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx); void k2pdfopt_djvu_reflow(ddjvu_page_t *page, ddjvu_context_t *ctx, ddjvu_render_mode_t mode, ddjvu_format_t *fmt); void k2pdfopt_rfbmp_size(int *width, int *height); diff --git a/pdf.c b/pdf.c index 1c2d5321d..056a31d94 100644 --- a/pdf.c +++ b/pdf.c @@ -523,9 +523,11 @@ static int reflowPage(lua_State *L) { double word_spacing = luaL_checknumber(L, 9); int text_wrap = luaL_checkint(L, 10); int justification = luaL_checkint(L, 11); - double contrast = luaL_checknumber(L, 12); + int columns = luaL_checkint(L, 12); + double contrast = luaL_checknumber(L, 13); - k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, text_wrap, justification, contrast); + k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, \ + text_wrap, justification, columns, contrast); k2pdfopt_mupdf_reflow(page->doc->xref, page->page, page->doc->context); k2pdfopt_rfbmp_size(&width, &height); k2pdfopt_rfbmp_zoom(&dc->zoom);