This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Fetchetch's profile picture

Displaying images without a file?

Started by Fetchetch, 08 July 2015 - 10:36 PM
Fetchetch #1
Posted 09 July 2015 - 12:36 AM
So recently I started developing Project Arch (a os in one file) and was wondering how to achieve displaying a image from a table (what paintutils.loadImage("img") puts in a var/table). I had tried it in the past using good ol' [[ and ]] (and it didnt work xD) but still errors out when paintutils.drawImage() tries to draw.

Any suggestions?
Edited on 08 July 2015 - 10:37 PM
Bomb Bloke #2
Posted 09 July 2015 - 01:06 AM
Load a paintutils image, then serialise the resulting table to a file. This'll show you the format you're after.

local myImage = paintutils.loadImage("someImage")

local myFile = fs.open("imageTableExample.txt", "w")
myFile.writeLine(textutils.serialize(myImage))
myFile.close()
Fetchetch #3
Posted 09 July 2015 - 01:10 AM
Load a paintutils image, then serialise the resulting table to a file. This'll show you the format you're after.

local myImage = paintutils.loadImage("someImage")

local myFile = fs.open("imageTableExample.txt", "w")
myFile.writeLine(textutils.serialize(myImage))
myFile.close()

Thanks!

Kinda what im looking for, but at the same time, not.
What I was looking for, was it to load a table,
(e.g:)

local img = [[22222
]]
(that makes: █████) //offtopic: If your wondering how i did it, use this █ and play with the colors and size.
then put it into a code that paintutils can understand, then draw it to the screen.
Edited on 09 July 2015 - 12:37 AM
MKlegoman357 #4
Posted 09 July 2015 - 08:40 AM
With the code Bomb Bloke provided you'd be able to simply copy-paste the table into your code and use paintutils.drawImage directly with it.
Bomb Bloke #5
Posted 09 July 2015 - 10:04 AM
If you specifically want to format your data like that, then term.blit() may be of interest to you.
Fetchetch #6
Posted 09 July 2015 - 06:10 PM


term.blit("t","b","b")
boot:42: Arguments must be the same length
HPWebcamAble #7
Posted 09 July 2015 - 06:54 PM

term.blit("t","b","b")
boot:42: Arguments must be the same length

That works for me (In CCEmuRedux)

Are you sure that's the 42nd line in 'boot'?
Fetchetch #8
Posted 09 July 2015 - 07:02 PM

term.blit("t","b","b")
boot:42: Arguments must be the same length

That works for me (In CCEmuRedux)

Are you sure that's the 42nd line in 'boot'?


(Using atom for editor btw)
______________________^^ = my stupidity. Never noticed that.
Edited on 09 July 2015 - 05:04 PM
Bomb Bloke #9
Posted 11 July 2015 - 12:51 AM
I've posted some code here that may do what you want.