2012-04-14 20:32:05 +00:00
|
|
|
Image = {}
|
|
|
|
|
|
|
|
function Image._getFileData(filename)
|
2012-04-15 00:26:24 +00:00
|
|
|
local f = io.open(filename)
|
2012-04-14 20:32:05 +00:00
|
|
|
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()
|
2012-04-15 21:39:53 +00:00
|
|
|
img:loadJPEGData(Image._getFileData(filename))
|
2012-04-14 20:32:05 +00:00
|
|
|
local bb = img:toBlitBuffer()
|
|
|
|
img:free()
|
|
|
|
return bb
|
|
|
|
end
|
|
|
|
|