Difference between revisions of "Format:SGX (SymbOS graphic files)"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(Palette)
(Web links)
 
(8 intermediate revisions by 2 users not shown)
Line 8: Line 8:
 
==Chunk types==
 
==Chunk types==
  
===Simple 4 colour graphic===
+
===Simple 4 colour graphic part===
  
 
<pre>
 
<pre>
byte 0: width in bytes (1-63)
+
byte 0: [bit0-6] width in bytes (1-63)
 +
        [bit7] flag, if graphic data is compressed
 
byte 1: width in pixel (1-252)
 
byte 1: width in pixel (1-252)
 
byte 2: height in pixel (1-255)
 
byte 2: height in pixel (1-255)
 +
if uncompressed:
 
byte 3-n: linear graphic data (size = byte0 * byte2)
 
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>
 
</pre>
  
This chunk type can be recognized, if the first byte has a value between 1 and 63. The 4 colour graphic data is encoded in CPC Mode 1 format. Every byte contains 4 pixels:
+
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>
 
<pre>
 
bit7 = bit0 of pixel0 (left pixel)
 
bit7 = bit0 of pixel0 (left pixel)
Line 37: Line 42:
 
</pre>
 
</pre>
  
 
+
===Extended 4 and 16 colour graphic part===
===Extended 4 and 16 colour graphic===
+
  
 
<pre>
 
<pre>
byte 0: 64
+
byte 0: [bit0-6] 64
 +
        [bit7] flag, if graphic data is compressed
 
byte 1: type (0=4 colour graphic, 5=16 colour graphic)
 
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 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 4,5: width in pixel (1-1020 [4c] or 1-508 [16c])
 
byte 6,7: height in pixel (1-65535)
 
byte 6,7: height in pixel (1-65535)
 +
if uncompressed:
 
byte 8-n: linear graphic data (size = byte2,3 * byte6,7)
 
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>
 
</pre>
  
This chunk type can be recognized with 64 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:
+
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>
 
<pre>
 
bit7-4 (high nibble): left pixel
 
bit7-4 (high nibble): left pixel
Line 56: Line 65:
  
 
Please note, that currently there are some limitations:
 
Please note, that currently there are some limitations:
* the maximum width for 4 colour graphics is 1020 pixel
+
* the maximum width for a 4 colour graphic part is 1020 pixel
* the maximum width for 16 colour graphics is 508 pixel
+
* the maximum width for a 16 colour graphic part is 508 pixel
* 16 colour graphics must always have an even width in bytes (2,4,...,254)
+
* 16 colour graphic parts must always have an even width in bytes (2,4,...,254)
 
+
  
 
===Line feed===
 
===Line feed===
Line 69: Line 77:
  
 
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".
 
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===
 
===EOF===
Line 104: Line 111:
  
  
Pallete configuration an colors:
+
Palette configuration and colors (for 16 colors format):
  
 
[[Image:symbosSGX.jpg]]
 
[[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==
 
==Web links==
  
* [http://www.symbos.de/download.htm#marke3 SGX file downloads]
+
* [https://www.symbos.org/media.htm?1 SGX file downloads]
  
 
[[Category:SymbOS]]
 
[[Category:SymbOS]]
 
[[Category:Programming]]
 
[[Category:Programming]]

Latest revision as of 02:40, 10 August 2024

Screen shots showing the same 16 colour SGX graphic in 6 different screen modes

This is a description of the SGX graphic format used in SymbOS and in SymSee.

A SGX graphic consists of any number of chunks, which define different picture parts. While there are limitations for the width and the height of a single part, the complete graphic can have any size, as all parts will be linked together.


Chunk types

Simple 4 colour graphic part

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)

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:

bit7 = bit0 of pixel0 (left pixel)
bit6 = bit0 of pixel1
bit5 = bit0 of pixel2
bit4 = bit0 of pixel3 (right pixel)
bit3 = bit1 of pixel0
bit2 = bit1 of pixel1
bit1 = bit1 of pixel2
bit0 = bit1 of pixel3

Or you can see it like this:

pixel0 = bit7 + 2 * bit3 (left pixel)
pixel1 = bit6 + 2 * bit2
pixel2 = bit5 + 2 * bit1
pixel3 = bit4 + 2 * bit0 (right pixel)

Extended 4 and 16 colour graphic part

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)

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:

bit7-4 (high nibble): left pixel
bit3-0 (low nibble): right pixel

Please note, that currently there are some limitations:

  • the maximum width for a 4 colour graphic part is 1020 pixel
  • the maximum width for a 16 colour graphic part is 508 pixel
  • 16 colour graphic parts must always have an even width in bytes (2,4,...,254)

Line feed

byte 0: 255
byte 1,2: undefined

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

byte 0: 0
byte 1,2: undefined

An EOF is not explicit required, but should be added, if graphics are stored on an Amsdos or CP/M disc, as these file system are not able to store the exact size of a file.


Palette

SGX files don't contain colour palette definitions, as these graphics have been designed in a way, which makes it possible to display them in any environment and colour-depth (2, 4 or 16 colours) on the SymbOS desktop.

For 4 colour graphics it means, that there is just a grayscale definition:

  • Pen 0: white
  • Pen 1: black
  • Pen 2: light gray
  • Pen 3: dark gray

This can be used for any type of colour, like orange, brown, light red, dark red etc.

16 colour graphics have a fixed palette which has the following definition:

  • Pen 00-03: #ff8,#000,#f80,#800
  • Pen 04-07: #0ff,#008,#88f,#00f
  • Pen 08-11: #fff,#080,#0f0,#f0f
  • Pen 12-15: #ff0,#888,#f88,#f00

The values are in CPC Plus RGB format. #ff8 means: red=15, green=15, blue=8.

On the MSX it would mean: red=7, green=7, blue=4.

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):

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:

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

See also

Web links