--- IMG_xcf.c.orig	Mon Apr 29 03:01:48 2002
+++ IMG_xcf.c	Mon Apr 29 03:17:07 2002
@@ -166,6 +166,7 @@
 
   Uint32 offset_x;
   Uint32 offset_y;
+  int visible : 1;
 } xcf_layer;
 
 typedef struct {
@@ -179,6 +180,7 @@
   Uint32 color;
   Uint32 opacity;
   int selection : 1;
+  int visible : 1;
 } xcf_channel;
 
 typedef struct {
@@ -245,7 +247,9 @@
   prop->id = SDL_ReadBE32 (src);
   prop->length = SDL_ReadBE32 (src);
 
+#if 0
   printf ("%.8X: %s: %d\n", SDL_RWtell (src), prop->id < 25 ? prop_names [prop->id] : "unknown", prop->length);
+#endif
 
   switch (prop->id) {
   case PROP_COLORMAP:
@@ -265,6 +269,9 @@
   case PROP_COLOR:
     SDL_RWread (src, &prop->data, prop->length, 1);
     break;
+  case PROP_VISIBLE:
+    prop->data.visible = SDL_ReadBE32 (src);
+    break;
   default:
     //    SDL_RWread (src, &prop->data, prop->length, 1);
     SDL_RWseek (src, prop->length, SEEK_CUR);
@@ -332,6 +339,8 @@
     if (prop.id == PROP_OFFSETS) {
       l->offset_x = prop.data.offset.x;
       l->offset_y = prop.data.offset.y;
+    } else if (prop.id == PROP_VISIBLE) {
+      l->visible = prop.data.visible ? 1 : 0;
     }
   } while (prop.id != PROP_END);
 
@@ -371,6 +380,9 @@
     case PROP_SELECTION:
       l->selection = 1;
       break;
+    case PROP_VISIBLE:
+      l->visible = prop.data.visible ? 1 : 0;
+      break;
     default:
     }
   } while (prop.id != PROP_END);
@@ -724,9 +736,10 @@
     rd.y = layer->offset_y;
     rd.w = layer->width;
     rd.h = layer->height;
-    free_xcf_layer (layer);
 
-    SDL_BlitSurface (lays, &rs, surface, &rd);
+    if (layer->visible)
+      SDL_BlitSurface (lays, &rs, surface, &rd);
+    free_xcf_layer (layer);
   }
 
   SDL_FreeSurface (lays);
@@ -756,7 +769,7 @@
     }
     for (i = 0; i < chnls; i++) {
       //      printf ("CNLBLT %i\n", i);
-      if (!channel [i]->selection) {
+      if (!channel [i]->selection && channel [i]->visible) {
 	create_channel_surface (chs, head->image_type, channel [i]->color, channel [i]->opacity);
 	SDL_BlitSurface (chs, NULL, surface, NULL);
       }
