mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
Night mode: keep some images non-inverted
Have the code pre-invert some images when in night mode, so they get inverted back to normal by night mode. This will allow images to be displayed normally in the following contexts: - images in credocument pages - long-press on images in credocument viewed in ImageViewer - cover thumbnails in File browser and History - full size covers when viewed in ImageViewer - images in Wikipedia lookup results
This commit is contained in:
parent
4a51e24b7a
commit
8f019b8183
@ -365,11 +365,19 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
|
|||||||
end
|
end
|
||||||
-- TODO: self.buffer could be re-used when no page/layout/highlights
|
-- TODO: self.buffer could be re-used when no page/layout/highlights
|
||||||
-- change has been made, to avoid having crengine redraw the exact
|
-- change has been made, to avoid having crengine redraw the exact
|
||||||
-- same buffer.
|
-- same buffer. And it could only change when some other methods
|
||||||
-- And it could only change when some other methods from here are called
|
-- from here are called
|
||||||
|
|
||||||
|
-- If in night mode, ask crengine to invert all images, so they
|
||||||
|
-- get displayed in their original colors when the whole screen
|
||||||
|
-- is inverted by night mode
|
||||||
|
local invert_images = G_reader_settings:isTrue("night_mode")
|
||||||
|
|
||||||
-- local start_clock = os.clock()
|
-- local start_clock = os.clock()
|
||||||
self._drawn_images_count, self._drawn_images_surface_ratio = self._document:drawCurrentPage(self.buffer, self.render_color)
|
self._drawn_images_count, self._drawn_images_surface_ratio =
|
||||||
|
self._document:drawCurrentPage(self.buffer, self.render_color, invert_images)
|
||||||
-- print(string.format("CreDocument:drawCurrentView: Rendering took %9.3f ms", (os.clock() - start_clock) * 1000))
|
-- print(string.format("CreDocument:drawCurrentView: Rendering took %9.3f ms", (os.clock() - start_clock) * 1000))
|
||||||
|
|
||||||
-- start_clock = os.clock()
|
-- start_clock = os.clock()
|
||||||
target:blitFrom(self.buffer, x, y, 0, 0, rect.w, rect.h)
|
target:blitFrom(self.buffer, x, y, 0, 0, rect.w, rect.h)
|
||||||
-- print(string.format("CreDocument:drawCurrentView: Blitting took %9.3f ms", (os.clock() - start_clock) * 1000))
|
-- print(string.format("CreDocument:drawCurrentView: Blitting took %9.3f ms", (os.clock() - start_clock) * 1000))
|
||||||
|
@ -373,6 +373,13 @@ function ImageWidget:paintTo(bb, x, y)
|
|||||||
if self.dim then
|
if self.dim then
|
||||||
bb:dimRect(x, y, size.w, size.h)
|
bb:dimRect(x, y, size.w, size.h)
|
||||||
end
|
end
|
||||||
|
-- If in night mode, invert all rendered images, so the original is
|
||||||
|
-- displayed when the whole screen is inverted by night mode.
|
||||||
|
-- Except for our black & white icon files, that we want inverted
|
||||||
|
-- in night mode.
|
||||||
|
if not self.file and G_reader_settings:isTrue("night_mode") then
|
||||||
|
bb:invertRect(x, y, size.w, size.h)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This will normally be called by our WidgetContainer:free()
|
-- This will normally be called by our WidgetContainer:free()
|
||||||
|
Loading…
Reference in New Issue
Block a user