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

Standardized image files

Started by ElvishJerricco, 18 October 2012 - 04:27 AM
ElvishJerricco #1
Posted 18 October 2012 - 06:27 AM
So with the coming advanced computers with color screens, I imagine colors and images are about to get a lot more important. I think we need a standardized format in which files are saved to represent ascii images with colors. This obviously requires three layers. One for the background color map, one for the text color map, and one for the text itself. I was thinking it could be just a three dimensional table serialized and saved to file. At the top though, there'd be a separate header table describing the dimensions of the file. After you unserialized the data table from the file though, you could use something like this to retrieve data:


dimensions = textutils.unserialize(file.readLine())
fileTable = textutils.unserialize(file.readLine())
fileTable[x][y][map]

The last line would provide the data for <map> at coordinates (x,y), the map again being either the background color, text color, or text itself.

The reason this would be nice is because any program that wants to use anyone else's image can do so easily without storing the data in the program file itself like an idiot.

anyone got any better ideas?
matejdro #2
Posted 18 October 2012 - 08:51 AM
I think current "standard" format is .nfp - 3 paint programs support it (although I'm not sure about AutomaPaint).
faubiguy #3
Posted 18 October 2012 - 08:54 AM
A bit of a self-plug, but you may want to check of my CBM format which was created for the purpose of a universal image format. No-ones adopted it yet, but it has support for transparency and I'm working on animation. (And its smaller than text-based formats.)
Cruor #4
Posted 18 October 2012 - 09:54 AM
The standard format is indeed the one that is in Paint 2.0, nPaintPro etc. Where the colors are stored with their hex and " " is transparent. IE a 16pixle color test

0123
4567
89ab
cdef

How you load it is up to you, but there will be support for this in imageutils.
matejdro #5
Posted 18 October 2012 - 11:28 AM
Cruor what is official name of that format? I am calling it NFP because that is how nitrogenfingers named it, but I'm sure there is better name.

I like CBM because it's smaller (byte instead of text), but NFP is more readable and you can even edit it with text editor.
Cruor #6
Posted 18 October 2012 - 11:54 AM
Cruor what is official name of that format? I am calling it NFP because that is how nitrogenfingers named it, but I'm sure there is better name.

I like CBM because it's smaller (byte instead of text), but NFP is more readable and you can even edit it with text editor.
writing it as 1111 uses 4 times the space as writing it as f, because its stored as chars and not bit

also it is called .img by dan or something o_o
Orwell #7
Posted 18 October 2012 - 12:44 PM
Cruor what is official name of that format? I am calling it NFP because that is how nitrogenfingers named it, but I'm sure there is better name.

I like CBM because it's smaller (byte instead of text), but NFP is more readable and you can even edit it with text editor.
writing it as 1111 uses 4 times the space as writing it as f, because its stored as chars and not bit

also it is called .img by dan or something o_o

He didn't mean that the values are written as binary :P/>/>. He meant that they aren't stored as ascii-values, but just as a binary value (e.g. 0xf). But in fact, they are equal in size (except for the headers probably).
matejdro #8
Posted 18 October 2012 - 12:46 PM
No it IS actual binary file http://pastebin.com/69W2E4Qd

One byte can store 2 hex values in binary mode or 1 character in text mode (as with other formats) so binary format have potential to be 2x more efficient (I did not accurately checked CBM code so I'm not sure how it works)
Cruor #9
Posted 18 October 2012 - 12:50 PM
well, then you cant open the file in edit :P/>/>
Orwell #10
Posted 18 October 2012 - 12:52 PM
well, then you cant open the file in edit :P/>/>

You can, but it will all be question marks :)/>/> anyways, as they are equal in size, the use of ascii chars is a much better choice.
CastleMan2000 #11
Posted 18 October 2012 - 03:18 PM
I like this idea. I wish I knew how to make one :P/>/>