2
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
5
* Copyright (C) 2004 NVIDIA Corporation.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of Version 2 of the GNU General Public
9
* License as published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2
14
* of the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the:
19
* Free Software Foundation, Inc.
20
* 59 Temple Place - Suite 330
21
* Boston, MA 02111-1307, USA
26
* This source file contains a simple routine for uncompressing RGB
27
* 1-byte-run-length-encoded images as generated by gimp when saving
36
#define GIMP_IMAGE_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) \
39
unsigned char *__ip; \
40
const unsigned char *__il, *__rd; \
44
__il = __ip + (size) * __bpp; \
47
if (__bpp > 3) { /* RGBA */ \
48
while (__ip < __il) { \
49
unsigned int __l = *(__rd++); \
53
memcpy (__ip, __rd, 4); __ip += 4; \
58
memcpy (__ip, __rd, __l); \
59
__ip += __l; __rd += __l; \
63
while (__ip < __il) { \
64
unsigned int __l = *(__rd++); \
68
memcpy (__ip, __rd, 3); __ip += 3; \
69
} while (--__l); __rd += 3; \
72
memcpy (__ip, __rd, __l); \
73
__ip += __l; __rd += __l; \
79
unsigned char *decompress_image_data(const nv_image_t *img)
81
unsigned char *buf = malloc(img->width *
83
img->bytes_per_pixel);
85
GIMP_IMAGE_RUN_LENGTH_DECODE(buf, img->rle_pixel_data,
86
img->width * img->height,
87
img->bytes_per_pixel);
92
void free_decompressed_image(unsigned char *buf, void *ptr)