mirror of
https://github.com/koreader/koreader
synced 2024-11-11 19:11:14 +00:00
Fix crash with kopt semi-auto crop on blank page
When such blank page has only a few black pixels (dust), it would result in a really small cropped area, than when scaled to fit screen, would cause a crash with : ./ffi/mupdf.lua:63: could not allocate pixmap: malloc of array (451342 x 612558 bytes) failed (integer overflow) (1) Fix similar to what is done in KoptInterface:getAutoBBox(): when cropped area too small, fall back to whole page (or here: to user's manually set area).
This commit is contained in:
parent
a192178bf6
commit
76f6b49731
@ -180,6 +180,11 @@ function KoptInterface:getSemiAutoBBox(doc, pageno)
|
||||
auto_bbox.x1 = auto_bbox.x1 + bbox.x0
|
||||
auto_bbox.y1 = auto_bbox.y1 + bbox.y0
|
||||
logger.dbg("Semi-auto detected bbox", auto_bbox)
|
||||
local native_size = Document.getNativePageDimensions(doc, pageno)
|
||||
if (auto_bbox.x1 - auto_bbox.x0)/native_size.w < 0.1 and (auto_bbox.y1 - auto_bbox.y0)/native_size.h < 0.1 then
|
||||
logger.dbg("Semi-auto detected bbox too small, using manual bbox")
|
||||
auto_bbox = bbox
|
||||
end
|
||||
page:close()
|
||||
Cache:insert(hash, CacheItem:new{ semiautobbox = auto_bbox })
|
||||
kc:free()
|
||||
|
Loading…
Reference in New Issue
Block a user