mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Allow for toggling color rendering
New menu item in Screen submenu. hasColorScreen enabled for SDL device.
This commit is contained in:
@@ -3,9 +3,9 @@ local CacheItem = require("cacheitem")
|
||||
local Document = require("document/document")
|
||||
local DrawContext = require("ffi/drawcontext")
|
||||
local KoptOptions = require("ui/data/koptoptions")
|
||||
local Screen = require("device").screen
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
local pdf = nil
|
||||
|
||||
local PdfDocument = Document:new{
|
||||
_document = false,
|
||||
@@ -16,8 +16,13 @@ local PdfDocument = Document:new{
|
||||
}
|
||||
|
||||
function PdfDocument:init()
|
||||
local pdf = require("ffi/mupdf")
|
||||
pdf.color = Screen:isColorEnabled()
|
||||
if not pdf then pdf = require("ffi/mupdf") end
|
||||
-- mupdf.color has to stay false for kopt to work correctly
|
||||
-- and be accurate (including its job about showing highlight
|
||||
-- boxes). We will turn it on and off in PdfDocument:preRenderPage()
|
||||
-- and :postRenderPage() when mupdf is called without kopt involved.
|
||||
pdf.color = false
|
||||
self:updateColorRendering()
|
||||
self.koptinterface = require("document/koptinterface")
|
||||
self.configurable:loadDefaults(self.options)
|
||||
local ok
|
||||
@@ -39,6 +44,14 @@ function PdfDocument:init()
|
||||
-- end
|
||||
end
|
||||
|
||||
function PdfDocument:preRenderPage()
|
||||
pdf.color = self.render_color
|
||||
end
|
||||
|
||||
function PdfDocument:postRenderPage()
|
||||
pdf.color = false
|
||||
end
|
||||
|
||||
function PdfDocument:unlock(password)
|
||||
if not self._document:authenticatePassword(password) then
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user