IMG_xcf.c
changeset 343 5bf0f0d6a74e
parent 320 aa5d55b11751
child 347 ad5034cad524
     1.1 --- a/IMG_xcf.c	Sun Jan 27 15:55:03 2013 -0800
     1.2 +++ b/IMG_xcf.c	Sun Feb 03 08:37:28 2013 -0800
     1.3 @@ -208,7 +208,7 @@
     1.4  /* See if an image is contained in a data source */
     1.5  int IMG_isXCF(SDL_RWops *src)
     1.6  {
     1.7 -	int start;
     1.8 +	Sint64 start;
     1.9  	int is_XCF;
    1.10  	char magic[14];
    1.11  
    1.12 @@ -217,7 +217,7 @@
    1.13  	start = SDL_RWtell(src);
    1.14  	is_XCF = 0;
    1.15  	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
    1.16 -		if (strncmp(magic, "gimp xcf ", 9) == 0) {
    1.17 +		if (SDL_strncmp(magic, "gimp xcf ", 9) == 0) {
    1.18  			is_XCF = 1;
    1.19  		}
    1.20  	}
    1.21 @@ -311,12 +311,12 @@
    1.22    do {
    1.23      xcf_read_property (src, &prop);
    1.24      if (prop.id == PROP_COMPRESSION)
    1.25 -      h->compr = prop.data.compression;
    1.26 +      h->compr = (xcf_compr_type)prop.data.compression;
    1.27      else if (prop.id == PROP_COLORMAP) {
    1.28        // unused var: int i;
    1.29  
    1.30        h->cm_num = prop.data.colormap.num;
    1.31 -      h->cm_map = (unsigned char *) malloc (sizeof (unsigned char) * 3 * h->cm_num);
    1.32 +      h->cm_map = (unsigned char *) SDL_malloc (sizeof (unsigned char) * 3 * h->cm_num);
    1.33        memcpy (h->cm_map, prop.data.colormap.cmap, 3*sizeof (char)*h->cm_num);
    1.34        free (prop.data.colormap.cmap);
    1.35      }
    1.36 @@ -366,7 +366,7 @@
    1.37    xcf_channel * l;
    1.38    xcf_prop    prop;
    1.39  
    1.40 -  l = (xcf_channel *) malloc (sizeof (xcf_channel));
    1.41 +  l = (xcf_channel *) SDL_malloc (sizeof (xcf_channel));
    1.42    l->width  = SDL_ReadBE32 (src);
    1.43    l->height = SDL_ReadBE32 (src);
    1.44  
    1.45 @@ -433,14 +433,14 @@
    1.46    xcf_level * l;
    1.47    int i;
    1.48  
    1.49 -  l = (xcf_level *) malloc (sizeof (xcf_level));
    1.50 +  l = (xcf_level *) SDL_malloc (sizeof (xcf_level));
    1.51    l->width  = SDL_ReadBE32 (src);
    1.52    l->height = SDL_ReadBE32 (src);
    1.53  
    1.54    l->tile_file_offsets = NULL;
    1.55    i = 0;
    1.56    do {
    1.57 -    l->tile_file_offsets = (Uint32 *) realloc (l->tile_file_offsets, sizeof (Uint32) * (i+1));
    1.58 +    l->tile_file_offsets = (Uint32 *) SDL_realloc (l->tile_file_offsets, sizeof (Uint32) * (i+1));
    1.59      l->tile_file_offsets [i] = SDL_ReadBE32 (src);
    1.60    } while (l->tile_file_offsets [i++]);
    1.61  
    1.62 @@ -454,7 +454,7 @@
    1.63  static unsigned char * load_xcf_tile_none (SDL_RWops * src, Uint32 len, int bpp, int x, int y) {
    1.64    unsigned char * load;
    1.65  
    1.66 -  load = (unsigned char *) malloc (len); // expect this is okay
    1.67 +  load = (unsigned char *) SDL_malloc (len); // expect this is okay
    1.68    SDL_RWread (src, load, len, 1);
    1.69  
    1.70    return load;
    1.71 @@ -466,7 +466,7 @@
    1.72    int i, size, count, j, length;
    1.73    unsigned char val;
    1.74  
    1.75 -  t = load = (unsigned char *) malloc (len);
    1.76 +  t = load = (unsigned char *) SDL_malloc (len);
    1.77    reallen = SDL_RWread (src, t, 1, len);
    1.78  
    1.79    data = (unsigned char *) malloc (x*y*bpp);
    1.80 @@ -514,15 +514,15 @@
    1.81      }
    1.82    }
    1.83  
    1.84 -  free (load);
    1.85 +  SDL_free (load);
    1.86    return (data);
    1.87  }
    1.88  
    1.89  static Uint32 rgb2grey (Uint32 a) {
    1.90    Uint8 l;
    1.91 -  l = 0.2990 * ((a && 0x00FF0000) >> 16)
    1.92 +  l = (Uint8)(0.2990 * ((a && 0x00FF0000) >> 16)
    1.93      + 0.5870 * ((a && 0x0000FF00) >>  8)
    1.94 -    + 0.1140 * ((a && 0x000000FF));
    1.95 +    + 0.1140 * ((a && 0x000000FF)));
    1.96  
    1.97    return (l << 16) | (l << 8) | l;
    1.98  }
    1.99 @@ -549,7 +549,8 @@
   1.100    Uint8  * p8;
   1.101    Uint16 * p16;
   1.102    Uint32 * p;
   1.103 -  int x, y, tx, ty, ox, oy, i, j;
   1.104 +  int i, j;
   1.105 +  Uint32 x, y, tx, ty, ox, oy;
   1.106    Uint32 *row;
   1.107  
   1.108    SDL_RWseek (src, layer->hierarchy_file_offset, RW_SEEK_SET);
   1.109 @@ -673,14 +674,14 @@
   1.110  
   1.111  SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
   1.112  {
   1.113 -  int start;
   1.114 +  Sint64 start;
   1.115    const char *error = NULL;
   1.116    SDL_Surface *surface, *lays;
   1.117    xcf_header * head;
   1.118    xcf_layer  * layer;
   1.119    xcf_channel ** channel;
   1.120    int chnls, i, offsets;
   1.121 -  Uint32 offset, fp;
   1.122 +  Sint64 offset, fp;
   1.123  
   1.124    unsigned char * (* load_tile) (SDL_RWops *, Uint32, int, int, int);
   1.125  
   1.126 @@ -722,7 +723,7 @@
   1.127  
   1.128    while ((offset = SDL_ReadBE32 (src))) {
   1.129      head->layer_file_offsets = (Uint32 *) realloc (head->layer_file_offsets, sizeof (Uint32) * (offsets+1));
   1.130 -    head->layer_file_offsets [offsets] = offset;
   1.131 +    head->layer_file_offsets [offsets] = (Uint32)offset;
   1.132      offsets++;
   1.133    }
   1.134    fp = SDL_RWtell (src);
   1.135 @@ -764,7 +765,7 @@
   1.136    channel = NULL;
   1.137    chnls   = 0;
   1.138    while ((offset = SDL_ReadBE32 (src))) {
   1.139 -    channel = (xcf_channel **) realloc (channel, sizeof (xcf_channel *) * (chnls+1));
   1.140 +    channel = (xcf_channel **) SDL_realloc (channel, sizeof (xcf_channel *) * (chnls+1));
   1.141      fp = SDL_RWtell (src);
   1.142      SDL_RWseek (src, offset, RW_SEEK_SET);
   1.143      channel [chnls++] = (read_xcf_channel (src));
   1.144 @@ -784,7 +785,7 @@
   1.145      for (i = 0; i < chnls; i++) {
   1.146        //      printf ("CNLBLT %i\n", i);
   1.147        if (!channel [i]->selection && channel [i]->visible) {
   1.148 -	create_channel_surface (chs, head->image_type, channel [i]->color, channel [i]->opacity);
   1.149 +	create_channel_surface (chs, (xcf_image_type)head->image_type, channel [i]->color, channel [i]->opacity);
   1.150  	SDL_BlitSurface (chs, NULL, surface, NULL);
   1.151        }
   1.152        free_xcf_channel (channel [i]);