black_hex & white_hex added

This commit is contained in:
keringo
2025-06-25 21:11:20 +03:00
parent 633e5c8bd4
commit 0a523f9ecf
14 changed files with 116 additions and 39 deletions

View File

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

View File

@@ -22,6 +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
-- 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

@@ -705,6 +705,20 @@ function ReaderPaging:onUpdateScrollPageGamma(gamma)
return true
end
function ReaderPaging:onUpdateScrollPageBlackLevel(black_hex)
for _, state in ipairs(self.view.page_states) do
state.black_hex = black_hex
end
return true
end
function ReaderPaging:onUpdateScrollPageWhiteLevel(white_hex)
for _, state in ipairs(self.view.page_states) do
state.white_hex = white_hex
end
return true
end
function ReaderPaging:getNextPageState(blank_area, image_offset)
local page_area = self.view:getPageArea(
self.view.state.page,

View File

@@ -1092,6 +1092,26 @@ function ReaderView:onGammaUpdate(gamma, no_notification)
end
end
function ReaderView:onBlackLevelUpdate(black_hex, no_notification)
self.state.black_hex = black_hex
if self.page_scroll then
self.ui:handleEvent(Event:new("UpdateScrollPageBlackLevel", black_hex))
end
if not no_notification then
Notification:notify(T(_("Black level set to: %1."), black_hex))
end
end
function ReaderView:onWhiteLevelUpdate(white_hex, no_notification)
self.state.white_hex = white_hex
if self.page_scroll then
self.ui:handleEvent(Event:new("UpdateScrollPageWhiteLevel", white_hex))
end
if not no_notification then
Notification:notify(T(_("White level set to: %1."), white_hex))
end
end
-- For ReaderKOptListener
function ReaderView:onDitheringUpdate()
-- Do the device cap checks again, to avoid snafus when sharing configs between devices