feat: saturation control (#15381)
This commit is contained in:
1 parent
bc0ef5a078
commit
06c9eea0d4
14 files changed
+97
-41
No files matched your search
+1
-1
Submodule base updated: 3725903411...4d5e13ee74.
@@ -87,6 +87,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_JUSTIFICATION = 3, -- -1 = auto, 0 = left, 1 = center, 2 = right, 3 = full
|
||||||
DKOPTREADER_CONFIG_MAX_COLUMNS = 2, -- range from 1 to 4
|
DKOPTREADER_CONFIG_MAX_COLUMNS = 2, -- range from 1 to 4
|
||||||
DKOPTREADER_CONFIG_CONTRAST = 1.0, -- range from 0.2 to 2.0
|
DKOPTREADER_CONFIG_CONTRAST = 1.0, -- range from 0.2 to 2.0
|
||||||
|
DKOPTREADER_CONFIG_SATURATION = 1.0, -- range from 0.2 to 2.0
|
||||||
DKOPTREADER_CONFIG_WHITE_THRESHOLD = 255, -- range from 0 to 255
|
DKOPTREADER_CONFIG_WHITE_THRESHOLD = 255, -- range from 0 to 255
|
||||||
|
|
||||||
-- word spacing for reflow
|
-- word spacing for reflow
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ function ReaderHinting:onHintPage()
|
|||||||
self.view.state.page + i,
|
self.view.state.page + i,
|
||||||
self.zoom:getZoom(self.view.state.page + i),
|
self.zoom:getZoom(self.view.state.page + i),
|
||||||
self.view.state.rotation,
|
self.view.state.rotation,
|
||||||
self.view.state.gamma)
|
self.view.state.gamma,
|
||||||
|
self.view.state.saturation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ function ReaderKoptListener:onReadSettings(config)
|
|||||||
self.normal_zoom_mode = normal_zoom_mode
|
self.normal_zoom_mode = normal_zoom_mode
|
||||||
self:setZoomMode(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("GammaUpdate", self.document.configurable.contrast, true)) -- no notification
|
||||||
|
self.ui:handleEvent(Event:new("SaturationUpdate", self.document.configurable.saturation, true)) -- no notification
|
||||||
-- since K2pdfopt v2.21 negative value of word spacing is also used, for config
|
-- 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
|
-- compatibility we should manually change previous -1 to a more reasonable -0.2
|
||||||
if self.document.configurable.word_spacing == -1 then
|
if self.document.configurable.word_spacing == -1 then
|
||||||
|
|||||||
@@ -716,6 +716,13 @@ function ReaderPaging:onUpdateScrollPageGamma(gamma)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ReaderPaging:onUpdateScrollPageSaturation(saturation)
|
||||||
|
for _, state in ipairs(self.view.page_states) do
|
||||||
|
state.saturation = saturation
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function ReaderPaging:getNextPageState(blank_area, image_offset)
|
function ReaderPaging:getNextPageState(blank_area, image_offset)
|
||||||
local page_area = self.view:getPageArea(
|
local page_area = self.view:getPageArea(
|
||||||
self.view.state.page,
|
self.view.state.page,
|
||||||
@@ -736,6 +743,7 @@ function ReaderPaging:getNextPageState(blank_area, image_offset)
|
|||||||
zoom = self.view.state.zoom,
|
zoom = self.view.state.zoom,
|
||||||
rotation = self.view.state.rotation,
|
rotation = self.view.state.rotation,
|
||||||
gamma = self.view.state.gamma,
|
gamma = self.view.state.gamma,
|
||||||
|
saturation = self.view.state.saturation,
|
||||||
offset = page_offset,
|
offset = page_offset,
|
||||||
visible_area = visible_area,
|
visible_area = visible_area,
|
||||||
page_area = page_area,
|
page_area = page_area,
|
||||||
@@ -763,6 +771,7 @@ function ReaderPaging:getPrevPageState(blank_area, image_offset)
|
|||||||
zoom = self.view.state.zoom,
|
zoom = self.view.state.zoom,
|
||||||
rotation = self.view.state.rotation,
|
rotation = self.view.state.rotation,
|
||||||
gamma = self.view.state.gamma,
|
gamma = self.view.state.gamma,
|
||||||
|
saturation = self.view.state.saturation,
|
||||||
offset = page_offset,
|
offset = page_offset,
|
||||||
visible_area = visible_area,
|
visible_area = visible_area,
|
||||||
page_area = page_area,
|
page_area = page_area,
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ function ReaderView:init()
|
|||||||
zoom = 1.0,
|
zoom = 1.0,
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
gamma = 1.0,
|
gamma = 1.0,
|
||||||
|
saturation = 1.0,
|
||||||
offset = nil,
|
offset = nil,
|
||||||
bbox = nil,
|
bbox = nil,
|
||||||
}
|
}
|
||||||
@@ -384,7 +385,8 @@ function ReaderView:drawScrollPages(bb, x, y)
|
|||||||
state.page,
|
state.page,
|
||||||
state.zoom,
|
state.zoom,
|
||||||
state.rotation,
|
state.rotation,
|
||||||
state.gamma)
|
state.gamma,
|
||||||
|
state.saturation)
|
||||||
pos.y = pos.y + state.visible_area.h
|
pos.y = pos.y + state.visible_area.h
|
||||||
-- draw page gap if not the last part
|
-- draw page gap if not the last part
|
||||||
if page ~= #self.page_states then
|
if page ~= #self.page_states then
|
||||||
@@ -458,7 +460,8 @@ function ReaderView:drawSinglePage(bb, x, y)
|
|||||||
self.state.page,
|
self.state.page,
|
||||||
self.state.zoom,
|
self.state.zoom,
|
||||||
self.state.rotation,
|
self.state.rotation,
|
||||||
self.state.gamma)
|
self.state.gamma,
|
||||||
|
self.state.saturation)
|
||||||
UIManager:nextTick(self.emitHintPageEvent)
|
UIManager:nextTick(self.emitHintPageEvent)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -871,6 +874,7 @@ function ReaderView:getViewContext()
|
|||||||
zoom = self.state.zoom,
|
zoom = self.state.zoom,
|
||||||
rotation = self.state.rotation,
|
rotation = self.state.rotation,
|
||||||
gamma = self.state.gamma,
|
gamma = self.state.gamma,
|
||||||
|
saturation = self.state.saturation,
|
||||||
offset = self.state.offset:copy(),
|
offset = self.state.offset:copy(),
|
||||||
bbox = self.state.bbox,
|
bbox = self.state.bbox,
|
||||||
},
|
},
|
||||||
@@ -1108,6 +1112,16 @@ function ReaderView:onGammaUpdate(gamma, no_notification)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ReaderView:onSaturationUpdate(saturation, no_notification)
|
||||||
|
self.state.saturation = saturation
|
||||||
|
if self.page_scroll then
|
||||||
|
self.ui:handleEvent(Event:new("UpdateScrollPageSaturation", saturation))
|
||||||
|
end
|
||||||
|
if not no_notification then
|
||||||
|
Notification:notify(T(_("Saturation set to: %1."), saturation))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- For ReaderKOptListener
|
-- For ReaderKOptListener
|
||||||
function ReaderView:onDitheringUpdate()
|
function ReaderView:onDitheringUpdate()
|
||||||
-- Do the device cap checks again, to avoid snafus when sharing configs between devices
|
-- Do the device cap checks again, to avoid snafus when sharing configs between devices
|
||||||
|
|||||||
@@ -285,16 +285,16 @@ function DjvuDocument:findAllText(pattern, case_insensitive, nb_context_words, m
|
|||||||
return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits)
|
return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DjvuDocument:renderPage(pageno, rect, zoom, rotation, gamma, hinting)
|
function DjvuDocument:renderPage(pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, hinting)
|
return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DjvuDocument:hintPage(pageno, zoom, rotation, gamma)
|
function DjvuDocument:hintPage(pageno, zoom, rotation, gamma, saturation)
|
||||||
return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma)
|
return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DjvuDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma)
|
function DjvuDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma)
|
return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DjvuDocument:register(registry)
|
function DjvuDocument:register(registry)
|
||||||
|
|||||||
@@ -390,32 +390,34 @@ function Document:resetTileCacheValidity()
|
|||||||
self.tile_cache_validity_ts = os.time()
|
self.tile_cache_validity_ts = os.time()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Document:getFullPageHash(pageno, zoom, rotation, gamma)
|
function Document:getFullPageHash(pageno, zoom, rotation, gamma, saturation)
|
||||||
return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
return "renderpg|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
||||||
..zoom.."|"..rotation.."|"..gamma.."|"..self.configurable.background_cleanup.."|"
|
..zoom.."|"..rotation.."|"..gamma.."|"..self.configurable.background_cleanup.."|"
|
||||||
..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 "")
|
..(self.reflowable_font_size and "|"..self.reflowable_font_size or "")
|
||||||
|
.."|"..saturation
|
||||||
end
|
end
|
||||||
|
|
||||||
function Document:getPagePartHash(pageno, zoom, rotation, gamma, rect)
|
function Document:getPagePartHash(pageno, zoom, rotation, gamma, saturation, rect)
|
||||||
return "renderpgpart|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
return "renderpgpart|"..self.file.."|"..self.mod_time.."|"..pageno.."|"
|
||||||
..tostring(rect).."|"..zoom.."|"..tostring(rect.scaled_rect)
|
..tostring(rect).."|"..zoom.."|"..tostring(rect.scaled_rect)
|
||||||
.."|"..rotation.."|"..gamma.."|"..self.configurable.background_cleanup.."|"
|
.."|"..rotation.."|"..gamma.."|"..self.configurable.background_cleanup.."|"
|
||||||
..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 "")
|
..(self.reflowable_font_size and "|"..self.reflowable_font_size or "")
|
||||||
|
.."|"..saturation
|
||||||
end
|
end
|
||||||
|
|
||||||
function Document:renderPage(pageno, rect, zoom, rotation, gamma, hinting)
|
function Document:renderPage(pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
-- If rect contains a nested scaled_rect object, our caller handled scaling itself (e.g., drawPagePart)
|
-- 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 is_prescaled = rect and rect.scaled_rect ~= nil or false
|
||||||
|
|
||||||
local hash, hash_excerpt, tile
|
local hash, hash_excerpt, tile
|
||||||
if is_prescaled then
|
if is_prescaled then
|
||||||
hash = self:getPagePartHash(pageno, zoom, rotation, gamma, rect)
|
hash = self:getPagePartHash(pageno, zoom, rotation, gamma, saturation, rect)
|
||||||
|
|
||||||
tile = DocCache:check(hash, TileCacheItem)
|
tile = DocCache:check(hash, TileCacheItem)
|
||||||
else
|
else
|
||||||
hash = self:getFullPageHash(pageno, zoom, rotation, gamma)
|
hash = self:getFullPageHash(pageno, zoom, rotation, gamma, saturation)
|
||||||
|
|
||||||
tile = DocCache:check(hash, TileCacheItem)
|
tile = DocCache:check(hash, TileCacheItem)
|
||||||
|
|
||||||
@@ -502,6 +504,9 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, hinting)
|
|||||||
if gamma ~= self.GAMMA_NO_GAMMA then
|
if gamma ~= self.GAMMA_NO_GAMMA then
|
||||||
dc:setGamma(gamma)
|
dc:setGamma(gamma)
|
||||||
end
|
end
|
||||||
|
if saturation ~= 1.0 and dc.setSaturation then
|
||||||
|
dc:setSaturation(saturation)
|
||||||
|
end
|
||||||
|
|
||||||
dc:setIsolateSMask(self.configurable.background_cleanup)
|
dc:setIsolateSMask(self.configurable.background_cleanup)
|
||||||
|
|
||||||
@@ -519,9 +524,9 @@ end
|
|||||||
|
|
||||||
-- a hint for the cache engine to paint a full page to the cache
|
-- a hint for the cache engine to paint a full page to the cache
|
||||||
--- @todo this should trigger a background operation
|
--- @todo this should trigger a background operation
|
||||||
function Document:hintPage(pageno, zoom, rotation, gamma)
|
function Document:hintPage(pageno, zoom, rotation, gamma, saturation)
|
||||||
logger.dbg("hinting page", pageno)
|
logger.dbg("hinting page", pageno)
|
||||||
self:renderPage(pageno, nil, zoom, rotation, gamma, true)
|
self:renderPage(pageno, nil, zoom, rotation, gamma, saturation, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -532,8 +537,8 @@ Draw page content to blitbuffer.
|
|||||||
@target: target blitbuffer
|
@target: target blitbuffer
|
||||||
@rect: visible_area inside document page
|
@rect: visible_area inside document page
|
||||||
--]]
|
--]]
|
||||||
function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma)
|
function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
local tile = self:renderPage(pageno, rect, zoom, rotation, gamma)
|
local tile = self:renderPage(pageno, rect, zoom, rotation, gamma, saturation)
|
||||||
-- Enable SW dithering if requested (only available in koptoptions)
|
-- Enable SW dithering if requested (only available in koptoptions)
|
||||||
if self.sw_dithering then
|
if self.sw_dithering then
|
||||||
target:ditherblitFrom(tile.bb,
|
target:ditherblitFrom(tile.bb,
|
||||||
@@ -550,8 +555,8 @@ function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Document:drawPageInverted(target, x, y, rect, pageno, zoom, rotation, gamma)
|
function Document:drawPageInverted(target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
local tile = self:renderPage(pageno, rect, zoom, rotation, gamma)
|
local tile = self:renderPage(pageno, rect, zoom, rotation, gamma, saturation)
|
||||||
target:invertblitFrom(tile.bb,
|
target:invertblitFrom(tile.bb,
|
||||||
x, y,
|
x, y,
|
||||||
rect.x - tile.excerpt.x,
|
rect.x - tile.excerpt.x,
|
||||||
@@ -582,7 +587,7 @@ function Document:drawPagePart(pageno, native_rect, rotation)
|
|||||||
rect.scaled_rect = scaled_rect
|
rect.scaled_rect = scaled_rect
|
||||||
|
|
||||||
-- Enable SMP via the hinting flag
|
-- Enable SMP via the hinting flag
|
||||||
local tile = self:renderPage(pageno, rect, zoom, rotation, 1.0, true)
|
local tile = self:renderPage(pageno, rect, zoom, rotation, 1.0, 1.0, true)
|
||||||
return tile.bb, rotate
|
return tile.bb, rotate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ function KoptInterface:getCoverPageImage(doc)
|
|||||||
local native_size = Document.getNativePageDimensions(doc, 1)
|
local native_size = Document.getNativePageDimensions(doc, 1)
|
||||||
local canvas_size = CanvasContext:getSize()
|
local canvas_size = CanvasContext:getSize()
|
||||||
local zoom = math.min(canvas_size.w / native_size.w, canvas_size.h / native_size.h)
|
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, false)
|
local tile = Document.renderPage(doc, 1, nil, zoom, 0, 1.0, 1.0, false)
|
||||||
if tile then
|
if tile then
|
||||||
return tile.bb:copy()
|
return tile.bb:copy()
|
||||||
end
|
end
|
||||||
@@ -401,13 +401,13 @@ function KoptInterface:is_optimizing_page(doc)
|
|||||||
return doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 or doc.configurable.white_threshold ~= 255
|
return doc.configurable.page_opt == 1 or doc.configurable.auto_straighten > 0 or doc.configurable.white_threshold ~= 255
|
||||||
end
|
end
|
||||||
|
|
||||||
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, hinting)
|
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
if doc.configurable.text_wrap == 1 then
|
if doc.configurable.text_wrap == 1 then
|
||||||
return self:renderReflowedPage(doc, pageno, rect, zoom, rotation, hinting)
|
return self:renderReflowedPage(doc, pageno, rect, zoom, rotation, hinting)
|
||||||
elseif self:is_optimizing_page(doc) then
|
elseif self:is_optimizing_page(doc) then
|
||||||
return self:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hinting)
|
return self:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hinting)
|
||||||
else
|
else
|
||||||
return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, hinting)
|
return Document.renderPage(doc, pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, hi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma)
|
function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma, saturation)
|
||||||
--- @note: Crappy safeguard around memory issues like in #7627: if we're eating too much RAM, drop half the cache...
|
--- @note: Crappy safeguard around memory issues like in #7627: if we're eating too much RAM, drop half the cache...
|
||||||
DocCache:memoryPressureCheck()
|
DocCache:memoryPressureCheck()
|
||||||
|
|
||||||
@@ -554,7 +554,7 @@ function KoptInterface:hintPage(doc, pageno, zoom, rotation, gamma)
|
|||||||
elseif self:is_optimizing_page(doc) then
|
elseif self:is_optimizing_page(doc) then
|
||||||
self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, true)
|
self:renderOptimizedPage(doc, pageno, nil, zoom, rotation, true)
|
||||||
else
|
else
|
||||||
Document.hintPage(doc, pageno, zoom, rotation, gamma)
|
Document.hintPage(doc, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -587,16 +587,16 @@ function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, hinting)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma)
|
function KoptInterface:drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
local nightmode_invert = doc.configurable.nightmode_document == 1 and Screen.night_mode
|
local nightmode_invert = doc.configurable.nightmode_document == 1 and Screen.night_mode
|
||||||
if doc.configurable.text_wrap == 1 then
|
if doc.configurable.text_wrap == 1 then
|
||||||
self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
||||||
elseif self:is_optimizing_page(doc) then
|
elseif self:is_optimizing_page(doc) then
|
||||||
self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
self:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
||||||
elseif nightmode_invert then
|
elseif nightmode_invert then
|
||||||
Document.drawPageInverted(doc, target, x, y, rect, pageno, zoom, rotation, gamma)
|
Document.drawPageInverted(doc, target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
else
|
else
|
||||||
Document.drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma)
|
Document.drawPage(doc, target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ Draw cached tile pixels into target blitbuffer.
|
|||||||
Inherited from common document interface.
|
Inherited from common document interface.
|
||||||
--]]
|
--]]
|
||||||
function KoptInterface:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
function KoptInterface:drawContextPage(doc, target, x, y, rect, pageno, zoom, rotation, nightmode_invert)
|
||||||
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, 1.0, false)
|
local tile = self:renderPage(doc, pageno, rect, zoom, rotation, 1.0, 1.0, false)
|
||||||
target:blitFrom(tile.bb,
|
target:blitFrom(tile.bb,
|
||||||
x, y,
|
x, y,
|
||||||
rect.x - tile.excerpt.x,
|
rect.x - tile.excerpt.x,
|
||||||
|
|||||||
@@ -357,16 +357,16 @@ function PdfDocument:findAllText(pattern, case_insensitive, nb_context_words, ma
|
|||||||
return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits)
|
return self.koptinterface:findAllText(self, pattern, case_insensitive, nb_context_words, max_hits)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PdfDocument:renderPage(pageno, rect, zoom, rotation, gamma, hinting)
|
function PdfDocument:renderPage(pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, hinting)
|
return self.koptinterface:renderPage(self, pageno, rect, zoom, rotation, gamma, saturation, hinting)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PdfDocument:hintPage(pageno, zoom, rotation, gamma)
|
function PdfDocument:hintPage(pageno, zoom, rotation, gamma, saturation)
|
||||||
return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma)
|
return self.koptinterface:hintPage(self, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PdfDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma)
|
function PdfDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma)
|
return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, saturation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PdfDocument:register(registry)
|
function PdfDocument:register(registry)
|
||||||
|
|||||||
@@ -506,6 +506,27 @@ Some of the other settings are only available when reflow mode is enabled.]]),
|
|||||||
precision = "%.1f",
|
precision = "%.1f",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name = "saturation",
|
||||||
|
name_text = _("Saturation"),
|
||||||
|
buttonprogress = true,
|
||||||
|
values = {0.2, 0.5, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0},
|
||||||
|
default_pos = 3,
|
||||||
|
default_value = G_defaults:readSetting("DKOPTREADER_CONFIG_SATURATION"),
|
||||||
|
event = "SaturationUpdate",
|
||||||
|
args = {0.2, 0.5, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0},
|
||||||
|
labels = {0.2, 0.5, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0},
|
||||||
|
show = Device:hasColorScreen(),
|
||||||
|
name_text_hold_callback = optionsutil.showValues,
|
||||||
|
more_options = true,
|
||||||
|
more_options_param = {
|
||||||
|
value_step = 0.1, value_hold_step = 0.2,
|
||||||
|
value_min = 0.2, value_max = 2.0,
|
||||||
|
precision = "%.1f",
|
||||||
|
},
|
||||||
|
help_text = _([[Adjust color saturation for rendered pages.
|
||||||
|
Lower values desaturate colors, 1.0 keeps original colors, and higher values increase color intensity.]]),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name = "white_threshold",
|
name = "white_threshold",
|
||||||
name_text = _("White Threshold"),
|
name_text = _("White Threshold"),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe("Cache module", function()
|
|||||||
|
|
||||||
it("should serialize blitbuffer", function()
|
it("should serialize blitbuffer", function()
|
||||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||||
doc:renderPage(pageno, nil, 1, 0, 1.0)
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 1.0)
|
||||||
DocCache:serialize()
|
DocCache:serialize()
|
||||||
end
|
end
|
||||||
DocCache:clear()
|
DocCache:clear()
|
||||||
@@ -28,7 +28,7 @@ describe("Cache module", function()
|
|||||||
|
|
||||||
it("should deserialize blitbuffer", function()
|
it("should deserialize blitbuffer", function()
|
||||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||||
doc:hintPage(pageno, 1, 0, 1.0)
|
doc:hintPage(pageno, 1, 0, 1.0, 1.0)
|
||||||
end
|
end
|
||||||
DocCache:clear()
|
DocCache:clear()
|
||||||
end)
|
end)
|
||||||
@@ -36,7 +36,7 @@ describe("Cache module", function()
|
|||||||
it("should serialize koptcontext", function()
|
it("should serialize koptcontext", function()
|
||||||
doc.configurable.text_wrap = 1
|
doc.configurable.text_wrap = 1
|
||||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||||
doc:renderPage(pageno, nil, 1, 0, 1.0)
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 1.0)
|
||||||
doc:getPageDimensions(pageno)
|
doc:getPageDimensions(pageno)
|
||||||
DocCache:serialize()
|
DocCache:serialize()
|
||||||
end
|
end
|
||||||
@@ -46,7 +46,7 @@ describe("Cache module", function()
|
|||||||
|
|
||||||
it("should deserialize koptcontext", function()
|
it("should deserialize koptcontext", function()
|
||||||
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
||||||
doc:renderPage(pageno, nil, 1, 0, 1.0)
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 1.0)
|
||||||
end
|
end
|
||||||
DocCache:clear()
|
DocCache:clear()
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ describe("ReaderLink module", function()
|
|||||||
h = 800, w = 566,
|
h = 800, w = 566,
|
||||||
},
|
},
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
|
saturation = 1,
|
||||||
visible_area = {
|
visible_area = {
|
||||||
x = 0, y = 694,
|
x = 0, y = 694,
|
||||||
h = 106, w = 566,
|
h = 106, w = 566,
|
||||||
@@ -133,6 +134,7 @@ describe("ReaderLink module", function()
|
|||||||
x = 0, y = 0,
|
x = 0, y = 0,
|
||||||
},
|
},
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
|
saturation = 1,
|
||||||
visible_area = {
|
visible_area = {
|
||||||
h = 686, w = 566,
|
h = 686, w = 566,
|
||||||
x = 0, y = 0,
|
x = 0, y = 0,
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ describe("Readerview module", function()
|
|||||||
page = 1,
|
page = 1,
|
||||||
pos = 0,
|
pos = 0,
|
||||||
gamma = 1,
|
gamma = 1,
|
||||||
|
saturation = 1,
|
||||||
offset = {
|
offset = {
|
||||||
x = 17, y = 0,
|
x = 17, y = 0,
|
||||||
h = 0, w = 0,
|
h = 0, w = 0,
|
||||||
@@ -124,6 +125,7 @@ describe("Readerview module", function()
|
|||||||
local saved_ctx = {
|
local saved_ctx = {
|
||||||
{
|
{
|
||||||
gamma = 1,
|
gamma = 1,
|
||||||
|
saturation = 1,
|
||||||
offset = {x = 17, y = 0},
|
offset = {x = 17, y = 0},
|
||||||
page = 1,
|
page = 1,
|
||||||
page_area = {
|
page_area = {
|
||||||
|
|||||||
Reference in new issue
Block a user