The 1bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header><pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height>


<magicnumber>       := 0x01 (16bit)
<colordepth>        := 0x01 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

------------

<pixeldata>         := {<eight_pixel_row>}+
<eight_pixel_row>   := {<eight_pixels>}*width

<eight_pixels>      := pixels are stored in a byte, one upon the other, LSB first (8bit each)

Thus, image pixeldata is always stored as a multiple of eight*<width>.

Example for an image: (8x10 pixels)

                        ..XXXX..
                        .X....X.
                        X......X
                        X.X..X.X
                        X......X
                        X......X
                        X.XXXX.X
                        X..XX..X
                        .X....X.
                        ..XXXX..

         LSB     .  .  X  X  X  X  .  .
                 .  X  .  .  .  .  X  .
                 X  .  .  .  .  .  .  X
                 X  .  X  .  .  X  .  X
                 X  .  .  .  .  .  .  X
                 X  .  .  .  .  .  .  X
                 X  .  X  X  X  X  .  X
         MSB     X  .  .  X  X  .  .  X

                 FC 02 49 C1 C1 49 02 FC

         LSB     .  X  .  .  .  .  X  .
                 .  .  X  X  X  X  .  .

                 00 01 02 02 02 02 01 00

The pixel data will be represented as FC0249C1C14902FC0001020202020100

The whole image will be store as

4A 43 49 46 00 01 00 01 00 08 00 0A FC 02 49 C1
C1 49 02 FC 00 01 02 02 02 02 01 00


****************************************************************************************






The 4bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header>[<palette>]<pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height><foreground><background><mode>


<magicnumber>       := 0x00 (16bit)
<colordepth>        := 0x04 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

<foreground>        := the foreground color index in the palette (4bit)
<background>        := the background color index in the palette (4bit)

<mode>              := a set of flags as follows (8bit)

COMPRESS    0x01: image is compressed
NOPALETTE   0x02: if set, no palette is included, standard windows palette must be used
TRANSPARENT 0x08: background color that was specified above may not be painted
FOREGROUND  0x10: if not set, the image has no special foreground color, the index at <foreground> will be ignored.
BACKGROUND  0x20: if not set, the image has no special background color, the index at <background> will be ignored.



------------
The palette is an array of 48 bytes, i.e. three bytes for every color

<palette>           := {<color>}*16

<color>             := <red><green><blue>

<red>               := the red part of the color    (8bit)
<green>             := the green part of the color  (8bit)
<blue>              := the blue part of the color   (8bit)

Note that a palette may only be defined if bit 2 in <mode> is not set.
------------

<pixeldata>         := <uncompressed_data>|<compressed_data>

<uncompressed_data> := {<pixel_pair>}+
<pixel_pair>        := <pixel><pixel>
<pixel>             := the palette index for the pixel color, 0-15 (4bit)

If the image's width is an odd number of pixels, each row will be filled up by 4 bits
to complete the last byte, though they will be ignored at painting.


<compressed_data>   := {<pixel_count><pixel>}+
<pixel_count>       := number of following pixels with the same color 1=1, 2=2, ..., 15=15, 0=16 (4bit)
<pixel>             := the palette index for the pixel color, 0-15 (4bit)

NOTE: This is not row-overlapping, i.e. each row starts with a new <pixel_count><pixel>!



****************************************************************************************

The 8bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header><palette><pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height>


<magicnumber>       := 0x00 (16bit)
<colordepth>        := 0x08 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

------------

<palette>           := <length><stuff>{<color>} length times
<length>            := number of colors in the palette (8bit)
<stuff>             := 0x00 0x00 0x00 (24 bit)

<color>             := <alpha><red><green><blue>

<alpha>             := the alpha value of the color (8bit)
<red>               := the red part of the color    (8bit)
<green>             := the green part of the color  (8bit)
<blue>              := the blue part of the color   (8bit)

------------

<pixeldata>         := <compressed_data>

<compressed_data> := {<data_package>}+
<data_package> := <raw_package>|<rle_package>

<raw_package> := <raw_pixel_count>{<pixel>}+
<raw_pixel_count> := number of the following pixels (between 1 and 128) 
+ 0x7F [128 = 1 px, 129 = 2 px, ..., 255 = 128 px]

<rle_package> := <rle_pixel_count><pixel>
<rle_pixel_count> := number of the following pixels of the same color 
(between 1 and 128) - 1 [0 = 1 px, 1 = 2 px, ..., 127 = 128 px]

<pixel> := palette index or true-color value

NOTE: Compression like Targa Format
NOTE: This is not row-overlapping, i.e. each row starts with a new <pixel_count><pixel>!



****************************************************************************************

The 16bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header><pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height>


<magicnumber>       := 0x00 (16bit)
<colordepth>        := 0x10 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

------------

<pixel>             := <alpha><red><green><blue>

<alpha>             := the alpha bit (alpha or not alpha) (1bit)
<red>               := the red part of the color          (5bit)
<green>             := the green part of the color        (5bit)
<blue>              := the blue part of the color         (5bit)

8bit := (5bit<<3)|(5bit>>2)

------------

<pixeldata>         := {<pixel>}*   (width x height) times

****************************************************************************************

The 24bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header><pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height>


<magicnumber>       := 0x00 (16bit)
<colordepth>        := 0x18 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

------------

<pixel>             := <red><green><blue>

<red>               := the red part of the color    (8bit)
<green>             := the green part of the color  (8bit)
<blue>              := the blue part of the color   (8bit)

------------

<pixeldata>         := {<pixel>}*   (width x height) times



****************************************************************************************

The 32bit JControl Image File Format (JCIF)
------------------------------------------

<image>             := <header><pixeldata>

------------
<header>            := "JCIF"<magicnumber><colordepth><width><height>


<magicnumber>       := 0x00 (16bit)
<colordepth>        := 0x20 (16bit)
<width>             := image width in pixels  (16bit)
<height>            := image height in pixels (16bit)

------------

<pixel>             := <alpha><red><green><blue>

<alpha>             := the alpha value              (8bit)
<red>               := the red part of the color    (8bit)
<green>             := the green part of the color  (8bit)
<blue>              := the blue part of the color   (8bit)

------------

<pixeldata>         := {<pixel>}*  (width x height) times


-------------------------------------------------------
(c) Domologic Home Automation GmbH. All Rights Reserved.
