| 1 |
/* Copyright (C) 2008 Vincent Penquerc'h. |
| 2 |
This file is part of the Kate codec library. |
| 3 |
Written by Vincent Penquerc'h. |
| 4 |
|
| 5 |
Use, distribution and reproduction of this library is governed |
| 6 |
by a BSD style source license included with this source in the |
| 7 |
file 'COPYING'. Please read these terms before distributing. */ |
| 8 |
|
| 9 |
|
| 10 |
/** |
| 11 |
|
| 12 |
\page format_rle Format - RLE bitmap |
| 13 |
|
| 14 |
RLE bitmaps are stored line per line, each line encoded with a particular algorithm, |
| 15 |
usually a variation of RLE. |
| 16 |
|
| 17 |
Let \b N be the number of bits per pixel of this bitmap. |
| 18 |
|
| 19 |
\li \b N bits being the "zero" color (it doesn't really matter what this color is, but the |
| 20 |
compression is best if this is the background color) |
| 21 |
|
| 22 |
Then, for each row in the bitmap: |
| 23 |
|
| 24 |
\li 3 bits representing the type of encoding used for this line. |
| 25 |
|
| 26 |
|
| 27 |
\par For encoding 0 (empty): |
| 28 |
There is no more data for this line, it consists of a single line of pixels of the "zero" color. |
| 29 |
|
| 30 |
\par For encoding 1 (basic): |
| 31 |
While there are still pixels to decode in this line: |
| 32 |
\li 4 bits representing the number \b P of pixels of an identical color, minus 1 (eg, 0 means a single pixel). |
| 33 |
\li \b N bits representing the color \b C. |
| 34 |
|
| 35 |
Then the next \b P pixels are filled with color \b C. |
| 36 |
|
| 37 |
|
| 38 |
\par For encoding 2 (delta): |
| 39 |
While there are still pixels to decode in this line: |
| 40 |
\li 1 bit being 1 if the pixel run is encoded as delta, 0 if not |
| 41 |
|
| 42 |
If the bit is 1: |
| 43 |
\li 6 bits representing the number \b P of pixels in this run, minus 1 |
| 44 |
The next \b P pixels are filled from a copy of the pixels in the previous line, starting at the same horizontal offset, |
| 45 |
or, if this is the first line of the bitmap, they are filled with the "zero" color. |
| 46 |
|
| 47 |
If the bit is 0: |
| 48 |
\li 3 bits representing the number \b P of pixels in this run, minus 1 |
| 49 |
\li \b N bits representing the color \b C. |
| 50 |
Then the next \b P pixels are filled with color \b C. |
| 51 |
|
| 52 |
|
| 53 |
\par For encoding 3 (basic/stop): |
| 54 |
\li 8 bits representing a number \b P of pixels in an initial run - if \b P is greater than zero, \b P pixels are filled with the "zero" color. |
| 55 |
|
| 56 |
Then, while there are still pixels to decode in this line: |
| 57 |
\li 6 bits representing the number \b P of pixels in this run, or 0 |
| 58 |
\li if \b P is greater than zero, \b N bits being the color to fill the next \b P pixels with. |
| 59 |
\li if \b P is zero, the remainder of the line is filled with the zero color. |
| 60 |
|
| 61 |
\par For encoding 4 (basic/startend): |
| 62 |
\li 9 bits representing the number \b P of pixels in a run of color "zero" at the start of the line (0 for an empty run) |
| 63 |
\li 9 bits representing the number \b P of pixels in a run of color "zero" at the end of the line (0 for an empty run) |
| 64 |
|
| 65 |
Then, while there are still pixels to decode in this line: |
| 66 |
\li 3 bits representing the number \b P of pixels in this run, minus 1 |
| 67 |
\li \b N bits representing the color \b C. |
| 68 |
Then the next \b P pixels are filled with color \b C. |
| 69 |
|
| 70 |
\par For encoding 5 (delta/stop): |
| 71 |
While there are still pixels to decode in this line: |
| 72 |
\li 1 bit being 1 if the next run is delta encoded, and 0 otherwise. |
| 73 |
|
| 74 |
If the bit is 1: |
| 75 |
\li 5 bits representing the number \b P of pixels in this run, minus 1 |
| 76 |
The next \b P pixels are filled from a copy of the pixels in the previous line, starting at the same horizontal offset, |
| 77 |
or, if this is the first line of the bitmap, they are filled with the "zero" color. |
| 78 |
|
| 79 |
If the bit is 0: |
| 80 |
\li 3 bits representing the number \b P of pixels in this run, or 0. |
| 81 |
\li if \b P is greater than zero, \b N bits representing the color of the pixels in this run. |
| 82 |
\li if \b P is zero, the remainder of the line is filled with the zero color. |
| 83 |
|
| 84 |
\par For encoding 6 (basic/zero): |
| 85 |
While there are still pixels to decode in this line: |
| 86 |
\li \b N bits representing the color \b C of this run. |
| 87 |
\li if \b C is the "zero" color, 8 bits representing the length \b P of this run, minus 1. |
| 88 |
\li if \b C is not the "zero" color, 3 bits representing the length \b P of this run, minus 1. |
| 89 |
Then, the next \b P pixels are filled with color \b C. |
| 90 |
|
| 91 |
|
| 92 |
\par For encoding 7: |
| 93 |
Encoding 7 is reserved for future use. A decoder encountering encoding 7 will not be able |
| 94 |
to decode the line, and thus the bitmap. |
| 95 |
|
| 96 |
|
| 97 |
*/ |
| 98 |
|