added interface to get blitbuffers from JPEG/PNG files

this is supposed to help us in the UI code.
This commit is contained in:
HW
2012-04-14 22:32:05 +02:00
parent e52b4808b1
commit 38afb59b3f
5 changed files with 210 additions and 2 deletions

25
image.lua Normal file
View 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