mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
added interface to get blitbuffers from JPEG/PNG files
this is supposed to help us in the UI code.
This commit is contained in:
25
image.lua
Normal file
25
image.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
Image = {}
|
||||
|
||||
function Image._getFileData(filename)
|
||||
local f = io.open("test.png")
|
||||
local data = f:read("*a")
|
||||
f:close()
|
||||
return data
|
||||
end
|
||||
|
||||
function Image.fromPNG(filename)
|
||||
local img = mupdfimg.new()
|
||||
img:loadPNGData(Image._getFileData(filename))
|
||||
local bb = img:toBlitBuffer()
|
||||
img:free()
|
||||
return bb
|
||||
end
|
||||
|
||||
function Image.fromJPEG(filename)
|
||||
local img = mupdfimg.new()
|
||||
img:loadJPEGData(Image._getFileData(filename)(fimgdatailename))
|
||||
local bb = img:toBlitBuffer()
|
||||
img:free()
|
||||
return bb
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user