Update headers, adapt to imlib2 changes, switch to stdint types

This commit is contained in:
Kim Woelders 2022-04-03 06:29:23 +02:00
parent 4dee30ae6a
commit c41a2a2e4e
8 changed files with 253 additions and 251 deletions

View File

@ -44,15 +44,15 @@
#define PIXEL_B(argb) (((argb) ) & 0xff)
#ifndef WORDS_BIGENDIAN
#define A_VAL(p) ((DATA8 *)(p))[3]
#define R_VAL(p) ((DATA8 *)(p))[2]
#define G_VAL(p) ((DATA8 *)(p))[1]
#define B_VAL(p) ((DATA8 *)(p))[0]
#define A_VAL(p) ((uint8_t *)(p))[3]
#define R_VAL(p) ((uint8_t *)(p))[2]
#define G_VAL(p) ((uint8_t *)(p))[1]
#define B_VAL(p) ((uint8_t *)(p))[0]
#else
#define A_VAL(p) ((DATA8 *)(p))[0]
#define R_VAL(p) ((DATA8 *)(p))[1]
#define G_VAL(p) ((DATA8 *)(p))[2]
#define B_VAL(p) ((DATA8 *)(p))[3]
#define A_VAL(p) ((uint8_t *)(p))[0]
#define R_VAL(p) ((uint8_t *)(p))[1]
#define G_VAL(p) ((uint8_t *)(p))[2]
#define B_VAL(p) ((uint8_t *)(p))[3]
#endif
#define CLIP(x, y, w, h, xx, yy, ww, hh) \

View File

@ -43,7 +43,7 @@ typedef struct _ImlibImageTag {
struct _ImlibImage {
char *file;
int w, h;
DATA32 *data;
uint32_t *data;
ImlibImageFlags flags;
time_t moddate;
ImlibBorder border;
@ -85,7 +85,7 @@ void __imlib_LoaderSetFormats(ImlibLoader * l,
const char *const *fmt,
unsigned int num);
ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data);
ImlibImage *__imlib_CreateImage(int w, int h, uint32_t * data);
ImlibImage *__imlib_LoadImage(const char *file, ImlibLoadArgs * ila);
int __imlib_LoadEmbedded(ImlibLoader * l, ImlibImage * im,
const char *file, int load_data);
@ -93,12 +93,11 @@ int __imlib_LoadImageData(ImlibImage * im);
void __imlib_DirtyImage(ImlibImage * im);
void __imlib_FreeImage(ImlibImage * im);
void __imlib_SaveImage(ImlibImage * im, const char *file,
ImlibProgressFunction progress,
char progress_granularity, int *er);
ImlibLoadArgs * ila);
DATA32 *__imlib_AllocateData(ImlibImage * im);
uint32_t *__imlib_AllocateData(ImlibImage * im);
void __imlib_FreeData(ImlibImage * im);
void __imlib_ReplaceData(ImlibImage * im, DATA32 * new_data);
void __imlib_ReplaceData(ImlibImage * im, uint32_t * new_data);
void __imlib_LoadProgressSetPass(ImlibImage * im,
int pass, int n_pass);
@ -136,7 +135,7 @@ int __imlib_CurrentCacheSize(void);
#define LOAD_BADFRAME -4 /* Requested frame not found */
/* 32767 is the maximum pixmap dimension and ensures that
* (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
* (w * h * sizeof(uint32_t)) won't exceed ULONG_MAX */
#define X_MAX_DIM 32767
/* NB! The image dimensions are sometimes used in (dim << 16) like expressions
* so great care must be taken if ever it is attempted to change this

View File

@ -41,18 +41,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
typedef struct _MsChunk {
struct _MsChunk *next;
DATA32 chunk_id;
DATA32 chunk_size; /* Size of this chunk, starting from */
DATA8 data; /* the following byte. Thus chunk_size = full size - 8 */
uint32_t chunk_id;
uint32_t chunk_size; /* Size of this chunk, starting from */
uint8_t data; /* the following byte. Thus chunk_size = full size - 8 */
} MsChunk;
typedef struct _MsAni {
FILE *fp;
DATA32 cp;
uint32_t cp;
DATA32 riff_id; /* "RIFF" */
DATA32 data_size;
DATA32 chunk_id; /* "ACON" */
uint32_t riff_id; /* "RIFF" */
uint32_t data_size;
uint32_t chunk_id; /* "ACON" */
MsChunk *chunks;
} MsAni;
@ -60,7 +60,7 @@ typedef struct _MsAni {
static void ani_cleanup(MsAni * ani);
static int
ani_read_int8(FILE * fp, DATA8 * data, int count)
ani_read_int8(FILE * fp, uint8_t * data, int count)
{
int total;
int bytes;
@ -79,14 +79,14 @@ ani_read_int8(FILE * fp, DATA8 * data, int count)
}
static int
ani_read_int32(FILE * fp, DATA32 * data, int count)
ani_read_int32(FILE * fp, uint32_t * data, int count)
{
int i, total;
total = count;
if (count > 0)
{
ani_read_int8(fp, (DATA8 *) data, count * 4);
ani_read_int8(fp, (uint8_t *) data, count * 4);
for (i = 0; i < count; i++)
data[i] = SWAP_LE_32(data[i]);
}
@ -141,7 +141,7 @@ ani_cleanup(MsAni * ani)
static MsChunk *
ani_load_chunk(MsAni * ani)
{
DATA32 chunk_id, chunk_size, dummy;
uint32_t chunk_id, chunk_size, dummy;
MsChunk *chunk;
if (ani->cp >= ani->data_size + 8)
@ -163,11 +163,11 @@ ani_load_chunk(MsAni * ani)
if (chunk_size % 2)
chunk_size += (2 - (chunk_size % 2));
chunk = calloc(1, sizeof(MsChunk *) + 2 * sizeof(DATA32) + chunk_size);
chunk = calloc(1, sizeof(MsChunk *) + 2 * sizeof(uint32_t) + chunk_size);
if (!chunk)
{
D("Warning, failed to allocate ANI chunk of size %ld\n",
sizeof(MsChunk *) + 2 * sizeof(DATA32) + chunk_size);
sizeof(MsChunk *) + 2 * sizeof(uint32_t) + chunk_size);
return NULL;
}

View File

@ -57,8 +57,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
int w, h, alpha, compression, size;
Eet_File *ef;
char file[4096], key[4096];
DATA32 *ret;
DATA32 *body;
uint32_t *ret;
uint32_t *body;
if (!im->key)
return 0;
@ -78,7 +78,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
}
/* header */
{
DATA32 header[8];
uint32_t header[8];
if (size < 32)
{
@ -123,7 +123,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
}
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
{
DATA32 *ptr;
uint32_t *ptr;
int y, pl = 0;
char pper = 0;
@ -136,7 +136,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
char per;
int l;
ptr = im->data = malloc(w * h * sizeof(DATA32));
ptr = im->data = malloc(w * h * sizeof(uint32_t));
if (!im->data)
{
free(ret);
@ -149,12 +149,12 @@ load(ImlibImage * im, ImlibProgressFunction progress,
{
int x;
memcpy(ptr, &(body[y * w]), im->w * sizeof(DATA32));
memcpy(ptr, &(body[y * w]), im->w * sizeof(uint32_t));
for (x = 0; x < im->w; x++)
SWAP32(ptr[x]);
}
#else
memcpy(ptr, &(body[y * w]), im->w * sizeof(DATA32));
memcpy(ptr, &(body[y * w]), im->w * sizeof(uint32_t));
#endif
ptr += im->w;
@ -176,7 +176,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
}
else
{
ptr = im->data = malloc(w * h * sizeof(DATA32));
ptr = im->data = malloc(w * h * sizeof(uint32_t));
if (!im->data)
{
free(ret);
@ -187,12 +187,12 @@ load(ImlibImage * im, ImlibProgressFunction progress,
{
int x;
memcpy(ptr, body, im->w * im->h * sizeof(DATA32));
memcpy(ptr, body, im->w * im->h * sizeof(uint32_t));
for (x = 0; x < (im->w * im->h); x++)
SWAP32(ptr[x]);
}
#else
memcpy(ptr, body, im->w * im->h * sizeof(DATA32));
memcpy(ptr, body, im->w * im->h * sizeof(uint32_t));
#endif
}
}
@ -200,8 +200,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
{
uLongf dlen;
dlen = w * h * sizeof(DATA32);
im->data = malloc(w * h * sizeof(DATA32));
dlen = w * h * sizeof(uint32_t);
im->data = malloc(w * h * sizeof(uint32_t));
if (!im->data)
{
free(ret);
@ -232,11 +232,11 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
int alpha = 0;
char file[4096], key[4096], *tmp;
DATA32 *header;
DATA32 *buf;
uint32_t *header;
uint32_t *buf;
Eet_File *ef;
int compression = 0, size = 0;
DATA32 *ret;
uint32_t *ret;
/* no image data? abort */
if (!im->data)
@ -267,7 +267,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
return 0;
/* account for space for compression */
buf = malloc((((im->w * im->h * 101) / 100) + 3 + 8) * sizeof(DATA32));
buf = malloc((((im->w * im->h * 101) / 100) + 3 + 8) * sizeof(uint32_t));
header = buf;
header[0] = 0xac1dfeed;
header[1] = im->w;
@ -291,31 +291,32 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
}
if (compression > 0)
{
DATA32 *compressed;
uint32_t *compressed;
int retr;
uLongf buflen;
compressed = &(buf[8]);
buflen = ((im->w * im->h * sizeof(DATA32) * 101) / 100) + 12;
buflen = ((im->w * im->h * sizeof(uint32_t) * 101) / 100) + 12;
#ifdef WORDS_BIGENDIAN
{
int i;
DATA32 *buf2;
uint32_t *buf2;
for (i = 0; i < 8; i++)
SWAP32(header[i]);
buf2 = malloc((((im->w * im->h * 101) / 100) + 3) * sizeof(DATA32));
buf2 =
malloc((((im->w * im->h * 101) / 100) + 3) * sizeof(uint32_t));
if (buf2)
{
int y;
memcpy(buf2, im->data, im->w * im->h * sizeof(DATA32));
memcpy(buf2, im->data, im->w * im->h * sizeof(uint32_t));
for (y = 0; y < (im->w * im->h) + 8; y++)
SWAP32(buf2[y]);
retr = compress2((Bytef *) compressed, &buflen,
(Bytef *) buf2,
(uLong) (im->w * im->h * sizeof(DATA32)),
(uLong) (im->w * im->h * sizeof(uint32_t)),
compression);
free(buf2);
}
@ -325,21 +326,22 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
#else
retr = compress2((Bytef *) compressed, &buflen,
(Bytef *) im->data,
(uLong) (im->w * im->h * sizeof(DATA32)), compression);
(uLong) (im->w * im->h * sizeof(uint32_t)),
compression);
#endif
if (retr != Z_OK)
compressed = 0;
else
{
if (buflen >= (im->w * im->h * sizeof(DATA32)))
if (buflen >= (im->w * im->h * sizeof(uint32_t)))
compressed = 0;
else
size = (8 * sizeof(DATA32)) + buflen;
size = (8 * sizeof(uint32_t)) + buflen;
}
}
else
{
memcpy(&(buf[8]), im->data, im->w * im->h * sizeof(DATA32));
memcpy(&(buf[8]), im->data, im->w * im->h * sizeof(uint32_t));
header[4] = compression;
#ifdef WORDS_BIGENDIAN
{
@ -349,7 +351,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
SWAP32(buf[y]);
}
#endif
size = ((im->w * im->h) + 8) * sizeof(DATA32);
size = ((im->w * im->h) + 8) * sizeof(uint32_t);
}
ret = buf;
eet_write(ef, key, ret, size, 0);

View File

@ -34,7 +34,7 @@
size, likely with smaller ones on the right and bottom edges.
The position of the tiles on the image is left->right, row by row. The
actual DATA8* data is contained in a "level" which is contained in a
actual uint8_t* data is contained in a "level" which is contained in a
"hierarchy". I've not really understood the purpose of the hierarchy, as
it seems to always contain only one level anyway.
@ -189,11 +189,11 @@ struct _Layer {
int num_cols;
/* After the tiles are read in, they're serialized int an array
* of DATA8's, that will always contain 4 bpp data. Not optimal,
* of uint8_t's, that will always contain 4 bpp data. Not optimal,
* I know, but makes life easier
*/
DATA32 *data;
uint32_t *data;
/* Layers are stored as a linked list. */
struct _Layer *next;
@ -212,7 +212,7 @@ struct _Tile {
* This is to handle edge tiles of a drawable.
*/
DATA8 *data;
uint8_t *data;
};
/* This struct simply contains everything that didn't fit elsewhere,
@ -227,10 +227,10 @@ struct _GimpImage {
int width, height; /* width and height attributes */
GimpImageBaseType base_type; /* base gimp_image type */
DATA32 floating_sel_offset;
uint32_t floating_sel_offset;
DATA8 *cmap; /* colormap--for indexed */
DATA32 num_cols; /* number of colors in map */
uint8_t *cmap; /* colormap--for indexed */
uint32_t num_cols; /* number of colors in map */
/* If a layer number was passed to the loader, it goes here: */
int single_layer_index;
@ -238,7 +238,7 @@ struct _GimpImage {
/* Tadaa -- the final image data. Layers get pasted
* onto this one, bottom-up.
*/
DATA32 *data;
uint32_t *data;
Layer *layers;
Layer *last_layer;
@ -283,7 +283,7 @@ init_tile(Tile * tile, int width, int height, int bpp)
tile->bpp = bpp;
tile->ewidth = width;
tile->eheight = height;
tile->data = malloc(sizeof(DATA8) * width * height * bpp);
tile->data = malloc(sizeof(uint8_t) * width * height * bpp);
if (!tile->data)
{
D("Couldn't allocate tile.\n");
@ -401,14 +401,14 @@ static void
set_layer_opacity(Layer * layer)
{
int i;
DATA8 *ptr;
uint8_t *ptr;
if (!layer)
return;
if (layer->opacity != 255)
{
for (i = 0, ptr = (DATA8 *) layer->data;
for (i = 0, ptr = (uint8_t *) layer->data;
i < layer->width * layer->height; i++, ptr += 4)
{
*(ptr + 3) = (*(ptr + 3) * layer->opacity) >> 8;
@ -419,8 +419,8 @@ set_layer_opacity(Layer * layer)
static void
apply_layer_mask(Layer * layer)
{
DATA8 *ptr1;
DATA8 *ptr2;
uint8_t *ptr1;
uint8_t *ptr2;
int i, tmp;
D("Applying layer mask.\n");
@ -431,8 +431,8 @@ apply_layer_mask(Layer * layer)
if (!layer->mask)
return;
ptr1 = (DATA8 *) layer->data;
ptr2 = (DATA8 *) layer->mask->data;
ptr1 = (uint8_t *) layer->data;
ptr2 = (uint8_t *) layer->mask->data;
for (i = 0; i < layer->width * layer->height; i++)
{
@ -440,7 +440,7 @@ apply_layer_mask(Layer * layer)
if (tmp > 255)
tmp = 255;
*(ptr1 + 3) = (DATA8) tmp;
*(ptr1 + 3) = (uint8_t) tmp;
ptr1 += 4;
ptr2 += 4;
}
@ -453,7 +453,7 @@ flatten_image(void)
Layer *lp;
int layer_index;
image->data = calloc(image->width * image->height, sizeof(DATA32));
image->data = calloc(image->width * image->height, sizeof(uint32_t));
layer_index = 0;
while (l)
@ -607,13 +607,13 @@ xcf_seek_pos(int pos)
}
static int
xcf_read_int8(FILE * fp, DATA8 * data, int count)
xcf_read_int8(FILE * fp, uint8_t * data, int count)
{
return fread(data, 1, count, fp);
}
static int
xcf_read_int32(FILE * fp, DATA32 * data, int count)
xcf_read_int32(FILE * fp, uint32_t * data, int count)
{
int i, nr;
@ -622,7 +622,7 @@ xcf_read_int32(FILE * fp, DATA32 * data, int count)
return 0;
for (i = 0; i < count; i++)
{
*data = (DATA32) ntohl(*data);
*data = (uint32_t) ntohl(*data);
data++;
}
@ -632,7 +632,7 @@ xcf_read_int32(FILE * fp, DATA32 * data, int count)
static int
xcf_read_string(FILE * fp, char **data, int count)
{
DATA32 tmp;
uint32_t tmp;
int total;
int i;
@ -642,8 +642,8 @@ xcf_read_string(FILE * fp, char **data, int count)
total += xcf_read_int32(fp, &tmp, 1);
if (tmp > 0)
{
data[i] = malloc(sizeof(DATA8) * tmp);
total += xcf_read_int8(fp, (DATA8 *) data[i], tmp);
data[i] = malloc(sizeof(uint8_t) * tmp);
total += xcf_read_int8(fp, (uint8_t *) data[i], tmp);
}
else
{
@ -655,14 +655,14 @@ xcf_read_string(FILE * fp, char **data, int count)
}
static int
xcf_load_prop(PropType * prop_type, DATA32 * prop_size)
xcf_load_prop(PropType * prop_type, uint32_t * prop_size)
{
int nr;
nr = xcf_read_int32(image->fp, (DATA32 *) prop_type, 1);
nr = xcf_read_int32(image->fp, (uint32_t *) prop_type, 1);
if (nr != 4)
return 0;
nr = xcf_read_int32(image->fp, (DATA32 *) prop_size, 1);
nr = xcf_read_int32(image->fp, (uint32_t *) prop_size, 1);
if (nr != 4)
return 0;
@ -675,8 +675,8 @@ static int
xcf_load_image_props(void)
{
PropType prop_type;
DATA32 prop_size;
DATA8 compression;
uint32_t prop_size;
uint8_t compression;
while (1)
{
@ -699,7 +699,7 @@ xcf_load_image_props(void)
"did not save indexed colormaps correctly.\n"
"Substituting grayscale map.\n");
image->cp += xcf_read_int32(image->fp, &image->num_cols, 1);
image->cmap = malloc(sizeof(DATA8) * image->num_cols * 3);
image->cmap = malloc(sizeof(uint8_t) * image->num_cols * 3);
xcf_seek_pos(image->cp + image->num_cols);
for (i = 0; i < image->num_cols; i++)
{
@ -712,9 +712,9 @@ xcf_load_image_props(void)
{
D("Loading colormap.\n");
image->cp += xcf_read_int32(image->fp, &image->num_cols, 1);
image->cmap = malloc(sizeof(DATA8) * image->num_cols * 3);
image->cmap = malloc(sizeof(uint8_t) * image->num_cols * 3);
image->cp +=
xcf_read_int8(image->fp, (DATA8 *) image->cmap,
xcf_read_int8(image->fp, (uint8_t *) image->cmap,
image->num_cols * 3);
}
break;
@ -751,7 +751,7 @@ xcf_load_image_props(void)
while (prop_size > 0)
{
DATA8 buf[16];
uint8_t buf[16];
int amount;
amount = (16 < prop_size ? 16 : prop_size);
@ -769,7 +769,7 @@ static int
xcf_load_layer_props(Layer * layer)
{
PropType prop_type;
DATA32 prop_size;
uint32_t prop_size;
while (1)
{
@ -786,30 +786,30 @@ xcf_load_layer_props(Layer * layer)
image->floating_sel = layer;
image->cp +=
xcf_read_int32(image->fp,
(DATA32 *) & image->floating_sel_offset, 1);
(uint32_t *) & image->floating_sel_offset, 1);
break;
case PROP_OPACITY:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->opacity, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->opacity, 1);
break;
case PROP_VISIBLE:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->visible, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->visible, 1);
break;
case PROP_PRESERVE_TRANSPARENCY:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->preserve_trans,
xcf_read_int32(image->fp, (uint32_t *) & layer->preserve_trans,
1);
break;
case PROP_OFFSETS:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->offset_x, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->offset_x, 1);
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->offset_y, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->offset_y, 1);
break;
case PROP_MODE:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->mode, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->mode, 1);
break;
/* I threw out all of the following: --cK */
@ -826,7 +826,7 @@ xcf_load_layer_props(Layer * layer)
while (prop_size > 0)
{
DATA8 buf[16];
uint8_t buf[16];
int amount;
amount = (16 < prop_size ? 16 : prop_size);
@ -842,11 +842,11 @@ xcf_load_layer_props(Layer * layer)
static int
read_tiles_into_data(Tile * tiles, int num_cols, int width,
int height, int bpp, DATA32 ** data_p, int use_cmap)
int height, int bpp, uint32_t ** data_p, int use_cmap)
{
int tile_x, tile_y, x, y, offset_x, offset_y;
DATA32 *data;
DATA8 *ptr2;
uint32_t *data;
uint8_t *ptr2;
unsigned char a, r, g, b;
Tile *t;
int warned = 0;
@ -858,7 +858,7 @@ read_tiles_into_data(Tile * tiles, int num_cols, int width,
free(*data_p);
/* Always allocate the data as 4 bytes per pixel */
data = malloc(sizeof(DATA32) * width * height);
data = malloc(sizeof(uint32_t) * width * height);
*data_p = data;
a = r = g = b = 0xff;
@ -957,22 +957,22 @@ xcf_load_tile(Tile * tile)
static int
xcf_load_tile_rle(Tile * tile, int data_length)
{
DATA8 *data;
DATA8 val;
uint8_t *data;
uint8_t val;
int size;
int count;
int length;
int bpp;
int i, j;
int nmemb_read_successfully;
DATA8 *xcfdata, *xcfodata, *xcfdatalimit;
uint8_t *xcfdata, *xcfodata, *xcfdatalimit;
data = tile->data;
bpp = tile->bpp;
/*printf ("Reading encrypted tile %ix%ix%i, data_length %i\n", tile->ewidth, tile->eheight, tile->bpp, data_length); */
xcfdata = xcfodata = malloc(sizeof(DATA8) * data_length);
xcfdata = xcfodata = malloc(sizeof(uint8_t) * data_length);
/* we have to use fread instead of xcf_read_* because we may be
* reading past the end of the file here */
@ -1081,8 +1081,8 @@ static int
xcf_load_level(Tile ** tiles_p, int hierarchy_width, int hierarchy_height,
int bpp, int *num_rows, int *num_cols)
{
DATA32 saved_pos;
DATA32 offset, offset2;
uint32_t saved_pos;
uint32_t offset, offset2;
int ntiles;
int width;
int height;
@ -1092,8 +1092,8 @@ xcf_load_level(Tile ** tiles_p, int hierarchy_width, int hierarchy_height,
Tile *tiles;
Tile *current_tile;
image->cp += xcf_read_int32(image->fp, (DATA32 *) & width, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & height, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & width, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & height, 1);
if ((width != hierarchy_width) || (height != hierarchy_height))
return 0;
@ -1186,15 +1186,15 @@ xcf_load_level(Tile ** tiles_p, int hierarchy_width, int hierarchy_height,
static int
xcf_load_hierarchy(Tile ** tiles, int *num_rows, int *num_cols, int *bpp)
{
DATA32 saved_pos;
DATA32 offset;
DATA32 junk;
uint32_t saved_pos;
uint32_t offset;
uint32_t junk;
int width;
int height;
image->cp += xcf_read_int32(image->fp, (DATA32 *) & width, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & height, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) bpp, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & width, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & height, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) bpp, 1);
image->cp += xcf_read_int32(image->fp, &offset, 1); /* top level */
@ -1234,7 +1234,7 @@ static int
xcf_load_channel_props(Layer * layer)
{
PropType prop_type;
DATA32 prop_size;
uint32_t prop_size;
while (1)
{
@ -1248,11 +1248,11 @@ xcf_load_channel_props(Layer * layer)
return 1;
case PROP_OPACITY:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->opacity, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->opacity, 1);
break;
case PROP_VISIBLE:
image->cp +=
xcf_read_int32(image->fp, (DATA32 *) & layer->visible, 1);
xcf_read_int32(image->fp, (uint32_t *) & layer->visible, 1);
break;
case PROP_ACTIVE_CHANNEL:
case PROP_SHOW_MASKED:
@ -1266,7 +1266,7 @@ xcf_load_channel_props(Layer * layer)
while (prop_size > 0)
{
DATA8 buf[16];
uint8_t buf[16];
int amount;
amount = (16 < prop_size ? 16 : prop_size);
@ -1284,15 +1284,15 @@ static Layer *
xcf_load_channel(void)
{
Layer *layer;
DATA32 hierarchy_offset;
uint32_t hierarchy_offset;
int err, width, height;
char *name;
D("Loading channel ...\n");
/* read in the layer width, height and name */
image->cp += xcf_read_int32(image->fp, (DATA32 *) & width, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & height, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & width, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & height, 1);
image->cp += xcf_read_string(image->fp, &name, 1);
/* Yeah, still ugly :) */
@ -1337,17 +1337,17 @@ xcf_load_layer(void)
{
Layer *layer;
Layer *layer_mask;
DATA32 hierarchy_offset;
DATA32 layer_mask_offset;
uint32_t hierarchy_offset;
uint32_t layer_mask_offset;
int err, width, height, type;
char *name;
D("Loading one layer ...\n");
/* read in the layer width, height and type */
image->cp += xcf_read_int32(image->fp, (DATA32 *) & width, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & height, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & type, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & width, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & height, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & type, 1);
image->cp += xcf_read_string(image->fp, &name, 1);
/* ugly, I know */
@ -1417,17 +1417,17 @@ static int
xcf_load_image(void)
{
Layer *layer;
DATA32 saved_pos;
DATA32 offset;
uint32_t saved_pos;
uint32_t offset;
int width;
int height;
int image_type;
int num_successful_elements = 0;
/* read in the image width, height and type */
image->cp += xcf_read_int32(image->fp, (DATA32 *) & width, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & height, 1);
image->cp += xcf_read_int32(image->fp, (DATA32 *) & image_type, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & width, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & height, 1);
image->cp += xcf_read_int32(image->fp, (uint32_t *) & image_type, 1);
image->width = width;
image->height = height;
@ -1525,7 +1525,7 @@ xcf_file_init(FILE * fp)
image->cp = 0;
memset(id, 0, sizeof(id));
image->cp += xcf_read_int8(image->fp, (DATA8 *) id, 14);
image->cp += xcf_read_int8(image->fp, (uint8_t *) id, 14);
if (strncmp(id, "gimp xcf ", 9) != 0)
{
success = 0;

View File

@ -2,50 +2,55 @@
#define LOADER_XCF_H
/* Stuff for layer merging: */
extern void combine_pixels_normal(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_add(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_sub(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_diff(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
extern void combine_pixels_normal(const uint32_t * src, int src_w,
int src_h, uint32_t * dest,
int dest_w, int dest_h, int dest_x,
int dest_y);
extern void combine_pixels_add(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_sub(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_diff(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_darken(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_lighten(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_mult(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
extern void combine_pixels_darken(const uint32_t * src, int src_w,
int src_h, uint32_t * dest,
int dest_w, int dest_h, int dest_x,
int dest_y);
extern void combine_pixels_lighten(const uint32_t * src, int src_w,
int src_h, uint32_t * dest,
int dest_w, int dest_h, int dest_x,
int dest_y);
extern void combine_pixels_mult(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_div(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_screen(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_overlay(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_hue(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_sat(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_val(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_col(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
int dest_x, int dest_y);
extern void combine_pixels_diss(const DATA32 * src, int src_w,
int src_h, DATA32 * dest, int dest_w,
extern void combine_pixels_div(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_screen(const uint32_t * src, int src_w,
int src_h, uint32_t * dest,
int dest_w, int dest_h, int dest_x,
int dest_y);
extern void combine_pixels_overlay(const uint32_t * src, int src_w,
int src_h, uint32_t * dest,
int dest_w, int dest_h, int dest_x,
int dest_y);
extern void combine_pixels_hue(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_sat(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_val(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_col(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
extern void combine_pixels_diss(const uint32_t * src, int src_w,
int src_h, uint32_t * dest, int dest_w,
int dest_h, int dest_x, int dest_y);
#endif /* LOADER_XCF_H */

View File

@ -32,17 +32,17 @@
#ifndef WORDS_BIGENDIAN
#define A_VAL(p) ((DATA8 *)(p))[3]
#define R_VAL(p) ((DATA8 *)(p))[2]
#define G_VAL(p) ((DATA8 *)(p))[1]
#define B_VAL(p) ((DATA8 *)(p))[0]
#define A_VAL(p) ((uint8_t *)(p))[3]
#define R_VAL(p) ((uint8_t *)(p))[2]
#define G_VAL(p) ((uint8_t *)(p))[1]
#define B_VAL(p) ((uint8_t *)(p))[0]
#else
#define A_VAL(p) ((DATA8 *)(p))[0]
#define R_VAL(p) ((DATA8 *)(p))[1]
#define G_VAL(p) ((DATA8 *)(p))[2]
#define B_VAL(p) ((DATA8 *)(p))[3]
#define A_VAL(p) ((uint8_t *)(p))[0]
#define R_VAL(p) ((uint8_t *)(p))[1]
#define G_VAL(p) ((uint8_t *)(p))[2]
#define B_VAL(p) ((uint8_t *)(p))[3]
#endif
@ -70,7 +70,7 @@
#define LINEAR(x,y,w) ((w*y + x)*4)
static void
rgb_to_hls(DATA8 * red, DATA8 * green, DATA8 * blue)
rgb_to_hls(uint8_t * red, uint8_t * green, uint8_t * blue)
{
int r, g, b;
double h, l, s;
@ -128,7 +128,7 @@ rgb_to_hls(DATA8 * red, DATA8 * green, DATA8 * blue)
*blue = s;
}
static DATA8
static uint8_t
gimp_hls_value(double n1, double n2, double hue)
{
double value;
@ -146,11 +146,11 @@ gimp_hls_value(double n1, double n2, double hue)
else
value = n1;
return (DATA8) (value * 255);
return (uint8_t) (value * 255);
}
static void
hls_to_rgb(DATA8 * hue, DATA8 * lightness, DATA8 * saturation)
hls_to_rgb(uint8_t * hue, uint8_t * lightness, uint8_t * saturation)
{
double h, l, s;
double m1, m2;
@ -183,7 +183,7 @@ hls_to_rgb(DATA8 * hue, DATA8 * lightness, DATA8 * saturation)
}
static void
rgb_to_hsv(DATA8 * red, DATA8 * green, DATA8 * blue)
rgb_to_hsv(uint8_t * red, uint8_t * green, uint8_t * blue)
{
int r, g, b;
double h, s, v;
@ -239,7 +239,7 @@ rgb_to_hsv(DATA8 * red, DATA8 * green, DATA8 * blue)
}
static void
hsv_to_rgb(DATA8 * hue, DATA8 * saturation, DATA8 * value)
hsv_to_rgb(uint8_t * hue, uint8_t * saturation, uint8_t * value)
{
double h, s, v;
double f, p, q, t;
@ -331,12 +331,12 @@ _clip(int *src_tl_x, int *src_tl_y,
}
void
combine_pixels_normal(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_normal(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -389,12 +389,12 @@ combine_pixels_normal(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_add(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_add(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -424,12 +424,12 @@ combine_pixels_add(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_sub(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_sub(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -459,12 +459,12 @@ combine_pixels_sub(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_diff(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_diff(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -494,12 +494,12 @@ combine_pixels_diff(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_darken(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_darken(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -523,12 +523,12 @@ combine_pixels_darken(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_lighten(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_lighten(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -552,12 +552,12 @@ combine_pixels_lighten(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_mult(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_mult(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -585,12 +585,12 @@ combine_pixels_mult(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_div(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_div(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -617,12 +617,12 @@ combine_pixels_div(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_screen(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_screen(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -646,12 +646,12 @@ combine_pixels_screen(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_overlay(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_overlay(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -684,12 +684,12 @@ combine_pixels_overlay(const DATA32 * src_, int src_w, int src_h,
}
static void
combine_pixels_hsv(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_hsv(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y, int mode)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -728,8 +728,8 @@ combine_pixels_hsv(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_hue(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
combine_pixels_hue(const uint32_t * src, int src_w, int src_h,
uint32_t * dest, int dest_w, int dest_h,
int dest_x, int dest_y)
{
combine_pixels_hsv(src, src_w, src_h, dest, dest_w, dest_h,
@ -737,8 +737,8 @@ combine_pixels_hue(const DATA32 * src, int src_w, int src_h,
}
void
combine_pixels_sat(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
combine_pixels_sat(const uint32_t * src, int src_w, int src_h,
uint32_t * dest, int dest_w, int dest_h,
int dest_x, int dest_y)
{
combine_pixels_hsv(src, src_w, src_h, dest, dest_w, dest_h,
@ -746,8 +746,8 @@ combine_pixels_sat(const DATA32 * src, int src_w, int src_h,
}
void
combine_pixels_val(const DATA32 * src, int src_w, int src_h,
DATA32 * dest, int dest_w, int dest_h,
combine_pixels_val(const uint32_t * src, int src_w, int src_h,
uint32_t * dest, int dest_w, int dest_h,
int dest_x, int dest_y)
{
combine_pixels_hsv(src, src_w, src_h, dest, dest_w, dest_h,
@ -755,12 +755,12 @@ combine_pixels_val(const DATA32 * src, int src_w, int src_h,
}
void
combine_pixels_col(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_col(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;
@ -786,12 +786,12 @@ combine_pixels_col(const DATA32 * src_, int src_w, int src_h,
}
void
combine_pixels_diss(const DATA32 * src_, int src_w, int src_h,
DATA32 * dst_, int dest_w, int dest_h,
combine_pixels_diss(const uint32_t * src_, int src_w, int src_h,
uint32_t * dst_, int dest_w, int dest_h,
int dest_x, int dest_y)
{
const DATA8 *src = (const DATA8 *)src_;
DATA8 *dest = (DATA8 *) dst_;
const uint8_t *src = (const uint8_t *)src_;
uint8_t *dest = (uint8_t *) dst_;
int x, y, s_idx, d_idx;
int src_tl_x = 0, src_tl_y = 0;
int src_br_x = src_w, src_br_y = src_h;

View File

@ -1,11 +1,7 @@
#ifndef TYPES_H
#define TYPES_H 1
#define DATABIG unsigned long long
#define DATA64 unsigned long long
#define DATA32 unsigned int
#define DATA16 unsigned short
#define DATA8 unsigned char
#include <stdint.h>
typedef struct _ImlibLoader ImlibLoader;