From 56dc5b186504f0c743c34c9bfdfdf62935e19509 Mon Sep 17 00:00:00 2001 From: keringo <> Date: Thu, 26 Jun 2025 17:35:46 +0300 Subject: [PATCH] white_threshold --- base | 2 +- defaults.lua | 3 +- .../apps/reader/modules/readerhinting.lua | 3 +- .../reader/modules/readerkoptlistener.lua | 3 +- frontend/apps/reader/modules/readerpaging.lua | 20 +++--------- frontend/apps/reader/modules/readerview.lua | 30 +++++------------ frontend/document/djvudocument.lua | 12 +++---- frontend/document/document.lua | 25 +++++++-------- frontend/document/koptinterface.lua | 24 +++++++------- frontend/document/pdfdocument.lua | 12 +++---- frontend/ui/data/koptoptions.lua | 32 ++++++------------- spec/unit/koptinterface_spec.lua | 4 +-- spec/unit/readerlink_spec.lua | 6 ++-- spec/unit/readerview_spec.lua | 6 ++-- 14 files changed, 67 insertions(+), 115 deletions(-) diff --git a/base b/base index 8b544c9a3..950c35b4e 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 8b544c9a3b2b10aa3706a47aec5ad7429ce08030 +Subproject commit 950c35b4e76e3782a0fa1e43edef02018f97c8a6 diff --git a/defaults.lua b/defaults.lua index 2ae8d1a92..170dcac5d 100644 --- a/defaults.lua +++ b/defaults.lua @@ -83,8 +83,7 @@ DKOPTREADER_CONFIG_AUTO_STRAIGHTEN = 0, -- range from 0 to 10 DKOPTREADER_CONFIG_JUSTIFICATION = 3, -- -1 = auto, 0 = left, 1 = center, 2 = right, 3 = full DKOPTREADER_CONFIG_MAX_COLUMNS = 2, -- range from 1 to 4 DKOPTREADER_CONFIG_CONTRAST = 1.0, -- range from 0.2 to 2.0 -DKOPTREADER_CONFIG_BLACK_HEX = 0x000000, -- color defined blackness -DKOPTREADER_CONFIG_WHITE_HEX = 0xFFFFFF, -- color defined whiteness +DKOPTREADER_CONFIG_WHITE_THRESHOLD = 255, -- range from 0 to 255 -- word spacing for reflow DKOPTREADER_CONFIG_WORD_SPACINGS = {0.05, -0.2, 0.375}, -- range from (+/-)0.05 to (+/-)0.5 diff --git a/frontend/apps/reader/modules/readerhinting.lua b/frontend/apps/reader/modules/readerhinting.lua index ad995791c..d5b3dc345 100644 --- a/frontend/apps/reader/modules/readerhinting.lua +++ b/frontend/apps/reader/modules/readerhinting.lua @@ -19,8 +19,7 @@ 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.white_threshold) end end return true diff --git a/frontend/apps/reader/modules/readerkoptlistener.lua b/frontend/apps/reader/modules/readerkoptlistener.lua index c0c7d4e64..094b275f3 100644 --- a/frontend/apps/reader/modules/readerkoptlistener.lua +++ b/frontend/apps/reader/modules/readerkoptlistener.lua @@ -22,8 +22,7 @@ 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("WhiteThresholdUpdate", self.document.configurable.white_threshold, 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 diff --git a/frontend/apps/reader/modules/readerpaging.lua b/frontend/apps/reader/modules/readerpaging.lua index 922c871ee..0262e0376 100644 --- a/frontend/apps/reader/modules/readerpaging.lua +++ b/frontend/apps/reader/modules/readerpaging.lua @@ -19,8 +19,7 @@ local function copyPageState(page_state) zoom = page_state.zoom, rotation = page_state.rotation, gamma = page_state.gamma, - black_hex = page_state.black_hex, - white_hex = page_state.white_hex, + white_threshold = page_state.white_threshold, offset = page_state.offset:copy(), visible_area = page_state.visible_area:copy(), page_area = page_state.page_area:copy(), @@ -707,16 +706,9 @@ function ReaderPaging:onUpdateScrollPageGamma(gamma) return true end -function ReaderPaging:onUpdateScrollPageBlackLevel(black_hex) +function ReaderPaging:onUpdateScrollPageWhiteThreshold(white_threshold) 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 + state.white_threshold = white_threshold end return true end @@ -741,8 +733,7 @@ function ReaderPaging:getNextPageState(blank_area, image_offset) zoom = self.view.state.zoom, rotation = self.view.state.rotation, gamma = self.view.state.gamma, - black_hex = self.view.state.black_hex, - white_hex = self.view.state.white_hex, + white_threshold = self.view.state.white_threshold, offset = page_offset, visible_area = visible_area, page_area = page_area, @@ -770,8 +761,7 @@ function ReaderPaging:getPrevPageState(blank_area, image_offset) zoom = self.view.state.zoom, rotation = self.view.state.rotation, gamma = self.view.state.gamma, - black_hex = self.view.state.black_hex, - white_hex = self.view.state.white_hex, + white_threshold = self.view.state.white_threshold, offset = page_offset, visible_area = visible_area, page_area = page_area, diff --git a/frontend/apps/reader/modules/readerview.lua b/frontend/apps/reader/modules/readerview.lua index 66faf6141..8575f00d3 100644 --- a/frontend/apps/reader/modules/readerview.lua +++ b/frontend/apps/reader/modules/readerview.lua @@ -86,8 +86,7 @@ function ReaderView:init() zoom = 1.0, rotation = 0, gamma = 1.0, - black_hex = 0x000000, - white_hex = 0xFFFFFF, + white_threshold = 255, offset = nil, bbox = nil, } @@ -387,8 +386,7 @@ function ReaderView:drawScrollPages(bb, x, y) state.zoom, state.rotation, state.gamma, - state.black_hex, - state.white_hex) + state.white_threshold) pos.y = pos.y + state.visible_area.h -- draw page gap if not the last part if page ~= #self.page_states then @@ -463,8 +461,7 @@ function ReaderView:drawSinglePage(bb, x, y) self.state.zoom, self.state.rotation, self.state.gamma, - self.state.black_hex, - self.state.white_hex) + self.state.white_threshold) UIManager:nextTick(self.emitHintPageEvent) end @@ -877,8 +874,7 @@ function ReaderView:getViewContext() zoom = self.state.zoom, rotation = self.state.rotation, gamma = self.state.gamma, - black_hex = self.state.black_hex, - white_hex = self.state.white_hex, + white_threshold = self.state.white_threshold, offset = self.state.offset:copy(), bbox = self.state.bbox, }, @@ -1100,23 +1096,13 @@ function ReaderView:onGammaUpdate(gamma, no_notification) end end -function ReaderView:onBlackLevelUpdate(black_hex, no_notification) - self.state.black_hex = black_hex +function ReaderView:onWhiteThresholdUpdate(white_threshold, no_notification) + self.state.white_threshold = white_threshold if self.page_scroll then - self.ui:handleEvent(Event:new("UpdateScrollPageBlackLevel", black_hex)) + self.ui:handleEvent(Event:new("UpdateScrollPageWhiteThreshold", white_threshold)) end if not no_notification then - Notification:notify(T(_("Black level set to: %1."), string.format("#%X", 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."), string.format("#%X", white_hex))) + Notification:notify(T(_("White threshold set to: %1."), white_threshold)) end end diff --git a/frontend/document/djvudocument.lua b/frontend/document/djvudocument.lua index 076890736..6291e83ae 100644 --- a/frontend/document/djvudocument.lua +++ b/frontend/document/djvudocument.lua @@ -136,16 +136,16 @@ function DjvuDocument:findAllText(pattern, case_insensitive, nb_context_words, m return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits) end -function DjvuDocument:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) - return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) +function DjvuDocument:renderPage(pageno, rect, zoom, rotation, gamma, white_threshold, hinting) + return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, white_threshold, hinting) end -function DjvuDocument:hintPage(pageno, zoom, rotation, gamma, black_hex, white_hex) - return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, black_hex, white_hex) +function DjvuDocument:hintPage(pageno, zoom, rotation, gamma, white_threshold) + return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, white_threshold) end -function DjvuDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) - return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) +function DjvuDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) + return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) end function DjvuDocument:register(registry) diff --git a/frontend/document/document.lua b/frontend/document/document.lua index 867a37a85..7c46962fb 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -390,32 +390,32 @@ function Document:resetTileCacheValidity() self.tile_cache_validity_ts = os.time() end -function Document:getFullPageHash(pageno, zoom, rotation, gamma, black_hex, white_hex) +function Document:getFullPageHash(pageno, zoom, rotation, gamma, white_threshold) return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|" - ..zoom.."|"..rotation.."|"..gamma.."|"..black_hex.."|"..white_hex + ..zoom.."|"..rotation.."|"..gamma.."|"..white_threshold ..self.render_mode..(self.render_color and "|color" or "|bw") ..(self.reflowable_font_size and "|"..self.reflowable_font_size or "") end -function Document:getPagePartHash(pageno, zoom, rotation, gamma, black_hex, white_hex, rect) +function Document:getPagePartHash(pageno, zoom, rotation, gamma, white_threshold, rect) return "renderpgpart|"..self.file.."|"..self.mod_time.."|"..pageno.."|" ..tostring(rect).."|"..zoom.."|"..tostring(rect.scaled_rect).."|" - ..rotation.."|"..gamma.."|"..black_hex.."|"..white_hex + ..rotation.."|"..gamma.."|"..white_threshold ..self.render_mode..(self.render_color and "|color" or "|bw") ..(self.reflowable_font_size and "|"..self.reflowable_font_size or "") end -function Document:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) +function Document:renderPage(pageno, rect, zoom, rotation, gamma, white_threshold, hinting) -- If rect contains a nested scaled_rect object, our caller handled scaling itself (e.g., drawPagePart) local is_prescaled = rect and rect.scaled_rect ~= nil or false local hash, hash_excerpt, tile if is_prescaled then - hash = self:getPagePartHash(pageno, zoom, rotation, gamma, black_hex, white_hex, rect) + hash = self:getPagePartHash(pageno, zoom, rotation, gamma, white_threshold, rect) tile = DocCache:check(hash, TileCacheItem) else - hash = self:getFullPageHash(pageno, zoom, rotation, gamma, black_hex, white_hex) + hash = self:getFullPageHash(pageno, zoom, rotation, gamma, white_threshold) tile = DocCache:check(hash, TileCacheItem) @@ -503,8 +503,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, whi dc:setGamma(gamma) end - dc:setBlackHex(black_hex) - dc:setWhiteHex(white_hex) + dc:setWhiteThreshold(white_threshold) -- And finally, render the page in our BB local page = self._document:openPage(pageno) @@ -520,9 +519,9 @@ end -- a hint for the cache engine to paint a full page to the cache --- @todo this should trigger a background operation -function Document:hintPage(pageno, zoom, rotation, gamma, black_hex, white_hex) +function Document:hintPage(pageno, zoom, rotation, gamma, white_threshold) logger.dbg("hinting page", pageno) - self:renderPage(pageno, nil, zoom, rotation, gamma, black_hex, white_hex, true) + self:renderPage(pageno, nil, zoom, rotation, gamma, white_threshold, true) end --[[ @@ -533,8 +532,8 @@ Draw page content to blitbuffer. @target: target blitbuffer @rect: visible_area inside document page --]] -function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) - local tile = self:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, white_hex) +function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) + local tile = self:renderPage(pageno, rect, zoom, rotation, gamma, white_threshold) -- Enable SW dithering if requested (only available in koptoptions) if self.sw_dithering then target:ditherblitFrom(tile.bb, diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 722255c34..9240f24e2 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -99,8 +99,7 @@ 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.white_threshold = G_defaults:readSetting("DKOPTREADER_CONFIG_WHITE_THRESHOLD") 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 +151,7 @@ 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:setBlackHex(doc.configurable.black_hex) - kc:setWhiteHex(doc.configurable.white_hex) + kc:setWhite(doc.configurable.white_threshold) kc:setDefectSize(doc.configurable.defect_size) kc:setLineSpacing(doc.configurable.line_spacing) kc:setWordSpacing(doc.configurable.word_spacing) @@ -394,13 +392,13 @@ function KoptInterface:getCoverPageImage(doc) end end -function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) +function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, white_threshold, 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, black_hex, white_hex, hinting) + return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, white_threshold, hinting) end end @@ -495,16 +493,16 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hi end end -function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, black_hex, white_hex) +function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, white_threshold) --- @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, black_hex, white_hex, true) + self:hintReflowedPage(doc, pageno, zoom, rotation, gamma, white_threshold, true) elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then - self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, gamma, black_hex, white_hex, true) + self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, true) else - Document.hintPage(doc, pageno, zoom, rotation, gamma, black_hex, white_hex) + Document.hintPage(doc, pageno, zoom, rotation, gamma, white_threshold) end end @@ -517,7 +515,7 @@ off by calling self:waitForContext(kctx) Inherited from common document interface. --]] -function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, gamma, hinting) +function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, gamma, white_threshold, hinting) local bbox = doc:getPageBBox(pageno) local hash_list = { "kctx" } self:getContextHash(doc, pageno, bbox, hash_list) @@ -537,13 +535,13 @@ function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, gamma, hint end end -function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) +function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) if doc.configurable.text_wrap == 1 then self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation) elseif doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 then self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation) else - Document.drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) + Document.drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) end end diff --git a/frontend/document/pdfdocument.lua b/frontend/document/pdfdocument.lua index 2b3640d6a..b07303e05 100644 --- a/frontend/document/pdfdocument.lua +++ b/frontend/document/pdfdocument.lua @@ -344,16 +344,16 @@ function PdfDocument:findAllText(pattern, case_insensitive, nb_context_words, ma return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits) end -function PdfDocument:renderPage(pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) - return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, black_hex, white_hex, hinting) +function PdfDocument:renderPage(pageno, rect, zoom, rotation, gamma, white_threshold, hinting) + return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, white_threshold, hinting) end -function PdfDocument:hintPage(pageno, zoom, rotation, gamma, black_hex, white_hex) - return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, black_hex, white_hex) +function PdfDocument:hintPage(pageno, zoom, rotation, gamma, white_threshold) + return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, white_threshold) end -function PdfDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) - return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, black_hex, white_hex) +function PdfDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) + return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, white_threshold) end function PdfDocument:register(registry) diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index dc48ffe6a..d32919117 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -497,36 +497,22 @@ Some of the other settings are only available when reflow mode is enabled.]]), more_options = true, more_options_param = { value_step = 0.1, value_hold_step = 1, - value_min = 0.8, value_max = 50, + value_min = 0.1, value_max = 50, precision = "%.1f", }, }, { - name = "black_hex", - name_text = _("Black Level"), + name = "white_threshold", + name_text = _("White Threshold"), buttonprogress = true, - -- For pdf reflowing mode (kopt_contrast): - values = {0x808080, 0x606060, 0x404040, 0x202020, 0x000000}, - default_pos = 5, - default_value = G_defaults:readSetting("DKOPTREADER_CONFIG_BLACK_HEX"), - event = "BlackLevelUpdate", - -- For pdf non-reflowing mode (mupdf): - args = {0x808080, 0x606060, 0x404040, 0x202020, 0x000000}, - labels = {"#808080", "#606060", "#404040", "#202020", "#000000"}, - name_text_hold_callback = optionsutil.showValues, - }, - { - name = "white_hex", - name_text = _("White Level"), - buttonprogress = true, - -- For pdf reflowing mode (kopt_contrast): - values = {0xFFFFFF, 0xE0E0E0, 0xC0C0C0, 0xA0A0A0, 0x808080}, + -- For pdf reflowing mode (k2pdfopt): + values = {255, 224, 192, 160, 128, 96, 64, 32}, default_pos = 1, - default_value = G_defaults:readSetting("DKOPTREADER_CONFIG_WHITE_HEX"), - event = "WhiteLevelUpdate", + default_value = G_defaults:readSetting("DKOPTREADER_CONFIG_WHITE_THRESHOLD"), + event = "WhiteThresholdUpdate", -- For pdf non-reflowing mode (mupdf): - args = {0xFFFFFF, 0xE0E0E0, 0xC0C0C0, 0xA0A0A0, 0x808080}, - labels = {"#FFFFFF", "#E0E0E0", "#C0C0C0", "#A0A0A0", "#808080"}, + args = {255, 224, 192, 160, 128, 96, 64, 32}, + labels = {255, 224, 192, 160, 128, 96, 64, 32}, name_text_hold_callback = optionsutil.showValues, }, { diff --git a/spec/unit/koptinterface_spec.lua b/spec/unit/koptinterface_spec.lua index f9c5b853f..39ae3357f 100644 --- a/spec/unit/koptinterface_spec.lua +++ b/spec/unit/koptinterface_spec.lua @@ -47,7 +47,7 @@ describe("Koptinterface module", function() it("should render optimized page to de-watermark", function() local page_dimen = doc:getPageDimensions(1, 1.0, 0) local tile = Koptinterface:renderOptimizedPage(doc, 1, nil, - 1.0, 0, 0) + 1.0, 0, false) assert.truthy(tile) assert.are.same(page_dimen, tile.excerpt) end) @@ -60,7 +60,7 @@ describe("Koptinterface module", function() it("should hint reflowed page in background", function() doc.configurable.text_wrap = 1 - Koptinterface:hintReflowedPage(doc, 1, 1.0, 0, 1.0, 0) + Koptinterface:hintReflowedPage(doc, 1, 1.0, 0, 1.0, 255, false) -- and wait for reflowing to complete local kc = Koptinterface:getCachedContext(doc, 1) assert.truthy(kc) diff --git a/spec/unit/readerlink_spec.lua b/spec/unit/readerlink_spec.lua index 8918e5e11..acf50d1f5 100644 --- a/spec/unit/readerlink_spec.lua +++ b/spec/unit/readerlink_spec.lua @@ -111,8 +111,7 @@ describe("ReaderLink module", function() local expected_page_states = { { gamma = 1, - black_hex = 0x000000, - white_hex = 0xFFFFFF, + white_threshold = 255, offset = {x = 17, y = 0}, page = 3, page_area = { @@ -128,8 +127,7 @@ describe("ReaderLink module", function() }, { gamma = 1, - black_hex = 0x000000, - white_hex = 0xFFFFFF, + white_threshold = 255, offset = {x = 17, y = 0}, page = 4, page_area = { diff --git a/spec/unit/readerview_spec.lua b/spec/unit/readerview_spec.lua index 3d36b63e7..ac0cf26c6 100644 --- a/spec/unit/readerview_spec.lua +++ b/spec/unit/readerview_spec.lua @@ -71,8 +71,7 @@ describe("Readerview module", function() page = 1, pos = 0, gamma = 1, - black_hex = 0x000000, - white_hex = 0xFFFFFF, + white_threshold = 255, offset = { x = 17, y = 0, h = 0, w = 0, @@ -126,8 +125,7 @@ describe("Readerview module", function() local saved_ctx = { { gamma = 1, - black_hex = 0x000000, - white_hex = 0xFFFFFF, + white_threshold = 255, offset = {x = 17, y = 0}, page = 1, page_area = {