Quote:
Originally Posted by Winkelschraube
Wow pazos, that would be awesome. I thank you already. With my Poke 2 the folder "/Pictures" and the file is best "bookcover.png". So together "/Pictures/bookcover.png".
I will certainly take a look at it and learn something from it to understand how it works and to be able to make future adjustments myself.
|
Minimum changes are:
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")
and
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
give it a try on the emulator with some books (replace "/home/pazos/Escritorio/test2.png" with the path you want). If you're fine with the changes you can move them to android.
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.