minor fixes

This commit is contained in:
keringo
2025-06-25 21:28:02 +03:00
parent 0a523f9ecf
commit 39f3e410bd
7 changed files with 18 additions and 19 deletions

2
base

Submodule base updated: 003e635a56...8b544c9a3b

View File

@@ -19,8 +19,8 @@ function ReaderHinting:onHintPage()
self.zoom:getZoom(self.view.state.page + i),
self.view.state.rotation,
self.view.state.gamma,
self.view.state.black_hex,
self.view.state.white_hex)
self.view.state.black_hex,
self.view.state.white_hex)
end
end
return true

View File

@@ -22,8 +22,8 @@ function ReaderKoptListener:onReadSettings(config)
self.normal_zoom_mode = normal_zoom_mode
self:setZoomMode(normal_zoom_mode)
self.ui:handleEvent(Event:new("GammaUpdate", self.document.configurable.contrast, true)) -- no notification
self.ui:handleEvent(Event:new("BlackLevelUpdate", self.document.configurable.black_hex, true)) -- no notification
self.ui:handleEvent(Event:new("WhiteLevelUpdate", self.document.configurable.white_hex, true)) -- no notification
self.ui:handleEvent(Event:new("BlackLevelUpdate", self.document.configurable.black_hex, true)) -- no notification
self.ui:handleEvent(Event:new("WhiteLevelUpdate", self.document.configurable.white_hex, true)) -- no notification
-- since K2pdfopt v2.21 negative value of word spacing is also used, for config
-- compatibility we should manually change previous -1 to a more reasonable -0.2
if self.document.configurable.word_spacing == -1 then

View File

@@ -392,9 +392,8 @@ end
function Document:getFullPageHash(pageno, zoom, rotation, gamma, black_hex, white_hex)
return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
..zoom.."|"
..rotation.."|"..gamma.."|"..black_hex.."|"..white_hex
..self.render_mode..(self.render_color and "|color" or "|bw")
..zoom.."|"..rotation.."|"..gamma.."|"..black_hex.."|"..white_hex
..self.render_mode..(self.render_color and "|color" or "|bw")
..(self.reflowable_font_size and "|"..self.reflowable_font_size or "")
end
@@ -402,7 +401,7 @@ function Document:getPagePartHash(pageno, zoom, rotation, gamma, black_hex, whit
return "renderpgpart|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
..tostring(rect).."|"..zoom.."|"..tostring(rect.scaled_rect).."|"
..rotation.."|"..gamma.."|"..black_hex.."|"..white_hex
..self.render_mode..(self.render_color and "|color" or "|bw")
..self.render_mode..(self.render_color and "|color" or "|bw")
..(self.reflowable_font_size and "|"..self.reflowable_font_size or "")
end
@@ -504,8 +503,8 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, whi
dc:setGamma(gamma)
end
dc:setBlackHex(black_hex)
dc:setWhiteHex(white_hex)
dc:setBlackHex(black_hex)
dc:setWhiteHex(white_hex)
-- And finally, render the page in our BB
local page = self._document:openPage(pageno)

View File

@@ -99,8 +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.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")
@@ -152,8 +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:setBlackHex(doc.configurable.black_hex)
kc:setWhiteHex(doc.configurable.white_hex)
kc:setDefectSize(doc.configurable.defect_size)
kc:setLineSpacing(doc.configurable.line_spacing)
kc:setWordSpacing(doc.configurable.word_spacing)
@@ -553,7 +553,7 @@ Draw cached tile pixels into target blitbuffer.
Inherited from common document interface.
--]]
function KoptInterface:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation)
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, 1.0)
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, 1.0, 0x000000, 0xFFFFFF)
target:blitFrom(tile.bb,
x, y,
rect.x - tile.excerpt.x,

View File

@@ -512,7 +512,7 @@ Some of the other settings are only available when reflow mode is enabled.]]),
event = "BlackLevelUpdate",
-- For pdf non-reflowing mode (mupdf):
args = {0x808080, 0x606060, 0x404040, 0x202020, 0x000000},
labels = { #808080, #606060, #404040, #202020, #000000},
labels = {"#808080", "#606060", "#404040", "#202020", "#000000"},
name_text_hold_callback = optionsutil.showValues,
},
{
@@ -526,7 +526,7 @@ Some of the other settings are only available when reflow mode is enabled.]]),
event = "WhiteLevelUpdate",
-- For pdf non-reflowing mode (mupdf):
args = {0xFFFFFF, 0xE0E0E0, 0xC0C0C0, 0xA0A0A0, 0x808080},
labels = { #FFFFFF, #E0E0E0, #C0C0C0, #A0A0A0, #808080},
labels = {"#FFFFFF", "#E0E0E0", "#C0C0C0", "#A0A0A0", "#808080"},
name_text_hold_callback = optionsutil.showValues,
},
{

View File

@@ -23,7 +23,7 @@ describe("PDF benchmark:", function()
end
for pageno = 1, math.min(9, doc.info.number_of_pages) do
local secs, usecs = util.gettime()
assert.truthy(doc:renderPage(pageno, nil, 1, 0, 1.0, , 0x000000, 0xFFFFFF))
assert.truthy(doc:renderPage(pageno, nil, 1, 0, 1.0, 0x000000, 0xFFFFFF))
local nsecs, nusecs = util.gettime()
local dur = nsecs - secs + (nusecs - usecs) / 1000000
logDuration(logfile, pageno, dur)