mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
djvu: enable color rendering (#3361)
* djvu: enable color rendering * Bump base
This commit is contained in:
2
base
2
base
Submodule base updated: 6002daccd3...78ebb308df
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user