Changes

Jump to: navigation, search

Format:SGX (SymbOS graphic files)

1,396 bytes added, 16:50, 13 August 2023
/* Graphic data compression */
==Chunk types==
===Simple 4 colour graphicpart===
<pre>
byte 0: [bit0-6] width in bytes (1-63) [bit7] flag, if graphic data is compressed
byte 1: width in pixel (1-252)
byte 2: height in pixel (1-255)
if uncompressed:
byte 3-n: linear graphic data (size = byte0 * byte2)
if compressed:
byte 3,4: size of compressed graphic data
byte 5-n: compressed linear graphic data (ZX0 with SymbOS-specific header, see below)
</pre>
This chunk type can be recognized, if the first byte has a value between 1 and 63(uncompressed) or between 129 and 191 (compressed). The 4 colour graphic data is encoded in CPC Mode 1 format. Every byte contains 4 pixels:
<pre>
bit7 = bit0 of pixel0 (left pixel)
</pre>
 ===Extended 4 and 16 colour graphicpart===
<pre>
byte 0: [bit0-6] 64 [bit7] flag, if graphic data is compressed
byte 1: type (0=4 colour graphic, 5=16 colour graphic)
byte 2,3: width in bytes (1-255 [4c] or 2-254 [16c])
byte 4,5: width in pixel (1-1020 [4c] or 1-508 [16c])
byte 6,7: height in pixel (1-65535)
if uncompressed:
byte 8-n: linear graphic data (size = byte2,3 * byte6,7)
if compressed:
byte 8,9: size of compressed graphic data
byte 10-n: compressed linear graphic data (ZX0 with SymbOS-specific header, see below)
</pre>
This chunk type can be recognized with 64 (uncompressed) or 192 (compressed) in the first byte. 4 colour graphics are encoded in CPC Mode 1 format (see above). 16 colour graphics are encoded in MSX Screen 5/7 format. Every byte contains 2 pixels:
<pre>
bit7-4 (high nibble): left pixel
Please note, that currently there are some limitations:
* the maximum width for a 4 colour graphics graphic part is 1020 pixel* the maximum width for a 16 colour graphics graphic part is 508 pixel* 16 colour graphics graphic parts must always have an even width in bytes (2,4,...,254) 
===Line feed===
This chunk has a length of 3 bytes and can be recognized with 255 in the first byte. Usually every graphic part will be linked right to the previous part. After a line feed the next graphic part will be linked below the first graphic of the previous "line".
 
===EOF===
On the CPC old generation it means: red=2, green=2, blue=1 (= 1*3^0 + 2*3^1 + 2*3^2 = 25).
 
Palette configuration and colors (for 16 colors format):
 
[[Image:symbosSGX.jpg]]
 
==Graphic data compression==
 
Both simple and extended graphic parts can be stored in a compressed way.
Compressed data has to be stored in the following SymbOS-specific way, which is used for all kind of compressed data in SymbOS:
<pre>
00 4B last 4 bytes of the data (not compressed)
04 1W size of non compressed part at the beginning (always 0 for SGX files)
06 ?B not compressed part of the data (not existing in SGX files)
?? ?B compressed part of the data without the last 4 bytes
using the "ZX0 data compressor" by Einar Saukas, see
https://github.com/einar-saukas/ZX0
</pre>
 
==See also==
 
* [[SymSee|SymSee (picture viewer)]]
* [[SymbOS|SymbOS (operating system)]]
* [[Format:VID (SymbOS video files)|VID (SymbOS video files)]]
==Web links==