mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
black_hex & white_hex added
This commit is contained in:
@@ -99,6 +99,8 @@ function KoptInterface:setDefaultConfigurable(configurable)
|
||||
configurable.page_margin = G_defaults:readSetting("DKOPTREADER_CONFIG_PAGE_MARGIN")
|
||||
configurable.quality = G_defaults:readSetting("DKOPTREADER_CONFIG_RENDER_QUALITY")
|
||||
configurable.contrast = G_defaults:readSetting("DKOPTREADER_CONFIG_CONTRAST")
|
||||
configurable.black_hex = G_defaults:readSetting("DKOPTREADER_CONFIG_BLACK_HEX")
|
||||
configurable.white_hex = G_defaults:readSetting("DKOPTREADER_CONFIG_WHITE_HEX")
|
||||
configurable.defect_size = G_defaults:readSetting("DKOPTREADER_CONFIG_DEFECT_SIZE")
|
||||
configurable.line_spacing = G_defaults:readSetting("DKOPTREADER_CONFIG_LINE_SPACING")
|
||||
configurable.word_spacing = G_defaults:readSetting("DKOPTREADER_CONFIG_DEFAULT_WORD_SPACING")
|
||||
@@ -150,6 +152,8 @@ function KoptInterface:createContext(doc, pageno, bbox)
|
||||
kc:setQuality(doc.configurable.quality)
|
||||
-- k2pdfopt (for reflowing) and mupdf use different algorithms to apply gamma when rendering
|
||||
kc:setContrast(1 / doc.configurable.contrast)
|
||||
kc:setForegroundHex(doc.configurable.black_hex)
|
||||
kc:setBackgroundHex(doc.configurable.white_hex)
|
||||
kc:setDefectSize(doc.configurable.defect_size)
|
||||
kc:setLineSpacing(doc.configurable.line_spacing)
|
||||
kc:setWordSpacing(doc.configurable.word_spacing)
|
||||
@@ -384,19 +388,19 @@ function KoptInterface:getCoverPageImage(doc)
|
||||
local native_size = Document.getNativePageDimensions(doc, 1)
|
||||
local canvas_size = CanvasContext:getSize()
|
||||
local zoom = math.min(canvas_size.w / native_size.w, canvas_size.h / native_size.h)
|
||||
local tile = Document.renderPage(doc, 1, nil, zoom, 0, 1.0)
|
||||
local tile = Document.renderPage(doc, 1, nil, zoom, 0, 1.0, 0x000000, 0xFFFFFF)
|
||||
if tile then
|
||||
return tile.bb:copy()
|
||||
end
|
||||
end
|
||||
|
||||
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, hinting)
|
||||
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting)
|
||||
if doc.configurable.text_wrap == 1 then
|
||||
return self:renderReflowedPage(doc, pageno, rect, zoom, rotation, hinting)
|
||||
elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then
|
||||
return self:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hinting)
|
||||
else
|
||||
return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, hinting)
|
||||
return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -491,16 +495,16 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hi
|
||||
end
|
||||
end
|
||||
|
||||
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma)
|
||||
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, black_hex, white_hex)
|
||||
--- @note: Crappy safeguard around memory issues like in #7627: if we're eating too much RAM, drop half the cache...
|
||||
DocCache:memoryPressureCheck()
|
||||
|
||||
if doc.configurable.text_wrap == 1 then
|
||||
self:hintReflowedPage(doc, pageno, zoom, rotation, gamma, true)
|
||||
self:hintReflowedPage(doc, pageno, zoom, rotation, gamma, black_hex, white_hex, true)
|
||||
elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then
|
||||
self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, gamma, true)
|
||||
self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, gamma, black_hex, white_hex, true)
|
||||
else
|
||||
Document.hintPage(doc, pageno, zoom, rotation, gamma)
|
||||
Document.hintPage(doc, pageno, zoom, rotation, gamma, black_hex, white_hex)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user