Date: 02 May 2002 04:11:26 +0200
authorSam Lantinga <slouken@libsdl.org>
Fri, 03 May 2002 02:10:44 +0000
changeset 70ef5fe56a0f07
parent 69 bfbf2f92c0d6
child 71 e2eb6980be07
Date: 02 May 2002 04:11:26 +0200
From: Dag-Erling Smorgrav <des@ofug.org>
Subject: SDL_image XCF patch

The attached patch makes the XCF code ignore invisible layers and
channels, and disables the debugging printouts. This makes the XCF
loader quite usable; I think it should be enabled by default.
CHANGES
IMG_xcf.c
     1.1 --- a/CHANGES	Sun Apr 14 21:57:25 2002 +0000
     1.2 +++ b/CHANGES	Fri May 03 02:10:44 2002 +0000
     1.3 @@ -1,3 +1,7 @@
     1.4 +
     1.5 +1.2.3:
     1.6 +Dag-Erling Smorgrav - Thu May  2 19:09:48 PDT 2002
     1.7 + * The XCF loader now ignores invisible layers and channels
     1.8  
     1.9  1.2.2:
    1.10  Sam Lantinga - Sat Apr 13 07:49:47 PDT 2002
     2.1 --- a/IMG_xcf.c	Sun Apr 14 21:57:25 2002 +0000
     2.2 +++ b/IMG_xcf.c	Fri May 03 02:10:44 2002 +0000
     2.3 @@ -166,6 +166,7 @@
     2.4  
     2.5    Uint32 offset_x;
     2.6    Uint32 offset_y;
     2.7 +  int visible;
     2.8  } xcf_layer;
     2.9  
    2.10  typedef struct {
    2.11 @@ -178,7 +179,8 @@
    2.12  
    2.13    Uint32 color;
    2.14    Uint32 opacity;
    2.15 -  int selection : 1;
    2.16 +  int selection;
    2.17 +  int visible;
    2.18  } xcf_channel;
    2.19  
    2.20  typedef struct {
    2.21 @@ -245,7 +247,9 @@
    2.22    prop->id = SDL_ReadBE32 (src);
    2.23    prop->length = SDL_ReadBE32 (src);
    2.24  
    2.25 +#if 0
    2.26    printf ("%.8X: %s: %d\n", SDL_RWtell (src), prop->id < 25 ? prop_names [prop->id] : "unknown", prop->length);
    2.27 +#endif
    2.28  
    2.29    switch (prop->id) {
    2.30    case PROP_COLORMAP:
    2.31 @@ -265,6 +269,9 @@
    2.32    case PROP_COLOR:
    2.33      SDL_RWread (src, &prop->data, prop->length, 1);
    2.34      break;
    2.35 +  case PROP_VISIBLE:
    2.36 +    prop->data.visible = SDL_ReadBE32 (src);
    2.37 +    break;
    2.38    default:
    2.39      //    SDL_RWread (src, &prop->data, prop->length, 1);
    2.40      SDL_RWseek (src, prop->length, SEEK_CUR);
    2.41 @@ -332,6 +339,8 @@
    2.42      if (prop.id == PROP_OFFSETS) {
    2.43        l->offset_x = prop.data.offset.x;
    2.44        l->offset_y = prop.data.offset.y;
    2.45 +    } else if (prop.id == PROP_VISIBLE) {
    2.46 +      l->visible = prop.data.visible ? 1 : 0;
    2.47      }
    2.48    } while (prop.id != PROP_END);
    2.49  
    2.50 @@ -371,6 +380,9 @@
    2.51      case PROP_SELECTION:
    2.52        l->selection = 1;
    2.53        break;
    2.54 +    case PROP_VISIBLE:
    2.55 +      l->visible = prop.data.visible ? 1 : 0;
    2.56 +      break;
    2.57      default:
    2.58      }
    2.59    } while (prop.id != PROP_END);
    2.60 @@ -724,9 +736,10 @@
    2.61      rd.y = layer->offset_y;
    2.62      rd.w = layer->width;
    2.63      rd.h = layer->height;
    2.64 +
    2.65 +    if (layer->visible)
    2.66 +      SDL_BlitSurface (lays, &rs, surface, &rd);
    2.67      free_xcf_layer (layer);
    2.68 -
    2.69 -    SDL_BlitSurface (lays, &rs, surface, &rd);
    2.70    }
    2.71  
    2.72    SDL_FreeSurface (lays);
    2.73 @@ -756,7 +769,7 @@
    2.74      }
    2.75      for (i = 0; i < chnls; i++) {
    2.76        //      printf ("CNLBLT %i\n", i);
    2.77 -      if (!channel [i]->selection) {
    2.78 +      if (!channel [i]->selection && channel [i]->visible) {
    2.79  	create_channel_surface (chs, head->image_type, channel [i]->color, channel [i]->opacity);
    2.80  	SDL_BlitSurface (chs, NULL, surface, NULL);
    2.81        }