108 |
|
return(ferror(fp) ? -1 : 0); |
109 |
|
} |
110 |
|
|
111 |
< |
|
111 |
> |
/* |
112 |
> |
* An old-format scanline is either a stream of valid RGBE or XYZE real |
113 |
> |
* pixels or at least one real pixel followed by some number of |
114 |
> |
* invalid real pixels of the form (1,1,1,n), where n is a count. |
115 |
> |
* These can themselves be repeated to create a multibyte repeat |
116 |
> |
* count, with the least significant byte first (little-endian order.) |
117 |
> |
* Repeat counts are limited by the size of an int; if a repetition |
118 |
> |
* leads to an overrun, the rest of the the repetition will be |
119 |
> |
* silently ignored. |
120 |
> |
*/ |
121 |
|
static int |
122 |
|
oldreadcolrs( /* read in an old-style colr scanline */ |
123 |
|
COLR *scanline, |
155 |
|
return(0); |
156 |
|
} |
157 |
|
|
158 |
< |
|
158 |
> |
/* |
159 |
> |
* There are two scanline formats: old and new. The old format |
160 |
> |
* compresses runs of RGBE or XYZE four-byte real pixels; the new |
161 |
> |
* format breaks the pixels into R, G, B, and E lines (or XYZE lines) |
162 |
> |
* which are individually run-length encoded. |
163 |
> |
* |
164 |
> |
* An old-format scanline always begins with a valid real pixel; at |
165 |
> |
* least one of the RGB (or XYZ) values will have its high-order bit |
166 |
> |
* set. A new-format scanline begins with four bytes which are not a |
167 |
> |
* valid real pixel: (2, 2, lenhigh, lenlow) where lenhigh is always |
168 |
> |
* less than 128 and hence never has a high-order bit set. |
169 |
> |
* |
170 |
> |
* A new-format scanline is broken into its RGBE or XYZE components. |
171 |
> |
* Each is output and run-length encoded separately so that a scanline |
172 |
> |
* is broken into four records. In turn, each record is organized |
173 |
> |
* into chunks of up to 128 characters, which begin with a count byte. |
174 |
> |
* If the count byte is greater than 128, the following data byte is |
175 |
> |
* repeated (count-128) times. If not, the count byte is followed by |
176 |
> |
* that many data bytes. |
177 |
> |
*/ |
178 |
|
int |
179 |
|
freadcolrs( /* read in an encoded colr scanline */ |
180 |
|
COLR *scanline, |