08-31-2020, 02:58 PM | #31 | |
cosiñeiro
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
|
Quote:
Code:
--- a/frontend/apps/reader/readerui.lua +++ b/frontend/apps/reader/readerui.lua @@ -555,6 +555,11 @@ function ReaderUI:doShowReader(file, provider) }) self:showFileManager() return + else + local image = document:getCoverPageImage() + if image then + Device.screen.bb:writePNG("/home/pazos/Escritorio/test2.png", false, image) + end end if document.is_locked then logger.info("document is locked") Code:
--- a/ffi/blitbuffer.lua +++ b/ffi/blitbuffer.lua @@ -1760,7 +1760,7 @@ write blitbuffer contents to a PNG file @param filename the name of the file to be created --]] local Png -- lazy load ffi/png -function BB_mt.__index:writePNG(filename, bgr) +function BB_mt.__index:writePNG(filename, bgr, buffer) if not Png then Png = require("ffi/png") end local hook, mask, _ = debug.gethook() debug.sethook() @@ -1770,7 +1770,8 @@ function BB_mt.__index:writePNG(filename, bgr) for y = 0, h-1 do local offset = 4 * w * y for x = 0, w-1 do - local c = self:getPixel(x, y):getColorRGB32() + local c = buffer and buffer:getPixel(x, y):getColorRGB32() or + self:getPixel(x, y):getColorRGB32() -- NOTE: Kobo's FB is BGR(A), we already trick MuPDF into doing it that way for us, so, keep faking it here! if bgr then mem[offset] = c.b Probably the 2nd block of code can be upstreamed, because it doesn't affect current code in any way and is just a quick way of writting a png file from a memory buffer without having to write to the framebuffer first. |
|
08-31-2020, 08:23 PM | #32 |
BLAM!
Posts: 13,478
Karma: 26012494
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
@pazos: The second hunk does make sense, but it's missing getting the width/height from buffer, too, because right now it uses the image buffer but with the framebuffer's dimensions .
(Which I realize may be the point, but then what happens if image buffer's dimension != framebuffer's dimension?) |
Advert | |
|
09-01-2020, 01:25 AM | #33 |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
Thank you very much. I see this eventing.
|
09-01-2020, 08:19 AM | #34 | |
cosiñeiro
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
|
Quote:
And the proper code, as suggested, would be: Code:
--- a/ffi/blitbuffer.lua +++ b/ffi/blitbuffer.lua @@ -1760,17 +1760,19 @@ write blitbuffer contents to a PNG file @param filename the name of the file to be created --]] local Png -- lazy load ffi/png -function BB_mt.__index:writePNG(filename, bgr) +function BB_mt.__index:writePNG(filename, bgr, buffer) if not Png then Png = require("ffi/png") end local hook, mask, _ = debug.gethook() debug.sethook() - local w, h = self:getWidth(), self:getHeight() + local w = buffer and buffer:getWidth() or self:getWidth() + local h = buffer and buffer:getHeight() or self:getHeight() local cdata = C.malloc(w * h * 4) local mem = ffi.cast("char*", cdata) for y = 0, h-1 do local offset = 4 * w * y for x = 0, w-1 do - local c = self:getPixel(x, y):getColorRGB32() + local c = buffer and buffer:getPixel(x, y):getColorRGB32() or + self:getPixel(x, y):getColorRGB32() -- NOTE: Kobo's FB is BGR(A), we already trick MuPDF into doing it that way for us, so, keep faking it here! if bgr then mem[offset] = c.b |
|
09-01-2020, 01:11 PM | #35 |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
Ok it works!!11! WOOHOO.
(Don't you really want to add this as an option? Calibre Companion should be able to do that as well. And KOReader is very much better ) But I have to build "./kodev release --debug android". I don't have a Google account to sign by myself. The file is very big and loading is very slow. I still have one problem, the image on the Poke 2 screensaver is scaled to screen size. If the width of the cover image is very small, it will be cut off at the top and bottom because it will be scaled until it is full screen. Is there an option to adjust the background of the image to the screen ratio? |
Advert | |
|
09-01-2020, 01:26 PM | #36 |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
Pictures of the scaling problem attached.
|
09-01-2020, 01:42 PM | #37 | |||
cosiñeiro
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
|
Quote:
Quote:
Quote:
Last edited by pazos; 09-01-2020 at 02:37 PM. |
|||
09-02-2020, 01:14 AM | #38 | |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
Quote:
I was thinking about an imagemagic script that runs in the background and checks every 30 minutes if the image has been rewritten. Because I have no idea about Lua. But of course it is better to do it in KOReader, I will try it in the next weeks. Thanks a lot for your help so far. This is really great. |
|
09-04-2020, 09:10 AM | #39 | |
Member
Posts: 11
Karma: 10
Join Date: Jan 2019
Device: PW4, tolino epos 2
|
Quote:
This would be a great solution for a rooted Android e-Ink reader. You would need an option for the screensaver so that the image can be saved in a certain format (jpg or png) in a user defined directory. In the local KOReader installation you would only have to activate the screensaver in android/device.lua. |
|
09-22-2020, 01:25 PM | #40 |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
I removed the hack three weeks ago.
It did not work, whenever I clicked on a book in the file manager, KOReader started loading and eventually stopped. (I checked with "adb logcat".) When I tapped on the top of the screen, it finished loading (re-rendered the font each time). The image was also created. It worked fine when the Poke 2 was loaded with a USB cable. I did not notice any differences with adb. Now I only changed the picture name in "screenshoter.lua" in line 42 to "screenshot.png" without date. So I just take a screenshot at the beginning of each book and that is the new screensaver. Code:
self.screenshot_fn_fmt = screenshots_dir .. "screenshot.png" |
10-13-2020, 05:59 AM | #41 | |
Connoisseur
Posts: 98
Karma: 10
Join Date: Jul 2020
Device: The (orly) amazing Kindle Oasis 3
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Use local file as cover image | jma1 | Recipes | 1 | 03-09-2020 11:14 AM |
AZW3 file loading incorrect cover in kindle | grapebasil | Library Management | 1 | 03-15-2018 07:41 PM |
Where else can a MOBI file have its cover image? | Alissa | Kindle Formats | 6 | 07-13-2013 02:50 PM |
Books loading into document file | Mumgod | Kindle Fire | 14 | 02-07-2012 05:37 AM |
Document converter (to pdf or image file) | Bob Russell | Lounge | 1 | 09-09-2004 04:01 PM |