summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gimp/xcf-private.h75
-rw-r--r--options.i9
-rw-r--r--xcf-general.c24
-rw-r--r--xcfinfo.c30
-rw-r--r--xcftools.h3
5 files changed, 106 insertions, 35 deletions
diff --git a/gimp/xcf-private.h b/gimp/xcf-private.h
index 0a5749f..33076d4 100644
--- a/gimp/xcf-private.h
+++ b/gimp/xcf-private.h
@@ -1,9 +1,9 @@
-/* The GIMP -- an image manipulation program
+/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
- * This program is free software; you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -12,8 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __XCF_PRIVATE_H__
@@ -22,33 +21,38 @@
typedef enum
{
- PROP_END = 0,
- PROP_COLORMAP = 1,
- PROP_ACTIVE_LAYER = 2,
- PROP_ACTIVE_CHANNEL = 3,
- PROP_SELECTION = 4,
- PROP_FLOATING_SELECTION = 5,
- PROP_OPACITY = 6,
- PROP_MODE = 7,
- PROP_VISIBLE = 8,
- PROP_LINKED = 9,
- PROP_PRESERVE_TRANSPARENCY = 10,
- PROP_APPLY_MASK = 11,
- PROP_EDIT_MASK = 12,
- PROP_SHOW_MASK = 13,
- PROP_SHOW_MASKED = 14,
- PROP_OFFSETS = 15,
- PROP_COLOR = 16,
- PROP_COMPRESSION = 17,
- PROP_GUIDES = 18,
- PROP_RESOLUTION = 19,
- PROP_TATTOO = 20,
- PROP_PARASITES = 21,
- PROP_UNIT = 22,
- PROP_PATHS = 23,
- PROP_USER_UNIT = 24,
- PROP_VECTORS = 25,
- PROP_TEXT_LAYER_FLAGS = 26
+ PROP_END = 0,
+ PROP_COLORMAP = 1,
+ PROP_ACTIVE_LAYER = 2,
+ PROP_ACTIVE_CHANNEL = 3,
+ PROP_SELECTION = 4,
+ PROP_FLOATING_SELECTION = 5,
+ PROP_OPACITY = 6,
+ PROP_MODE = 7,
+ PROP_VISIBLE = 8,
+ PROP_LINKED = 9,
+ PROP_LOCK_ALPHA = 10,
+ PROP_APPLY_MASK = 11,
+ PROP_EDIT_MASK = 12,
+ PROP_SHOW_MASK = 13,
+ PROP_SHOW_MASKED = 14,
+ PROP_OFFSETS = 15,
+ PROP_COLOR = 16,
+ PROP_COMPRESSION = 17,
+ PROP_GUIDES = 18,
+ PROP_RESOLUTION = 19,
+ PROP_TATTOO = 20,
+ PROP_PARASITES = 21,
+ PROP_UNIT = 22,
+ PROP_PATHS = 23,
+ PROP_USER_UNIT = 24,
+ PROP_VECTORS = 25,
+ PROP_TEXT_LAYER_FLAGS = 26,
+ PROP_SAMPLE_POINTS = 27,
+ PROP_LOCK_CONTENT = 28,
+ PROP_GROUP_ITEM = 29,
+ PROP_ITEM_PATH = 30,
+ PROP_GROUP_ITEM_FLAGS = 31
} PropType;
typedef enum
@@ -71,10 +75,17 @@ typedef enum
XCF_STROKETYPE_BEZIER_STROKE = 1
} XcfStrokeType;
+typedef enum
+{
+ XCF_GROUP_ITEM_EXPANDED = 1
+} XcfGroupItemFlagsType;
+
typedef struct _XcfInfo XcfInfo;
struct _XcfInfo
{
+ Gimp *gimp;
+ GimpProgress *progress;
FILE *fp;
guint cp;
const gchar *filename;
diff --git a/options.i b/options.i
index 56bb014..05e18ad 100644
--- a/options.i
+++ b/options.i
@@ -47,6 +47,15 @@ OPTION('j',--bzip,input is bzip2 compressed,
));
unzipper = "bzcat" ;
break ;
+
+#ifdef XCFINFO
+OPTION('p',--path-separator, (string) use 'string' to separate the groups in the paths,
+ (This string will be used to separate the name of the containing groups
+ when manipulating layers.
+ ));
+pathSeparator = optarg ;
+break ;
+#endif
OPTION('z',--gzip,input is gzip compressed,
(Equivalent to
diff --git a/xcf-general.c b/xcf-general.c
index 9d0b4dc..b23c260 100644
--- a/xcf-general.c
+++ b/xcf-general.c
@@ -196,7 +196,7 @@ getBasicXcfInfo(void)
{
uint32_t ptr, data, layerfile ;
PropType type ;
- int i ;
+ int i, j ;
xcfCheckspace(0,14+7*4,"(very short)");
if( strcmp((char*)xcf_file,"gimp xcf file") == 0 )
@@ -207,7 +207,7 @@ getBasicXcfInfo(void)
else
FatalBadXCF(_("Not an XCF file at all (magic not recognized)"));
- if( XCF.version < 0 || XCF.version > 2 ) {
+ if( XCF.version < 0 || XCF.version > 3 ) {
fprintf(stderr,
_("Warning: XCF version %d not supported (trying anyway...)\n"),
XCF.version);
@@ -241,6 +241,7 @@ getBasicXcfInfo(void)
for( i = 0 ; i < XCF.numLayers ; i++ ) {
struct xcfLayer *L = XCF.layers + i ;
ptr = xcfL(layerfile+4*(XCF.numLayers-1-i)) ;
+
L->mode = GIMP_NORMAL_MODE ;
L->opacity = 255 ;
L->isVisible = 1 ;
@@ -250,6 +251,11 @@ getBasicXcfInfo(void)
L->type = xcfL(ptr); ptr+=4 ;
L->name = xcfString(ptr,&ptr);
L->propptr = ptr ;
+
+ L->isGroup = 0;
+ L->pathLength = 0;
+ L->path = NULL;
+
while( (type = xcfNextprop(&ptr,&data)) != PROP_END ) {
switch(type) {
case PROP_OPACITY:
@@ -270,6 +276,20 @@ getBasicXcfInfo(void)
case PROP_MODE:
L->mode = xcfL(data);
break ;
+ case PROP_GROUP_ITEM:
+ L->isGroup = 1 ;
+ break;
+ case PROP_ITEM_PATH:
+ L->pathLength = (ptr - data - 2) / 4 ;
+
+ if ( L->pathLength != 0 ) {
+
+ L->path = xcfmalloc( L->pathLength * sizeof(unsigned) ) ;
+
+ for ( j = 0; j!=L->pathLength; j++ )
+ *(L->path + j) = (unsigned)xcfL(data + 4 * j);
+ }
+ break;
default:
/* Ignore unknown properties */
break ;
diff --git a/xcfinfo.c b/xcfinfo.c
index 7054fb5..21f4f93 100644
--- a/xcfinfo.c
+++ b/xcfinfo.c
@@ -42,6 +42,23 @@ usage(FILE *where)
}
}
+static void
+printLayerPath
+( unsigned layerIndex, const char* pathSeparator )
+{
+ int depth = XCF.layers[layerIndex].pathLength ;
+ int i = layerIndex;
+
+ if ( depth != 0 ) {
+ do {
+ i++;
+ } while ( XCF.layers[i].pathLength != depth - 1 );
+
+ printLayerPath( i, pathSeparator ) ;
+ printf( "%s%s", pathSeparator, XCF.layers[i].name );
+ }
+}
+
int
main(int argc,char **argv)
{
@@ -49,6 +66,7 @@ main(int argc,char **argv)
int option ;
const char *unzipper = NULL ;
const char *infile = NULL ;
+ const char *pathSeparator = "|";
setlocale(LC_ALL,"");
progname = argv[0] ;
@@ -95,7 +113,17 @@ main(int argc,char **argv)
printf("/%02d%%",XCF.layers[i].opacity * 100 / 255);
if( XCF.layers[i].hasMask )
printf(_("/mask"));
- printf(" %s\n",XCF.layers[i].name);
+ if( XCF.layers[i].isGroup )
+ printf(_("/group"));
+
+ printf( " " );
+
+ if ( XCF.version > 2 ) {
+ printLayerPath( i, pathSeparator );
+ printf( "%s", pathSeparator );
+ }
+
+ printf("%s\n",XCF.layers[i].name);
}
return 0 ;
diff --git a/xcftools.h b/xcftools.h
index e05637a..5a1efcc 100644
--- a/xcftools.h
+++ b/xcftools.h
@@ -181,6 +181,9 @@ struct xcfLayer {
uint32_t propptr ;
struct xcfTiles pixels ;
struct xcfTiles mask ;
+ int isGroup ;
+ unsigned pathLength ;
+ unsigned *path ;
};
extern struct xcfImage {