Added getImageFromPosition() and isXPointerInDocument()

Bump base (depends on koreader-base PR #470)
This commit is contained in:
poire-z
2017-01-15 21:42:04 +01:00
committed by Qingping Hou
parent 8549d98805
commit d648d2b66c
3 changed files with 25 additions and 2 deletions

View File

@@ -148,8 +148,23 @@ function CreDocument:getCoverPageImage()
if data and size then
local Mupdf = require("ffi/mupdf")
local ok, image = pcall(Mupdf.renderImage, data, size)
ffi.C.free(data)
if ok then
return image
end
end
end
function CreDocument:getImageFromPosition(pos)
local data, size = self._document:getImageDataFromPosition(pos.x, pos.y)
if data and size then
logger.dbg("CreDocument: got image data from position", data, size)
local Mupdf = require("ffi/mupdf")
-- wrapped with pcall so we always free(data)
local ok, image = pcall(Mupdf.renderImage, data, size)
ffi.C.free(data) -- need that explicite clean
logger.dbg("Mupdf.renderImage", ok, image)
if ok then
ffi.C.free(data)
return image
end
end
@@ -250,6 +265,10 @@ function CreDocument:getXPointer()
return self._document:getXPointer()
end
function CreDocument:isXPointerInDocument(xp)
return self._document:isXPointerInDocument(xp)
end
function CreDocument:getPosFromXPointer(xp)
return self._document:getPosFromXPointer(xp)
end