djvu: enable color rendering (#3361)

* djvu: enable color rendering

* Bump base
pull/3362/head
poire-z 7 years ago committed by Frans de Jonge
parent 74242025ff
commit cfa5c8a941

@ -1 +1 @@
Subproject commit 6002daccd327e7227228c092510e4df20321abad
Subproject commit 78ebb308df595c3c6388047db032f6a909820b12

@ -1,3 +1,4 @@
local Blitbuffer = require("ffi/blitbuffer")
local Document = require("document/document")
local DrawContext = require("ffi/drawcontext")
local KoptOptions = require("ui/data/koptoptions")
@ -10,7 +11,7 @@ local DjvuDocument = Document:new{
dc_null = DrawContext.new(),
options = KoptOptions,
koptinterface = nil,
is_color_capable = false,
color_bb_type = Blitbuffer.TYPE_BBRGB24,
}
-- check DjVu magic string to validate
@ -33,7 +34,7 @@ function DjvuDocument:init()
end
local ok
ok, self._document = pcall(djvu.openDocument, self.file, self.djvulibre_cache_size)
ok, self._document = pcall(djvu.openDocument, self.file, self.render_color, self.djvulibre_cache_size)
if not ok then
error(self._document) -- will contain error message
end
@ -43,6 +44,13 @@ function DjvuDocument:init()
self:_readMetadata()
end
function DjvuDocument:updateColorRendering()
Document.updateColorRendering(self) -- will set self.render_color
if self._document then
self._document:setColorRendering(self.render_color)
end
end
function DjvuDocument:getProps()
local _, _, docname = self.file:find(".*/(.*)")
docname = docname or self.file

@ -35,6 +35,8 @@ local Document = {
-- whether this document can be rendered in color
is_color_capable = true,
-- bb type needed by engine for color rendering
color_bb_type = Blitbuffer.TYPE_BBRGB32,
}
@ -337,7 +339,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode)
size = size.w * size.h + 64, -- estimation
excerpt = size,
pageno = pageno,
bb = Blitbuffer.new(size.w, size.h, self.render_color and Blitbuffer.TYPE_BBRGB32 or nil)
bb = Blitbuffer.new(size.w, size.h, self.render_color and self.color_bb_type or nil)
}
-- create a draw context

Loading…
Cancel
Save