summaryrefslogtreecommitdiffstats
path: root/xcf-general.c
diff options
context:
space:
mode:
authorJulien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:31:25 (EST)
committer Julien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:31:25 (EST)
commitc29082d538224219586ef453f1291151a01c15bb (patch)
tree562684ed5430cdf5dad195f25707a6b3f4a4e716 /xcf-general.c
parent30aef48ae5ee252dd42f206c4b5b9e770694417c (diff)
downloadxcftools-c29082d538224219586ef453f1291151a01c15bb.zip
xcftools-c29082d538224219586ef453f1291151a01c15bb.tar.gz
xcftools-c29082d538224219586ef453f1291151a01c15bb.tar.bz2
Add layer group support introduced in Gimp 2.8.
Changes introduced by this commit: - Update xcf-private.h with the file from the head of git's branch named gimp-2-8 (commit acebb4ad205901a9e8029a66ed5bca62cf13bc96). - Increase supported version number from 2 to 3. - Add the cases for PROP_GROUP_ITEM and PROP_ITEM_PATH in getBasicXcfInfo(). - Add the function printLayerPath() to print the groups containing a given layer. - Add an option --path-separator (string) to set the string to use to separate the groups in the paths. The output is unchanged for files whose version is lower than 3. Otherwise, the name of the layer now contains its path in the image and the marker "group" is added for the group layers in the fourth field. For example, here is the output of a file containing a single layer named "a", then one group named "G 1", which contains two layers named "b 1" and "c 2". The path separator is "|" by default: Version 3, 10x10 RGB color, 4 layers, compressed RLE + 10x10+0+0 RGB-alpha Normal |a + 10x10+0+0 RGB-alpha Normal/group |G 1 + 10x10+0+0 RGB-alpha Normal |G 1|b 1 + 10x10+0+0 RGB-alpha Normal |G 1|c 2
Diffstat (limited to 'xcf-general.c')
-rw-r--r--xcf-general.c24
1 files changed, 22 insertions, 2 deletions
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 ;