================================================================
 CCD Astrocamera format BYT for the CCDUTIL Software
================================================================

 Preamble
---------
The early CCD cameras were for astronomy buffs with a lot of
money to spare, monochrome and quite small. Image processing
software could hardly be found and it was even harder to bring
the money together to buy it. Some amateurs wrote dedicated
programs and saved the processed pictures in newly invented file
formats.

The CCDTOOLS [1] - a suite of astro CCD image processing 
software - were developed by myself in the early 90s. A DOS
application only, but quite comprehensive, very fast, extremly
cheap (gratis) and thus rather popular.

I needed a fast and space saving file format to store the
processed pictures on my 20 MB HD. Besides, a good part of the
CCDTOOLS were written in assembler and I did not want to spoil
the speed by writing huge files onto slow hard disks, which were
around 45 ms at the time.


 The BYT format
----------------
The Byte format has the file extension BYT. There is a 5 byte
file head and data compression is employed. The encoding type is
a blend of Hewlett Packards Run Length Encoding (RLE) as found
in printer software [2], and Run Length Limitation Encoding
(RLLE) initially developed by Mark Zachmann of ZSoft [3,4],
later to be found in Microsofts Paintbrush PCX image file
format.

The BYT file can contain image data for pictures of 165 lines
with 192 columns each. The pixel values are in bytes. Data is
stored columnwise, i.e. from top to bottom, left to right. The
first pixel value in the file has its origin in the top left
corner.

+--------------+-------------------------+
 5 bytes Head  n bytes RLCE image data 
+--------------+-------------------------+


 File Head
-----------
Bytes 0 & 1: Integer value (Intel format, i.e. low-high)
             containing the file size.
Bytes 2 & 3: Integer value containing the number of pixel values
             in the file.
Byte 4:      First Counter.


 Run Length Count Encoding (RLCE)
----------------------------------
RLCE combines the advantages of RLE and RLLE while evading
their disadvantages.

Byte 4, the 5th byte in the file, is the first counter. Bits 0
thru 6 make up the counter. A value of 0 is prohibitted and
flags a corrupted file. Bit 7 is special.

If bit 7 is 0: If this is the very first counter (byte 4 in the
file), this means that all data following it are uncompressed
pixel values. If it is any other counter, bit 7 = 0 means that
the following number of bytes as is the value of bit 0 thru 6 of
this counter byte, must be copied. The next counter byte will
follow immediately after the number of bytes to be copied.

Bit 7 = 1 means that the following byte has to be replicated as
many times, as is the value of bit 0 thru 6 of this counter
byte. The byte after the byte following the counter is the next
counter.

The file size is between 330 and 31'685 bytes.


 REFERENCES
------------
[1] Wernli, Hans-Ruedi; Die CCD Astrokamera fr den Amateur,
    1995, Birkhuser. ISBN 3-7643-5218-3.

[2] Hewlett Packard, Deskjet 500/500C Technical Reference
    Manual, February 1992, Part Number C2114-90008.

[3] Pohl, Martin; Eriksdottar Holger; Die wunderbare Welt der
    Grafikformate; 1991, Wolfram's, ISBN 3-925328-05-x.

[4] Born, Gnter; Referenzhandbuch Dateiformate, 1992,
    Addison-Wesley, ISBN 3-89319-446-0.


 Author
--------
hans-rudolf.wernli@bluewin.ch
http://mypage.bluewin.ch/horo/
05. August 2002
