mirror of
https://github.com/koreader/koreader
synced 2024-11-08 07:10:27 +00:00
9e531fc2db
all lua frontend files are now in the frontend/ directory. all old code is cleaned up.
26 lines
471 B
Lua
26 lines
471 B
Lua
Image = {}
|
|
|
|
function Image._getFileData(filename)
|
|
local f = io.open(filename)
|
|
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))
|
|
local bb = img:toBlitBuffer()
|
|
img:free()
|
|
return bb
|
|
end
|
|
|