Skip to content

kopt: option to invert document in night mode#14954

Merged
Frenzie merged 3 commits into
koreader:masterfrom
Euphoriyy:invert-document
Mar 8, 2026
Merged

kopt: option to invert document in night mode#14954
Frenzie merged 3 commits into
koreader:masterfrom
Euphoriyy:invert-document

Conversation

@Euphoriyy

@Euphoriyy Euphoriyy commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Adds a document option for CBZs/PDFs to invert the document in night mode. Uses invertblitFrom().

Resolves #9899.

invert-document

This change is Reviewable

@Euphoriyy

Copy link
Copy Markdown
Contributor Author

Any thoughts?

@poire-z

poire-z commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Fine with the setting position (it makes the last panel have 5 items, but only when nightmode is enabled, and it's the same for ReaderRolling).
@NiLuJe will have to validate the BlitBuffer magic (right methods, in the right order, etc...)

@Frenzie Frenzie added this to the 2026.02 milestone Feb 17, 2026
@Frenzie

Frenzie commented Feb 17, 2026

Copy link
Copy Markdown
Member

The blitbuffer stuff is fine in principle, but note that k2pdfopt has a -neg option. It might be more efficient to use that instead.

@Euphoriyy

Copy link
Copy Markdown
Contributor Author

Fine with the setting position (it makes the last panel have 5 items, but only when nightmode is enabled, and it's the same for ReaderRolling).

You said last panel, but this is currently on the contrast panel. Should it be moved to the last one to match "Invert Images"?

k2pdfopt has a -neg option. It might be more efficient to use that instead.

That's interesting. The part of k2pdfopt responsible for that seems to bek2settings->dst_negative. I don't think there is direct control over that with KOPTContext currently because k2pdfopt_settings_init_from_koptcontext(k2settings, kctx)doesn't set that option from the context.

@Frenzie

Frenzie commented Feb 17, 2026

Copy link
Copy Markdown
Member

I don't think there is direct control over that with KOPTContext currently because k2pdfopt_settings_init_from_koptcontext(k2settings, kctx)doesn't set that option from the context.

KOPTContext controls what we want it to control. ;-) But since it'll ultimately do something very similar it'd probably mostly be keeping things a touch more legible over here.

On the flip side, this way you can also apply the same thing to PicDocument.

@poire-z

poire-z commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

You said last panel, but this is currently on the contrast panel. Should it be moved to the last one to match "Invert Images"?

Oh, right.
I wouldn't really mind in what panel it is: my point was that I don't like more than 4 items per panel - so we can see more of the page, but going from 4 to 5 in one panel only when in night mode can be ok (only nightmode users will suffer :))
But it feels it would not be out of place in the last panel (with other document related thingies like Document Language, Writing Directions, Document colons - it's about the document that it has/is real images, and we want them non-inverted in nightmode (+ the symetry with ReaderRolling/creopt).
The Contrast pannel might be considered more about the text/pages than the document ? (but I'm not really a Pdf reader).

@Euphoriyy

Euphoriyy commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

But since it'll ultimately do something very similar it'd probably mostly be keeping things a touch more legible over here.

Yeah, that might be better than messing around with blitters. Although, one benefit of inverting it after is not having to update the cache.

But it feels it would not be out of place in the last panel (with other document related thingies like Document Language, Writing Directions, Document colons - it's about the document that it has/is real images, and we want them non-inverted in nightmode (+ the symetry with ReaderRolling/creopt).

That's definitely a good point. Although it might be more similar to the dewatermark and contrast option in practice, conceptually it is definitely a document option especially since it is dependent on night mode. And ultimately the consistency/symmetry with creopt is probably preferable.

@Frenzie Frenzie merged commit a47ecfc into koreader:master Mar 8, 2026
4 checks passed
Frenzie pushed a commit that referenced this pull request Mar 17, 2026
)

Due to changes to renderOptimizedPage(...) made by #15067, which was merged after #14954 was made, a regression was introduced that causes instability and even crashes on mobile devices and e-readers when Invert Document is enabled along with Reflow or Auto Straighten.

This PR fixes the regression and simplifies the drawContextPage(...) method.
jqs7 pushed a commit to jqs7/koreader that referenced this pull request Mar 19, 2026
…eader#15123)

Due to changes to renderOptimizedPage(...) made by koreader#15067, which was merged after koreader#14954 was made, a regression was introduced that causes instability and even crashes on mobile devices and e-readers when Invert Document is enabled along with Reflow or Auto Straighten.

This PR fixes the regression and simplifies the drawContextPage(...) method.
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
…eader#15123)

Due to changes to renderOptimizedPage(...) made by koreader#15067, which was merged after koreader#14954 was made, a regression was introduced that causes instability and even crashes on mobile devices and e-readers when Invert Document is enabled along with Reflow or Auto Straighten.

This PR fixes the regression and simplifies the drawContextPage(...) method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Add 'Invert Images' option to .CBZ and .PDF file formats

3 participants