diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 3f0288699..e2afaaae5 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -16,7 +16,6 @@ CreDocument = Document:new{ fallback_font = "Droid Sans Fallback", default_css = "./data/cr3.css", options = CreOptions, - configurable = Configurable, } -- NuPogodi, 20.05.12: inspect the zipfile content diff --git a/frontend/document/djvudocument.lua b/frontend/document/djvudocument.lua index c8f71af8c..005abfd76 100644 --- a/frontend/document/djvudocument.lua +++ b/frontend/document/djvudocument.lua @@ -10,7 +10,6 @@ DjvuDocument = Document:new{ djvulibre_cache_size = nil, dc_null = DrawContext.new(), options = KoptOptions, - configurable = Configurable, koptinterface = KoptInterface, } diff --git a/frontend/document/document.lua b/frontend/document/document.lua index a5b15a913..b2dfd9f9a 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -60,24 +60,26 @@ Document = { number_of_pages = 0, -- if not pageable, length of the document in pixels doc_height = 0, - + -- other metadata title = "", author = "", date = "" }, - + GAMMA_NO_GAMMA = 1.0, - + -- override bbox from orignal page's getUsedBBox bbox = {}, - + -- flag to show whether the document was opened successfully is_open = false, error_message = nil, -- flag to show that the document needs to be unlocked by a password is_locked = false, + + configurable = Configurable, } function Document:new(o) @@ -227,7 +229,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode) size = rect end - -- prepare cache item with contained blitbuffer + -- prepare cache item with contained blitbuffer local tile = TileCacheItem:new{ size = size.w * size.h / 2 + 64, -- estimation excerpt = size, @@ -248,7 +250,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode) dc:setOffset(0, page_size.h) end dc:setZoom(zoom) - + if gamma ~= self.GAMMA_NO_GAMMA then --DEBUG("gamma correction: ", gamma) dc:setGamma(gamma) @@ -294,7 +296,7 @@ function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, re end DEBUG("now painting", tile, rect) target:blitFrom(tile.bb, - x, y, + x, y, rect.x - tile.excerpt.x, rect.y - tile.excerpt.y, rect.w, rect.h) @@ -313,3 +315,4 @@ end require "document/pdfdocument" require "document/djvudocument" require "document/credocument" +require "document/picdocument" diff --git a/frontend/document/pdfdocument.lua b/frontend/document/pdfdocument.lua index 1a376c826..dc6274b0b 100644 --- a/frontend/document/pdfdocument.lua +++ b/frontend/document/pdfdocument.lua @@ -10,7 +10,6 @@ PdfDocument = Document:new{ mupdf_cache_size = 5 * 1024 * 1024, dc_null = DrawContext.new(), options = KoptOptions, - configurable = Configurable, koptinterface = KoptInterface, } diff --git a/frontend/document/picdocument.lua b/frontend/document/picdocument.lua new file mode 100644 index 000000000..19330750f --- /dev/null +++ b/frontend/document/picdocument.lua @@ -0,0 +1,26 @@ + +PicDocument = Document:new{ + _document = false, + dc_null = DrawContext.new(), +} + +function PicDocument:init() + 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 + + +DocumentRegistry:addProvider("jpeg", "application/jpeg", PicDocument) +DocumentRegistry:addProvider("jpg", "application/jpeg", PicDocument)