Post by hydrophilic on Jul 22, 2014 15:24:01 GMT
I didn't want to hi-jack another thread, so let me start fresh...
So despite iPaint being fairly popular with C128, I never could find info on its format after a few hours (!) of searching. The best I could find out it is that "it is similar to BASIC 8 format but has extra color information"...
So I pulled out the BASIC 8 manual, and it seems by comparing iPaint bytes, they are the same... at least the file header. BASIC 8 manual, so far, contains only "documentation" about the format I have found, but it is pretty lame:
So, after load address, it has 5 byte magic identifier, cool.
Then it has three null bytes. I'm guessing this means start at top-left corner, presumably (would be nice if they documented this)... not sure why you would want this in an image/brush file, but anyway...
Next is "Compression Flag". What are the valid values? WOuld be nice to know... I'm guessing 0 not compressed and 1 is RLE (described below) ?
Next is "ColorSize". OK, now this really needs to be explained! **bad** documentation. I'm guessing this is the height of a color cell? (For example, the iPaint files I checked always have value 2 here)
Next is DX Columns... presumably a Column is 8 bits wide, so this gives width of bitmap / 8... would be nice if they could say... if this were true (seems reasonable guess by looking at iPaint files) then it means format is fixed-x cells (although variable-y cells per previous "ColorSize")
Next is DY... now this really needs to explained! I'm guessing it is the height of the bitmap. (For exmaple, most iPaint files say 400). If this is true, note the inconsistancy in the format! DX is bitmap_width / cell_width, but DY is **not** bitmap_height / cell_height.
Next is BC/FC/OC color bytes which really have no meaning in color bitmap ! In monochrome mode, it might be useful...
And worst of all is the last part: Brush data... ******* arg ******* what is the format of the data
All rasters, then all colors? ColorSize rasters then color size bytes (repeated for DY / ColorSize)? Or all color cells, then all rasters?
And that is just with BASIC 8... how many more possibilites are thre when you include interlace?
Well, I did find the BASIC 8 compression described later. The documentation isn't much better here, but the RLE scheme is so simple, I think I understand it! It uses a lead byte which flags raw data or repeated byte. It uses the high as raw/rle flag, and bits 0 to 6 for data (although VDC8x2 and me determined that using low bit as raw/rle flag is superior). The only thing is, I'm not sure if/how a file can be ended or about exceptions...
Like the Docs say the RLE length should be 4 to 127 because 4 is the break-even point. Actually in some cases, 3 can be useful (I know from experience and can explain if you ask) but what about values 0 to 2? Throw an error? It might be useful to write 128 or 256 bytes when you get a zero...
Similar about the Raw length; Docs say it should be 1 to 127. So is zero end-of-file or maybe 128 or 256 bytes of raw data? Or just fail with error?
****
Well I got excited when I saw a decode program, here it is:
My delight suddenly turned to disgust. I think it only takes a little familiarity with BASIC to realize that program has multiple issues. Will not work... really, no point in providing buggy documentation! Well I guess making 3D interface to BASIC was something they were good at, while writing documentation they clearly were not.
Anyway, if somebody knows of some docs for iPaint format, or some better description for BASIC 8 format, then please share!
Now there was a post by somebody (on the forum formerly known as Alive!), I dont think it was either VDC8x2 or Tokra, but they were talking about a file format for VDC images. It looked really nice compared to BASIC 8 / iPaint. It clearly defined the different parts of data (rasters, color), and cell size, and number of cells. Don't know who that was... I think I might have copied that post, or part of it... somewhere, hmm... but Anyway! It was just for developement, for now I would like to know more about real working files...
So despite iPaint being fairly popular with C128, I never could find info on its format after a few hours (!) of searching. The best I could find out it is that "it is similar to BASIC 8 format but has extra color information"...
So I pulled out the BASIC 8 manual, and it seems by comparing iPaint bytes, they are the same... at least the file header. BASIC 8 manual, so far, contains only "documentation" about the format I have found, but it is pretty lame:
The structure of a BRUSH file is:
Load Address (2 bytes) Lo/Hi
FILE IDENTIFIER (4 bytes) BRUS
FILE TYPE (1 byte) 4
Column # (1 byte)
Scanline (2 bytes) Lo/Hi
Compression Flag (1 byte)
ColorSize (1 byte)
DX Columns (1 byte)
DY (2 bytes) Lo/Hi
BC (background color 1 byte)
FC (foreground color 1 byte)
OC (outline color 1 byte)
Brush data ...
Load Address (2 bytes) Lo/Hi
FILE IDENTIFIER (4 bytes) BRUS
FILE TYPE (1 byte) 4
Column # (1 byte)
Scanline (2 bytes) Lo/Hi
Compression Flag (1 byte)
ColorSize (1 byte)
DX Columns (1 byte)
DY (2 bytes) Lo/Hi
BC (background color 1 byte)
FC (foreground color 1 byte)
OC (outline color 1 byte)
Brush data ...
So, after load address, it has 5 byte magic identifier, cool.
Then it has three null bytes. I'm guessing this means start at top-left corner, presumably (would be nice if they documented this)... not sure why you would want this in an image/brush file, but anyway...
Next is "Compression Flag". What are the valid values? WOuld be nice to know... I'm guessing 0 not compressed and 1 is RLE (described below) ?
Next is "ColorSize". OK, now this really needs to be explained! **bad** documentation. I'm guessing this is the height of a color cell? (For example, the iPaint files I checked always have value 2 here)
Next is DX Columns... presumably a Column is 8 bits wide, so this gives width of bitmap / 8... would be nice if they could say... if this were true (seems reasonable guess by looking at iPaint files) then it means format is fixed-x cells (although variable-y cells per previous "ColorSize")
Next is DY... now this really needs to explained! I'm guessing it is the height of the bitmap. (For exmaple, most iPaint files say 400). If this is true, note the inconsistancy in the format! DX is bitmap_width / cell_width, but DY is **not** bitmap_height / cell_height.
Next is BC/FC/OC color bytes which really have no meaning in color bitmap ! In monochrome mode, it might be useful...
And worst of all is the last part: Brush data... ******* arg ******* what is the format of the data
All rasters, then all colors? ColorSize rasters then color size bytes (repeated for DY / ColorSize)? Or all color cells, then all rasters?
And that is just with BASIC 8... how many more possibilites are thre when you include interlace?
Well, I did find the BASIC 8 compression described later. The documentation isn't much better here, but the RLE scheme is so simple, I think I understand it! It uses a lead byte which flags raw data or repeated byte. It uses the high as raw/rle flag, and bits 0 to 6 for data (although VDC8x2 and me determined that using low bit as raw/rle flag is superior). The only thing is, I'm not sure if/how a file can be ended or about exceptions...
Like the Docs say the RLE length should be 4 to 127 because 4 is the break-even point. Actually in some cases, 3 can be useful (I know from experience and can explain if you ask) but what about values 0 to 2? Throw an error? It might be useful to write 128 or 256 bytes when you get a zero...
Similar about the Raw length; Docs say it should be 1 to 127. So is zero end-of-file or maybe 128 or 256 bytes of raw data? Or just fail with error?
****
Well I got excited when I saw a decode program, here it is:
1 rem A sample uncompression program in Basic
5 dim a$(11)
10 open 2,8,2,"datafile,p,r"
20 get#2,a$,b$:rem get load address
30 for t=1 to 4:get#2,a$:next:rem BRUS header
40 get#2,a$:rem file type
50 for t=1 to 11:get#2,a$(t):next:rem get header info
60 if a$(i)="1" then 120
70 rem data not compressed
8O get#2,a$:s=st
90 a=asc(a$+chr$(0)):rem store A somewhere
100 if s=0 then 80
110 goto 200
120 rem compressed data
130 get#2,a$:s=st:a=asc(a$+chr$(0))
140 if (a and 127) = 0 then 210
150 get#2,a$:s=st:rem run value
160 for t=1 to (a or 127):rem run count
170 rem store asc(a$+chr$(0)) somewhere
180 next
190 if s=0 then 130
200 closa 2:end
210 rem uncompressed toggle
220 for t=1 to (a or 127)
230 get#2,a$:s=st
240 rem store asc(a$+chz$(0)) somewhere
250 it s<>o then t=(a or 127):goto 200
260 next t
270 goto 190
My delight suddenly turned to disgust. I think it only takes a little familiarity with BASIC to realize that program has multiple issues. Will not work... really, no point in providing buggy documentation! Well I guess making 3D interface to BASIC was something they were good at, while writing documentation they clearly were not.
Anyway, if somebody knows of some docs for iPaint format, or some better description for BASIC 8 format, then please share!
Now there was a post by somebody (on the forum formerly known as Alive!), I dont think it was either VDC8x2 or Tokra, but they were talking about a file format for VDC images. It looked really nice compared to BASIC 8 / iPaint. It clearly defined the different parts of data (rasters, color), and cell size, and number of cells. Don't know who that was... I think I might have copied that post, or part of it... somewhere, hmm... but Anyway! It was just for developement, for now I would like to know more about real working files...