Commit 058cd91d authored by Sven Neumann's avatar Sven Neumann
Browse files

cleaned up after myself ...


--Sven
parent 96961a7b
Thu Oct 14 13:31:59 MEST 1999 Sven Neumann <sven@gimp.org>
* plug-ins/common/sunras.c
* plug-ins/common/xwd.c: changed a few changes I made yesterday...
Thu Oct 14 04:59:11 BST 1999 Nick Lamb <njl195@zepler.org>
 
* app/preferences_dialog.c: Recalculate size of ctree in the
preferences dialog after adding all the categories.
This is the real fix for #2508.
 
Thu Oct 14 04:08:31 *EST 1999 Sven Neumann <sven@gimp.org>
Thu Oct 14 04:08:31 MEST 1999 Sven Neumann <sven@gimp.org>
 
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
......@@ -37,7 +42,7 @@ Thu Oct 14 01:00:03 MEST 1999 Sven Neumann <sven@gimp.org>
Wed Oct 13 21:37:51 BST 1999 Andy Thomas <alt@gimp.org>
 
* app/crop.c
* app/sca_convert.c
* app/scan_convert.c
 
Fixes to memory problems (use of freed memory references) found
by running with dmalloc.
......
......@@ -142,6 +142,7 @@ static void save_ok_callback (GtkWidget *widget,
gpointer data);
static void save_toggle_update (GtkWidget *widget,
gpointer data);
static void show_message (char *);
/* Portability kludge */
static int my_fwrite (void *ptr, int size, int nmemb, FILE *stream);
......@@ -370,7 +371,7 @@ load_image (char *filename)
ifp = fopen (filename, "rb");
if (!ifp)
{
gimp_message ("can't open file for reading");
show_message ("can't open file for reading");
return (-1);
}
......@@ -379,14 +380,14 @@ load_image (char *filename)
read_sun_header (ifp, &sunhdr);
if (sunhdr.l_ras_magic != RAS_MAGIC)
{
gimp_message("can't open file as SUN-raster-file");
show_message("can't open file as SUN-raster-file");
fclose (ifp);
return (-1);
}
if ((sunhdr.l_ras_type < 0) || (sunhdr.l_ras_type > 5))
{
gimp_message ("the type of this SUN-rasterfile\nis not supported");
show_message ("the type of this SUN-rasterfile\nis not supported");
fclose (ifp);
return (-1);
}
......@@ -397,7 +398,7 @@ load_image (char *filename)
suncolmap = (unsigned char *)malloc (sunhdr.l_ras_maplength);
if (suncolmap == NULL)
{
gimp_message ("cant get memory for colour map");
show_message ("cant get memory for colour map");
fclose (ifp);
return (-1);
}
......@@ -414,14 +415,14 @@ load_image (char *filename)
#endif
if (sunhdr.l_ras_magic != RAS_MAGIC)
{
gimp_message ("cant read colour entries");
show_message ("cant read colour entries");
fclose (ifp);
return (-1);
}
}
else if (sunhdr.l_ras_maplength > 0)
{
gimp_message ("type of colourmap not supported");
show_message ("type of colourmap not supported");
fseek (ifp, (sizeof (L_SUNFILEHEADER)/sizeof (L_CARD32))
*4 + sunhdr.l_ras_maplength, SEEK_SET);
}
......@@ -463,7 +464,7 @@ load_image (char *filename)
if (image_ID == -1)
{
gimp_message ("this image depth is not supported");
show_message ("this image depth is not supported");
return (-1);
}
......@@ -487,7 +488,7 @@ save_image (char *filename,
/* Make sure we're not saving an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID))
{
gimp_message ("SUNRAS save cannot handle images with alpha channels");
show_message ("SUNRAS save cannot handle images with alpha channels");
return FALSE;
}
......@@ -498,7 +499,7 @@ save_image (char *filename,
case RGB_IMAGE:
break;
default:
gimp_message ("cannot operate on unknown image types");
show_message ("cannot operate on unknown image types");
return (FALSE);
break;
}
......@@ -507,7 +508,7 @@ save_image (char *filename,
ofp = fopen (filename, "wb");
if (!ofp)
{
gimp_message ("cant open file for writing");
show_message ("cant open file for writing");
return (FALSE);
}
......@@ -1028,7 +1029,7 @@ load_sun_d1 (char *filename,
g_free (data);
if (err)
gimp_message ("EOF encountered on reading");
show_message ("EOF encountered on reading");
gimp_drawable_flush (drawable);
......@@ -1120,7 +1121,7 @@ load_sun_d8 (char *filename,
g_free (data);
if (err)
gimp_message ("EOF encountered on reading");
show_message ("EOF encountered on reading");
gimp_drawable_flush (drawable);
......@@ -1202,7 +1203,7 @@ load_sun_d24 (char *filename,
g_free (data);
if (err)
gimp_message ("EOF encountered on reading");
show_message ("EOF encountered on reading");
gimp_drawable_flush (drawable);
......@@ -1298,7 +1299,7 @@ load_sun_d32 (char *filename,
g_free (data);
if (err)
gimp_message ("EOF encountered on reading");
show_message ("EOF encountered on reading");
gimp_drawable_flush (drawable);
......@@ -1454,7 +1455,7 @@ save_index (FILE *ofp,
if (ferror (ofp))
{
gimp_message ("write error occured");
show_message ("write error occured");
return (FALSE);
}
return (TRUE);
......@@ -1563,7 +1564,7 @@ save_rgb (FILE *ofp,
if (ferror (ofp))
{
gimp_message ("write error occured");
show_message ("write error occured");
return (FALSE);
}
return (TRUE);
......@@ -1707,6 +1708,16 @@ save_toggle_update (GtkWidget *widget,
*toggle_val = FALSE;
}
/* Show a message. Where to show it, depends on the runmode */
static void
show_message (char *message)
{
if (l_run_mode == RUN_INTERACTIVE)
gimp_message (message);
else
fprintf (stderr, "sunras: %s\n", message);
}
static int
my_fwrite (void *ptr,
int size,
......@@ -1715,3 +1726,7 @@ my_fwrite (void *ptr,
{
return fwrite(ptr, size, nmemb, stream);
}
......@@ -124,28 +124,28 @@ typedef struct {
/* Declare some local functions.
*/
static void query (void);
static void run (char *name,
int nparams,
GParam *param,
int *nreturn_vals,
GParam **return_vals);
static void init_gtk (void);
static gint32 load_image (char *filename);
static gint save_image (char *filename,
gint32 image_ID,
gint32 drawable_ID);
static gint32 create_new_image (char *filename, guint width, guint height,
GImageType type, gint32 *layer_ID,
GDrawable **drawable, GPixelRgn *pixel_rgn);
static int set_pixelmap (int, L_XWDCOLOR *,PIXEL_MAP *);
static int get_pixelmap (L_CARD32, PIXEL_MAP *,unsigned char *,
static void query (void);
static void run (char *name,
int nparams,
GParam *param,
int *nreturn_vals,
GParam **return_vals);
static void init_gtk (void);
static gint32 load_image (char *filename);
static gint save_image (char *filename,
gint32 image_ID,
gint32 drawable_ID);
static gint32 create_new_image (char *filename, guint width, guint height,
GImageType type, gint32 *layer_ID,
GDrawable **drawable, GPixelRgn *pixel_rgn);
static int set_pixelmap (int, L_XWDCOLOR *,PIXEL_MAP *);
static int get_pixelmap (L_CARD32, PIXEL_MAP *,unsigned char *,
unsigned char *, unsigned char *);
static void set_bw_color_table (gint32);
static void set_color_table (gint32, L_XWDFILEHEADER *, L_XWDCOLOR *);
static void set_bw_color_table (gint32);
static void set_color_table (gint32, L_XWDFILEHEADER *, L_XWDCOLOR *);
static gint32 load_xwd_f2_d1_b1 (char *, FILE *, L_XWDFILEHEADER *,
L_XWDCOLOR *);
......@@ -174,6 +174,8 @@ static void write_xwd_cols (FILE *, L_XWDFILEHEADER *, L_XWDCOLOR *);
static gint save_index (FILE *, gint32, gint32, int);
static gint save_rgb (FILE *, gint32, gint32);
static void show_message (char *);
static int read_msb_first = 1;
......@@ -200,13 +202,13 @@ query (void)
{
static GParamDef load_args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_STRING, "filename", "The name of the file to load" },
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_STRING, "filename", "The name of the file to load" },
{ PARAM_STRING, "raw_filename", "The name of the file to load" },
};
static GParamDef load_return_vals[] =
{
{ PARAM_IMAGE, "image", "Output image" },
{ PARAM_IMAGE, "image", "Output image" },
};
static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
static int nload_return_vals = sizeof (load_return_vals)
......@@ -214,12 +216,11 @@ query (void)
static GParamDef save_args[] =
{
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
{ PARAM_STRING, "raw_filename",
"The name of the file to save the image in" }
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
{ PARAM_STRING, "raw_filename", "The name of the file to save the image in" }
};
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
......@@ -245,7 +246,7 @@ those with alpha channels."),
"Peter Kirchgessner",
"1996",
"<Save>/XWD",
"RGB*, GRAY*, INDEXED*",
"RGB, GRAY, INDEXED",
PROC_PLUG_IN,
nsave_args, 0,
save_args, NULL);
......@@ -305,7 +306,7 @@ run (char *name,
case RUN_WITH_LAST_VALS:
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "XWD",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA));
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
......@@ -374,7 +375,7 @@ load_image (char *filename)
ifp = fopen (filename, "rb");
if (!ifp)
{
gimp_message (_("can't open file for reading"));
show_message (_("can't open file for reading"));
return (-1);
}
......@@ -390,7 +391,7 @@ load_image (char *filename)
read_xwd_header (ifp, &xwdhdr);
if (xwdhdr.l_file_version != 7)
{
gimp_message(_("can't open file as XWD file"));
show_message(_("can't open file as XWD file"));
fclose (ifp);
return (-1);
}
......@@ -405,7 +406,7 @@ load_image (char *filename)
* xwdhdr.l_colormap_entries);
if (xwdcolmap == NULL)
{
gimp_message (_("can't get memory for colormap"));
show_message (_("can't get memory for colormap"));
fclose (ifp);
return (-1);
}
......@@ -423,7 +424,7 @@ load_image (char *filename)
#endif
if (xwdhdr.l_file_version != 7)
{
gimp_message (_("can't read color entries"));
show_message (_("can't read color entries"));
g_free (xwdcolmap);
fclose (ifp);
return (-1);
......@@ -487,14 +488,14 @@ load_image (char *filename)
temp = g_malloc (strlen (filename)+256);
if (temp == NULL)
{
gimp_message (_("this image depth/format is not supported"));
show_message (_("this image depth/format is not supported"));
}
else
{
sprintf (temp, _("load_image (xwd): XWD-file %s has format %d, depth %d\n\
and bits per pixel %d.\nCurrently this is not supported.\n"),
filename, (int)xwdhdr.l_pixmap_format, depth, bpp);
gimp_message (temp);
show_message (temp);
g_free (temp);
}
return (-1);
......@@ -519,7 +520,7 @@ save_image (char *filename,
/* Make sure we're not saving an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID))
{
gimp_message (_("XWD save cannot handle images with alpha channels"));
show_message (_("XWD save cannot handle images with alpha channels"));
return FALSE;
}
......@@ -530,7 +531,7 @@ save_image (char *filename,
case RGB_IMAGE:
break;
default:
gimp_message (_("cannot operate on unknown image types"));
show_message (_("cannot operate on unknown image types"));
return (FALSE);
break;
}
......@@ -539,7 +540,7 @@ save_image (char *filename,
ofp = fopen (filename, "wb");
if (!ofp)
{
gimp_message (_("can't open file for writing"));
show_message (_("can't open file for writing"));
return (FALSE);
}
......@@ -1197,7 +1198,7 @@ load_xwd_f2_d1_b1 (char *filename,
g_free (scanline);
if (err)
gimp_message (_("EOF encountered on "));
show_message (_("EOF encountered on "));
gimp_drawable_flush (drawable);
......@@ -1295,7 +1296,7 @@ load_xwd_f2_d8_b8 (char *filename,
g_free (data);
if (err)
gimp_message (_("EOF encountered on reading"));
show_message (_("EOF encountered on reading"));
gimp_drawable_flush (drawable);
......@@ -1343,7 +1344,7 @@ load_xwd_f2_d16_b16 (char *filename,
ColorMap = (unsigned char *)g_malloc (maxval);
if (ColorMap == NULL)
{
gimp_message (_("No memory for mapping colors"));
show_message (_("No memory for mapping colors"));
return (-1);
}
memset (ColorMap,0,maxval);
......@@ -1457,7 +1458,7 @@ load_xwd_f2_d16_b16 (char *filename,
g_free (ColorMap);
if (err)
gimp_message (_("EOF encountered on reading"));
show_message (_("EOF encountered on reading"));
gimp_drawable_flush (drawable);
......@@ -1654,7 +1655,7 @@ load_xwd_f2_d24_b32 (char *filename,
g_free (data);
if (err)
gimp_message (_("EOF encountered on reading"));
show_message (_("EOF encountered on reading"));
gimp_drawable_flush (drawable);
......@@ -1905,7 +1906,7 @@ load_xwd_f1_d24_b1 (char *filename,
g_free (xwddata);
if (err)
gimp_message (_("EOF encountered on reading"));
show_message (_("EOF encountered on reading"));
gimp_drawable_flush (drawable);
......@@ -2029,7 +2030,7 @@ save_index (FILE *ofp,
if (ferror (ofp))
{
gimp_message (_("Error during writing indexed/grey image"));
show_message (_("Error during writing indexed/grey image"));
return (FALSE);
}
return (TRUE);
......@@ -2118,12 +2119,21 @@ save_rgb (FILE *ofp,
if (ferror (ofp))
{
gimp_message (_("Error during writing rgb image"));
show_message (_("Error during writing rgb image"));
return (FALSE);
}
return (TRUE);
}
/* Show a message. Where to show it, depends on the runmode */
static void
show_message (char *message)
{
if (l_run_mode == RUN_INTERACTIVE)
gimp_message (message);
else
fprintf (stderr, "sunras: %s\n", message);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment