mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
feedback zoom value used by page reflow
So that when zoom value exceed the upper limit of reflowable page size user will notice that zoom value cannot be increased. Conflicts: koptreader.lua
This commit is contained in:
8
djvu.c
8
djvu.c
@@ -476,16 +476,16 @@ static int reflowPage(lua_State *L) {
|
||||
DrawContext *dc = (DrawContext*) luaL_checkudata(L, 2, "drawcontext");
|
||||
ddjvu_render_mode_t mode = (int) luaL_checkint(L, 3);
|
||||
|
||||
double dpi = 250*(dc->zoom);
|
||||
|
||||
int width, height;
|
||||
k2pdfopt_djvu_reflow(page->page_ref, page->doc->context, mode, page->doc->pixelformat, dpi);
|
||||
k2pdfopt_djvu_reflow(page->page_ref, page->doc->context, mode, page->doc->pixelformat, dc->zoom);
|
||||
k2pdfopt_rfbmp_size(&width, &height);
|
||||
k2pdfopt_rfbmp_zoom(&dc->zoom);
|
||||
|
||||
lua_pushnumber(L, (double)width);
|
||||
lua_pushnumber(L, (double)height);
|
||||
lua_pushnumber(L, (double)dc->zoom);
|
||||
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int drawReflowedPage(lua_State *L) {
|
||||
|
||||
19
k2pdfopt.c
19
k2pdfopt.c
@@ -409,6 +409,7 @@ static int master_bmp_height = 0;
|
||||
static int max_page_width_pix = 3000;
|
||||
static int max_page_height_pix = 4000;
|
||||
static double shrink_factor = 0.9;
|
||||
static double zoom_value = 1.0;
|
||||
|
||||
static void k2pdfopt_reflow_bmp(MASTERINFO *masterinfo, WILLUSBITMAP *src) {
|
||||
PAGEINFO _pageinfo, *pageinfo;
|
||||
@@ -471,7 +472,7 @@ static void k2pdfopt_reflow_bmp(MASTERINFO *masterinfo, WILLUSBITMAP *src) {
|
||||
}
|
||||
|
||||
void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx, \
|
||||
double dpi, double gamma, double rot_deg) {
|
||||
double zoom, double gamma, double rot_deg) {
|
||||
fz_device *dev;
|
||||
fz_pixmap *pix;
|
||||
fz_rect bounds,bounds2;
|
||||
@@ -480,6 +481,7 @@ void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx, \
|
||||
WILLUSBITMAP _src, *src;
|
||||
|
||||
double dpp;
|
||||
double dpi = 250*zoom;
|
||||
do {
|
||||
dpp = dpi / 72.;
|
||||
pix = NULL;
|
||||
@@ -490,7 +492,9 @@ void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx, \
|
||||
bounds2 = fz_transform_rect(ctm, bounds);
|
||||
bbox = fz_round_rect(bounds2);
|
||||
printf("reading page:%d,%d,%d,%d dpi:%.0f\n",bbox.x0,bbox.y0,bbox.x1,bbox.y1,dpi);
|
||||
dpi = dpi*shrink_factor;
|
||||
zoom_value = zoom;
|
||||
zoom *= shrink_factor;
|
||||
dpi *= zoom;
|
||||
} while (bbox.x1 > max_page_width_pix | bbox.y1 > max_page_height_pix);
|
||||
// ctm=fz_translate(0,-page->mediabox.y1);
|
||||
// ctm=fz_concat(ctm,fz_scale(dpp,-dpp));
|
||||
@@ -529,11 +533,12 @@ 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, double dpi) {
|
||||
ddjvu_render_mode_t mode, ddjvu_format_t *fmt, double zoom) {
|
||||
WILLUSBITMAP _src, *src;
|
||||
ddjvu_rect_t prect;
|
||||
ddjvu_rect_t rrect;
|
||||
int i, iw, ih, idpi, status;
|
||||
double dpi = 250*zoom;
|
||||
|
||||
while (!ddjvu_page_decoding_done(page))
|
||||
handle(1, ctx);
|
||||
@@ -546,7 +551,9 @@ void k2pdfopt_djvu_reflow(ddjvu_page_t *page, ddjvu_context_t *ctx, \
|
||||
prect.w = iw * dpi / idpi;
|
||||
prect.h = ih * dpi / idpi;
|
||||
printf("reading page:%d,%d,%d,%d dpi:%.0f\n",prect.x,prect.y,prect.w,prect.h,dpi);
|
||||
dpi = dpi*shrink_factor;
|
||||
zoom_value = zoom;
|
||||
zoom *= shrink_factor;
|
||||
dpi *= zoom;
|
||||
} while (prect.w > max_page_width_pix | prect.h > max_page_height_pix);
|
||||
rrect = prect;
|
||||
|
||||
@@ -583,6 +590,10 @@ void k2pdfopt_rfbmp_ptr(unsigned char** bmp_ptr_ptr) {
|
||||
*bmp_ptr_ptr = masterinfo->bmp.data;
|
||||
}
|
||||
|
||||
void k2pdfopt_rfbmp_zoom(double *zoom) {
|
||||
*zoom = zoom_value;
|
||||
}
|
||||
|
||||
/* ansi.c */
|
||||
#define MAXSIZE 8000
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ void k2pdfopt_djvu_reflow(ddjvu_page_t *page, ddjvu_context_t *ctx, \
|
||||
ddjvu_render_mode_t mode, ddjvu_format_t *fmt, double dpi);
|
||||
void k2pdfopt_rfbmp_size(int *width, int *height);
|
||||
void k2pdfopt_rfbmp_ptr(unsigned char** bmp_ptr_ptr);
|
||||
void k2pdfopt_rfbmp_zoom(double *zoom);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
8
pdf.c
8
pdf.c
@@ -516,16 +516,16 @@ static int reflowPage(lua_State *L) {
|
||||
PdfPage *page = (PdfPage*) luaL_checkudata(L, 1, "pdfpage");
|
||||
DrawContext *dc = (DrawContext*) luaL_checkudata(L, 2, "drawcontext");
|
||||
|
||||
double dpi = 250*(dc->zoom);
|
||||
|
||||
int width, height;
|
||||
k2pdfopt_mupdf_reflow(page->doc->xref, page->page, page->doc->context, dpi, dc->gamma, 0);
|
||||
k2pdfopt_mupdf_reflow(page->doc->xref, page->page, page->doc->context, dc->zoom, dc->gamma, 0);
|
||||
k2pdfopt_rfbmp_size(&width, &height);
|
||||
k2pdfopt_rfbmp_zoom(&dc->zoom);
|
||||
|
||||
lua_pushnumber(L, (double)width);
|
||||
lua_pushnumber(L, (double)height);
|
||||
lua_pushnumber(L, (double)dc->zoom);
|
||||
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int drawReflowedPage(lua_State *L) {
|
||||
|
||||
Reference in New Issue
Block a user