2013-10-22 15:19:08 +00:00
|
|
|
local Document = require("document/document")
|
2013-12-31 05:12:56 +00:00
|
|
|
local DrawContext = require("ffi/drawcontext")
|
2013-10-17 21:34:55 +00:00
|
|
|
|
2013-10-22 15:19:08 +00:00
|
|
|
local PicDocument = Document:new{
|
2013-10-17 21:34:55 +00:00
|
|
|
_document = false,
|
2013-12-31 05:12:56 +00:00
|
|
|
dc_null = DrawContext.new()
|
2013-10-17 21:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function PicDocument:init()
|
2013-12-31 05:12:56 +00:00
|
|
|
require "libs/libkoreader-pic"
|
2013-10-17 21:34:55 +00:00
|
|
|
ok, self._document = pcall(pic.openDocument, self.file)
|
|
|
|
if not ok then
|
|
|
|
self.error_message = "failed to open jpeg image"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
self.info.has_pages = true
|
|
|
|
self.info.configurable = false
|
|
|
|
|
|
|
|
self:readMetadata()
|
|
|
|
end
|
|
|
|
|
|
|
|
function PicDocument:readMetadata()
|
|
|
|
self.info.number_of_pages = 1
|
|
|
|
end
|
|
|
|
|
2013-10-22 15:19:08 +00:00
|
|
|
function PicDocument:register(registry)
|
|
|
|
registry:addProvider("jpeg", "application/jpeg", self)
|
|
|
|
registry:addProvider("jpg", "application/jpeg", self)
|
|
|
|
end
|
2013-10-17 21:34:55 +00:00
|
|
|
|
2013-10-22 15:19:08 +00:00
|
|
|
return PicDocument
|