ran autoupdate on this file

2001-07-19  Sven Neumann  <sven@gimp.org>

	* configure.in: ran autoupdate on this file

	* app/xcf/xcf-load.c
	* app/xcf/xcf-private.h
	* app/xcf/xcf-save.c: code cleanup, no changes
This commit is contained in:
Sven Neumann 2001-07-19 15:34:19 +00:00 committed by Sven Neumann
parent 4d212d199b
commit 06db2b8472
5 changed files with 168 additions and 131 deletions

View File

@ -1,3 +1,11 @@
2001-07-19 Sven Neumann <sven@gimp.org>
* configure.in: ran autoupdate on this file
* app/xcf/xcf-load.c
* app/xcf/xcf-private.h
* app/xcf/xcf-save.c: code cleanup, no changes
2001-07-18 Michael Natterer <mitch@gimp.org>
* app/batch.c: bahave like the old batch code and call

View File

@ -94,7 +94,7 @@ static gboolean xcf_swap_func (gint fd,
static GimpParasite *
read_a_parasite (XcfInfo *info)
xcf_load_parasite (XcfInfo *info)
{
GimpParasite *p;
@ -109,7 +109,7 @@ read_a_parasite (XcfInfo *info)
}
static PathPoint*
v1read_bz_point (XcfInfo *info)
xcf_load_bz_point_version1 (XcfInfo *info)
{
PathPoint *ptr;
guint32 type;
@ -126,7 +126,7 @@ v1read_bz_point (XcfInfo *info)
}
static PathPoint *
read_bz_point (XcfInfo *info)
xcf_load_bz_point (XcfInfo *info)
{
PathPoint *ptr;
guint32 type;
@ -143,7 +143,7 @@ read_bz_point (XcfInfo *info)
}
static Path *
read_one_path (GimpImage *gimage,
xcf_load_path (GimpImage *gimage,
XcfInfo *info)
{
Path *bzp;
@ -171,7 +171,7 @@ read_one_path (GimpImage *gimage,
{
PathPoint *bpt;
/* Read in a path */
bpt = v1read_bz_point (info);
bpt = xcf_load_bz_point_version1 (info);
pts_list = g_slist_append (pts_list, bpt);
}
}
@ -183,7 +183,7 @@ read_one_path (GimpImage *gimage,
{
PathPoint *bpt;
/* Read in a path */
bpt = read_bz_point (info);
bpt = xcf_load_bz_point (info);
pts_list = g_slist_append (pts_list, bpt);
}
}
@ -196,7 +196,7 @@ read_one_path (GimpImage *gimage,
{
PathPoint *bpt;
/* Read in a path */
bpt = read_bz_point (info);
bpt = xcf_load_bz_point (info);
pts_list = g_slist_append (pts_list, bpt);
}
}
@ -205,14 +205,15 @@ read_one_path (GimpImage *gimage,
g_warning ("Unknown path type. Possibly corrupt XCF file");
}
bzp = path_new (gimage, ptype, pts_list, closed, (gint)state, locked, tattoo, name);
bzp = path_new (gimage,
ptype, pts_list, closed, (gint)state, locked, tattoo, name);
return bzp;
}
static PathList *
read_bzpaths (GimpImage *gimage,
XcfInfo *info)
xcf_load_bzpaths (GimpImage *gimage,
XcfInfo *info)
{
guint32 num_paths;
guint32 last_selected_row;
@ -226,7 +227,7 @@ read_bzpaths (GimpImage *gimage,
{
Path *bzp;
/* Read in a path */
bzp = read_one_path (gimage, info);
bzp = xcf_load_path (gimage, info);
bzp_list = g_slist_append (bzp_list, bzp);
}
@ -389,7 +390,8 @@ xcf_load_image_props (XcfInfo *info,
g_message (_("XCF warning: version 0 of XCF file format\n"
"did not save indexed colormaps correctly.\n"
"Substituting grayscale map."));
info->cp += xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
gimage->cmap = g_new (guchar, gimage->num_cols*3);
xcf_seek_pos (info, info->cp + gimage->num_cols);
for (i = 0; i<gimage->num_cols; i++)
@ -401,9 +403,12 @@ xcf_load_image_props (XcfInfo *info,
}
else
{
info->cp += xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
gimage->cmap = g_new (guchar, gimage->num_cols*3);
info->cp += xcf_read_int8 (info->fp, (guint8*) gimage->cmap, gimage->num_cols*3);
info->cp +=
xcf_read_int8 (info->fp,
(guint8*) gimage->cmap, gimage->num_cols*3);
}
break;
@ -436,8 +441,10 @@ xcf_load_image_props (XcfInfo *info,
nguides = prop_size / (4 + 1);
for (i = 0; i < nguides; i++)
{
info->cp += xcf_read_int32 (info->fp, (guint32 *) &position, 1);
info->cp += xcf_read_int8 (info->fp, (guint8 *) &orientation, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32 *) &position, 1);
info->cp +=
xcf_read_int8 (info->fp, (guint8 *) &orientation, 1);
switch (orientation)
{
@ -496,7 +503,7 @@ xcf_load_image_props (XcfInfo *info,
while (info->cp - base < prop_size)
{
p = read_a_parasite (info);
p = xcf_load_parasite (info);
gimp_image_parasite_attach (gimage, p);
gimp_parasite_free (p);
}
@ -514,7 +521,8 @@ xcf_load_image_props (XcfInfo *info,
if ((unit <= GIMP_UNIT_PIXEL) ||
(unit >= _gimp_unit_get_number_of_built_in_units (gimage->gimp)))
{
g_message ("Warning, unit out of range in XCF file, falling back to inches");
g_message ("Warning, unit out of range in XCF file, "
"falling back to inches");
unit = GIMP_UNIT_INCH;
}
@ -524,7 +532,7 @@ xcf_load_image_props (XcfInfo *info,
case PROP_PATHS:
{
PathList *paths = read_bzpaths (gimage, info);
PathList *paths = xcf_load_bzpaths (gimage, info);
/* add to gimage */
gimp_image_set_paths (gimage, paths);
}
@ -584,7 +592,8 @@ xcf_load_image_props (XcfInfo *info,
break;
default:
g_message ("unexpected/unknown image property: %d (skipping)", prop_type);
g_message ("unexpected/unknown image property: %d (skipping)",
prop_type);
{
guint8 buf[16];
@ -629,10 +638,13 @@ xcf_load_layer_props (XcfInfo *info,
break;
case PROP_FLOATING_SELECTION:
info->floating_sel = layer;
info->cp += xcf_read_int32 (info->fp, (guint32*) &info->floating_sel_offset, 1);
info->cp +=
xcf_read_int32 (info->fp,
(guint32*) &info->floating_sel_offset, 1);
break;
case PROP_OPACITY:
info->cp += xcf_read_int32 (info->fp, (guint32*) &layer->opacity, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32*) &layer->opacity, 1);
break;
case PROP_VISIBLE:
{
@ -647,7 +659,8 @@ xcf_load_layer_props (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, (guint32*) &layer->linked, 1);
break;
case PROP_PRESERVE_TRANSPARENCY:
info->cp += xcf_read_int32 (info->fp, (guint32*) &layer->preserve_trans, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32*) &layer->preserve_trans, 1);
break;
case PROP_APPLY_MASK:
info->cp += xcf_read_int32 (info->fp, (guint32*) apply_mask, 1);
@ -659,8 +672,12 @@ xcf_load_layer_props (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, (guint32*) show_mask, 1);
break;
case PROP_OFFSETS:
info->cp += xcf_read_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->offset_x, 1);
info->cp += xcf_read_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->offset_y, 1);
info->cp +=
xcf_read_int32 (info->fp,
(guint32*) &GIMP_DRAWABLE(layer)->offset_x, 1);
info->cp +=
xcf_read_int32 (info->fp,
(guint32*) &GIMP_DRAWABLE(layer)->offset_y, 1);
break;
case PROP_MODE:
info->cp += xcf_read_int32 (info->fp, (guint32*) &layer->mode, 1);
@ -676,7 +693,7 @@ xcf_load_layer_props (XcfInfo *info,
GimpParasite *p;
while (info->cp - base < prop_size)
{
p = read_a_parasite(info);
p = xcf_load_parasite(info);
gimp_drawable_parasite_attach(GIMP_DRAWABLE(layer), p);
gimp_parasite_free(p);
}
@ -685,7 +702,8 @@ xcf_load_layer_props (XcfInfo *info,
}
break;
default:
g_message ("unexpected/unknown layer property: %d (skipping)", prop_type);
g_message ("unexpected/unknown layer property: %d (skipping)",
prop_type);
{
guint8 buf[16];
@ -749,7 +767,8 @@ xcf_load_channel_props (XcfInfo *info,
}
break;
case PROP_SHOW_MASKED:
info->cp += xcf_read_int32 (info->fp, (guint32*) &channel->show_masked, 1);
info->cp +=
xcf_read_int32 (info->fp, (guint32*) &channel->show_masked, 1);
break;
case PROP_COLOR:
{
@ -762,8 +781,8 @@ xcf_load_channel_props (XcfInfo *info,
}
break;
case PROP_TATTOO:
info->cp += xcf_read_int32 (info->fp, &GIMP_DRAWABLE(channel)->tattoo,
1);
info->cp +=
xcf_read_int32 (info->fp, &GIMP_DRAWABLE(channel)->tattoo, 1);
break;
case PROP_PARASITES:
{
@ -771,7 +790,7 @@ xcf_load_channel_props (XcfInfo *info,
GimpParasite *p;
while ((info->cp - base) < prop_size)
{
p = read_a_parasite(info);
p = xcf_load_parasite(info);
gimp_drawable_parasite_attach(GIMP_DRAWABLE(channel), p);
gimp_parasite_free(p);
}
@ -780,7 +799,8 @@ xcf_load_channel_props (XcfInfo *info,
}
break;
default:
g_message ("unexpected/unknown channel property: %d (skipping)", prop_type);
g_message ("unexpected/unknown channel property: %d (skipping)",
prop_type);
{
guint8 buf[16];
@ -1381,7 +1401,8 @@ xcf_swap_func (gint fd,
if (err <= 0)
{
g_message ("unable to read tile data from xcf file: %d ( %d ) bytes read", err, nleft);
g_message ("unable to read tile data from xcf file: "
"%d ( %d ) bytes read", err, nleft);
return FALSE;
}

View File

@ -22,58 +22,58 @@
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_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_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
} PropType;
typedef enum
{
COMPRESS_NONE = 0,
COMPRESS_RLE = 1,
COMPRESS_ZLIB = 2,
COMPRESS_FRACTAL = 3 /* Unused. */
} CompressionType;
COMPRESS_NONE = 0,
COMPRESS_RLE = 1,
COMPRESS_ZLIB = 2, /* unused */
COMPRESS_FRACTAL = 3 /* unused */
} XcfCompressionType;
typedef struct _XcfInfo XcfInfo;
struct _XcfInfo
{
FILE *fp;
guint cp;
gchar *filename;
GimpLayer *active_layer;
GimpChannel *active_channel;
GimpDrawable *floating_sel_drawable;
GimpLayer *floating_sel;
guint floating_sel_offset;
gint swap_num;
gint *ref_count;
gint compression;
gint file_version;
FILE *fp;
guint cp;
gchar *filename;
GimpLayer *active_layer;
GimpChannel *active_channel;
GimpDrawable *floating_sel_drawable;
GimpLayer *floating_sel;
guint floating_sel_offset;
gint swap_num;
gint *ref_count;
XcfCompressionType compression;
gint file_version;
};

View File

@ -252,7 +252,8 @@ xcf_save_image_props (XcfInfo *info,
{
/* check and see if we should save the colormap property */
if (gimage->cmap)
xcf_save_prop (info, gimage, PROP_COLORMAP, gimage->num_cols, gimage->cmap);
xcf_save_prop (info, gimage,
PROP_COLORMAP, gimage->num_cols, gimage->cmap);
if (info->compression != COMPRESS_NONE)
xcf_save_prop (info, gimage, PROP_COMPRESSION, info->compression);
@ -358,27 +359,25 @@ xcf_save_channel_props (XcfInfo *info,
}
static void
write_a_parasite (gchar *key,
GimpParasite *p,
XcfInfo *info)
xcf_save_parasite (gchar *key,
GimpParasite *parasite,
XcfInfo *info)
{
if ((p->flags & GIMP_PARASITE_PERSISTENT))
if (gimp_parasite_is_persistent (parasite))
{
info->cp += xcf_write_string (info->fp, &p->name, 1);
info->cp += xcf_write_int32 (info->fp, &p->flags, 1);
info->cp += xcf_write_int32 (info->fp, &p->size, 1);
info->cp += xcf_write_int8 (info->fp, p->data, p->size);
info->cp += xcf_write_string (info->fp, &parasite->name, 1);
info->cp += xcf_write_int32 (info->fp, &parasite->flags, 1);
info->cp += xcf_write_int32 (info->fp, &parasite->size, 1);
info->cp += xcf_write_int8 (info->fp, parasite->data, parasite->size);
}
}
static void
write_bz_point (gpointer pptr,
gpointer iptr)
xcf_save_bz_point (PathPoint *bpt,
XcfInfo *info)
{
PathPoint *bpt = (PathPoint*)pptr;
XcfInfo *info = (XcfInfo *)iptr;
gfloat xfloat = (gfloat)bpt->x;
gfloat yfloat = (gfloat)bpt->y;
gfloat xfloat = bpt->x;
gfloat yfloat = bpt->y;
/* (all gint)
* type
@ -392,12 +391,10 @@ write_bz_point (gpointer pptr,
}
static void
write_one_path (gpointer pptr,
gpointer iptr)
xcf_save_path (Path *bzp,
XcfInfo *info)
{
Path *bzp = (Path*)pptr;
XcfInfo *info = (XcfInfo *)iptr;
guint8 state = (gchar)bzp->state;
guint8 state = bzp->state;
guint32 num_points;
guint32 closed;
guint32 version;
@ -423,12 +420,12 @@ write_one_path (gpointer pptr,
info->cp += xcf_write_int32 (info->fp, &version, 1);
info->cp += xcf_write_int32 (info->fp, &bzp->pathtype, 1);
info->cp += xcf_write_int32 (info->fp, &bzp->tattoo, 1);
g_slist_foreach (bzp->path_details, write_bz_point, info);
g_slist_foreach (bzp->path_details, (GFunc) xcf_save_bz_point, info);
}
static void
write_bzpaths (PathList *paths,
XcfInfo *info)
static void
xcf_save_bzpaths (PathList *paths,
XcfInfo *info)
{
guint32 num_paths;
/* Write out the following:-
@ -439,10 +436,11 @@ write_bzpaths (PathList *paths,
* then each path:-
*/
info->cp += xcf_write_int32 (info->fp, (guint32*)&paths->last_selected_row, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &paths->last_selected_row, 1);
num_paths = g_slist_length (paths->bz_paths);
info->cp += xcf_write_int32(info->fp, &num_paths, 1);
g_slist_foreach( paths->bz_paths, write_one_path, info);
info->cp += xcf_write_int32 (info->fp, &num_paths, 1);
g_slist_foreach (paths->bz_paths, (GFunc) xcf_save_path, info);
}
static void
@ -678,7 +676,8 @@ xcf_save_prop (XcfInfo *info,
{
gfloat xresolution, yresolution;
/* we pass in floats, but they are promoted to double by the compiler */
/* we pass in floats,
but they are promoted to double by the compiler */
xresolution = va_arg (args, double);
yresolution = va_arg (args, double);
@ -717,15 +716,16 @@ xcf_save_prop (XcfInfo *info,
/* because we don't know how much room the parasite list will take
* we save the file position and write the length later
*/
pos = ftell (info->fp);
pos = info->cp;
info->cp += xcf_write_int32 (info->fp, &length, 1);
base = info->cp;
gimp_parasite_list_foreach (list, (GHFunc) write_a_parasite, info);
gimp_parasite_list_foreach (list,
(GHFunc) xcf_save_parasite, info);
length = info->cp - base;
/* go back to the saved position and write the length */
fseek (info->fp, pos, SEEK_SET);
xcf_seek_pos (info, pos);
xcf_write_int32 (info->fp, &length, 1);
fseek (info->fp, 0, SEEK_END);
xcf_seek_end (info);
}
}
break;
@ -747,24 +747,25 @@ xcf_save_prop (XcfInfo *info,
PathList *paths_list;
guint32 base, length;
long pos;
paths_list = va_arg (args, PathList *);
if (paths_list)
{
info->cp += xcf_write_int32 (info->fp, (guint32*) &prop_type, 1);
/* because we don't know how much room the paths list will take
we save the file position and write the length later
ALT. OK I copied the code from above...
*/
pos = ftell(info->fp);
info->cp += xcf_write_int32 (info->fp, &length, 1);
base = info->cp;
write_bzpaths(paths_list,info);
length = info->cp - base;
/* go back to the saved position and write the length */
fseek(info->fp, pos, SEEK_SET);
xcf_write_int32 (info->fp, &length, 1);
fseek(info->fp, 0, SEEK_END);
}
{
info->cp += xcf_write_int32 (info->fp, (guint32*) &prop_type, 1);
/* because we don't know how much room the paths list will take
we save the file position and write the length later
*/
pos = info->cp;
info->cp += xcf_write_int32 (info->fp, &length, 1);
base = info->cp;
xcf_save_bzpaths (paths_list, info);
length = info->cp - base;
/* go back to the saved position and write the length */
xcf_seek_pos (info, pos);
xcf_write_int32 (info->fp, &length, 1);
xcf_seek_end (info);
}
}
break;
case PROP_USER_UNIT:
@ -825,9 +826,12 @@ xcf_save_layer (XcfInfo *info,
}
/* write out the width, height and image type information for the layer */
info->cp += xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->width, 1);
info->cp += xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->height, 1);
info->cp += xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->type, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->width, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->height, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(layer)->type, 1);
/* write out the layers name */
info->cp += xcf_write_string (info->fp, &GIMP_OBJECT (layer)->name, 1);
@ -876,7 +880,7 @@ xcf_save_channel (XcfInfo *info,
/* check and see if this is the drawable that the floating
* selection is attached to.
*/
if (GIMP_DRAWABLE(channel) == info->floating_sel_drawable)
if (GIMP_DRAWABLE (channel) == info->floating_sel_drawable)
{
saved_pos = info->cp;
xcf_seek_pos (info, info->floating_sel_offset);
@ -885,8 +889,10 @@ xcf_save_channel (XcfInfo *info,
}
/* write out the width and height information for the channel */
info->cp += xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->width, 1);
info->cp += xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->height, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->width, 1);
info->cp +=
xcf_write_int32 (info->fp, (guint32*) &GIMP_DRAWABLE(channel)->height, 1);
/* write out the channels name */
info->cp += xcf_write_string (info->fp, &GIMP_OBJECT (channel)->name, 1);
@ -903,7 +909,7 @@ xcf_save_channel (XcfInfo *info,
xcf_seek_pos (info, info->cp + 4);
offset = info->cp;
xcf_save_hierarchy (info, GIMP_DRAWABLE(channel)->tiles);
xcf_save_hierarchy (info, GIMP_DRAWABLE (channel)->tiles);
xcf_seek_pos (info, saved_pos);
info->cp += xcf_write_int32 (info->fp, &offset, 1);
@ -1023,7 +1029,8 @@ xcf_save_level (XcfInfo *info,
/* allocate a temporary buffer to store the rle data before it is
written to disk */
rlebuf = g_malloc (TILE_WIDTH * TILE_HEIGHT * tile_manager_bpp (level) * 1.5);
rlebuf =
g_malloc (TILE_WIDTH * TILE_HEIGHT * tile_manager_bpp (level) * 1.5);
if (level->tiles)
{
@ -1152,6 +1159,7 @@ xcf_save_tile_rle (XcfInfo *info,
else if ((length == 1) && (last != *data))
state = 1;
break;
case 1:
/* in state 1 we try and find a long sequence of
* non-matching values.

View File

@ -439,7 +439,7 @@ AC_MSG_CHECKING([fd_set and sys/select])
AC_TRY_COMPILE([#include <sys/types.h>],
[fd_set readMask, writeMask;], gimp_ok=yes, gimp_ok=no)
if test $gimp_ok = no; then
AC_HEADER_EGREP(fd_mask, sys/select.h, gimp_ok=yes)
AC_EGREP_HEADER(fd_mask, sys/select.h, gimp_ok=yes)
if test $gimp_ok = yes; then
AC_DEFINE(HAVE_SYS_SELECT_H)
fi