48 int len,
int pixelstride)
51 unsigned char *orig = out_buf;
54 while (out_buf < out_end) {
57 pixel = bytestream2_get_byteu(&s->
g);
58 if (!(count = (pixel & 0x7f))) {
63 if (out_end - out_buf <= pixelstride * (count - 1)) {
70 *out_buf = bytestream2_get_byte(&s->
g);
71 out_buf += pixelstride;
74 pixel = bytestream2_get_byte(&s->
g);
78 out_buf += pixelstride;
82 return (out_buf - orig) / pixelstride;
86 int len,
int pixelstride)
90 unsigned short *orig = out_buf;
91 uint16_t *out_end = out_buf +
len;
93 while (out_buf < out_end) {
96 pixel = bytestream2_get_be16u(&s->
g);
97 if (!(count = (pixel & 0x7f)))
101 if (pixelstride * (count - 1) >= len) {
110 out_buf += pixelstride;
117 out_buf += pixelstride;
121 return (out_buf - orig) / pixelstride;
137 unsigned int start_offset;
145 for (z = 0; z < s->
depth; z++) {
147 for (y = 0; y < s->
height; y++) {
150 start_offset = bytestream2_get_be32(&g_table);
181 for (z = 0; z < s->
depth; z++) {
186 for (y = s->
height - 1; y >= 0; y--) {
187 out_end = out_buf + (y * s->
linesize);
189 for (x = s->
width; x > 0; x--)
190 for (z = 0; z < s->
depth; z++)
191 *out_end++ = bytestream2_get_byteu(&gp[z]);
193 uint16_t *out16 = (uint16_t *)out_end;
194 for (x = s->
width; x > 0; x--)
195 for (z = 0; z < s->
depth; z++)
203 void *
data,
int *got_frame,
208 unsigned int dimension, rle;
219 if (bytestream2_get_be16u(&s->
g) !=
SGI_MAGIC) {
224 rle = bytestream2_get_byteu(&s->
g);
226 dimension = bytestream2_get_be16u(&s->
g);
227 s->
width = bytestream2_get_be16u(&s->
g);
228 s->
height = bytestream2_get_be16u(&s->
g);
229 s->
depth = bytestream2_get_be16u(&s->
g);
237 if (dimension != 2 && dimension != 3) {
262 out_buf = p->
data[0];