2 posts
Posted 02 March 2014 - 09:19 PM
Hello,
I have just started to play around with the "paintutils" API and made a program (A startup program)
I have tried to draw an Image to the screen, but I have no success in doing so.
If you wan't to view the code, go here!
Thanks,
JSpartan250
1281 posts
Posted 02 March 2014 - 09:33 PM
What does your image file look like? Im assuming you actually drew it with the paint program?
Edit: I took a look at the paintutils API
function loadImage( sPath )
local tImage = {}
if fs.exists( sPath ) then
local file = io.open(sPath, "r" )
local sLine = file:read()
while sLine do
local tLine = {}
for x=1,sLine:len() do
tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
end
table.insert( tImage, tLine )
sLine = file:read()
end
file:close()
return tImage
end
return nil
end
This will only return nil if the file you give it dosen't exist, so… does "IMG/Test" even exist?
Edited on 02 March 2014 - 08:42 PM
2 posts
Posted 03 March 2014 - 07:58 AM
What does your image file look like? Im assuming you actually drew it with the paint program?
Edit: I took a look at the paintutils API
function loadImage( sPath )
local tImage = {}
if fs.exists( sPath ) then
local file = io.open(sPath, "r" )
local sLine = file:read()
while sLine do
local tLine = {}
for x=1,sLine:len() do
tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
end
table.insert( tImage, tLine )
sLine = file:read()
end
file:close()
return tImage
end
return nil
end
This will only return nil if the file you give it dosen't exist, so… does "IMG/Test" even exist?
Thanks for that.
Don't know what happened, but I just came back on and it somehow worked :D/>
Thanks,
JSpartan250