diff --git a/ChangeLog b/ChangeLog index 1d42b84a70..598dc0e498 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Sep 14 13:51:45 PDT 1999 Manish Singh + + * plug-ins/gfli/fli.[ch] + * plug-ins/gfli/gfli.c: applied gimp-narazaki-990914-0, fixes bogus + magic settings and noninteractive pdb + + * plug-ins/common/ps.c: resolution info patch + Tue Sep 14 13:15:34 PDT 1999 Manish Singh * plug-ins/common/ps.c: don't use wacky binary modifiers to popen diff --git a/plug-ins/common/postscript.c b/plug-ins/common/postscript.c index a95d2bc192..8a4caa7d45 100644 --- a/plug-ins/common/postscript.c +++ b/plug-ins/common/postscript.c @@ -40,10 +40,11 @@ * V 1.05, PK, 21-Sep-98: Write b/w-images (indexed) using image-operator * V 1.06, PK, 22-Dec-98: Fix problem with writing color PS files. * Ghostview may hang when displaying the files. + * V 1.07, PK, 14-Sep-99: Add resolution to image */ -#define VERSIO 1.06 -static char dversio[] = "v1.06 22-Dec-98"; -static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.06 22-Dec-98"; +#define VERSIO 1.07 +static char dversio[] = "v1.07 14-Sep-99"; +static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99"; #include "config.h" #include @@ -302,8 +303,8 @@ query (void) { 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_FLOAT, "width", "Width of the image in PostScript file" }, - { PARAM_FLOAT, "height", "Height of image in PostScript file" }, + { PARAM_FLOAT, "width", "Width of the image in PostScript file (0: use input image size)" }, + { PARAM_FLOAT, "height", "Height of image in PostScript file (0: use input image size)" }, { PARAM_FLOAT, "x_offset", "X-offset to image from lower left corner" }, { PARAM_FLOAT, "y_offset", "Y-offset to image from lower left corner" }, { PARAM_INT32, "unit", "Unit for width/height/offset. 0: inches, 1: millimeters" }, @@ -319,7 +320,7 @@ query (void) gimp_install_procedure ("file_ps_load", _("load file of PostScript/PDF file format"), _("load file of PostScript/PDF file format"), - "Peter Kirchgessner ", + "Peter Kirchgessner ", "Peter Kirchgessner", dversio, "/PostScript", @@ -331,7 +332,7 @@ query (void) gimp_install_procedure ("file_ps_load_setargs", "set additional parameters for procedure file_ps_load", "set additional parameters for procedure file_ps_load", - "Peter Kirchgessner ", + "Peter Kirchgessner ", "Peter Kirchgessner", dversio, NULL, @@ -360,6 +361,36 @@ those with alpha channels."), } +#ifdef GIMP_HAVE_RESOLUTION_INFO +static void +ps_set_save_size (PSSaveVals *vals, + gint32 image_ID) + +{gdouble xres, yres, factor, iw, ih; + guint width, height; + GUnit unit; + + gimp_image_get_resolution (image_ID, &xres, &yres); + unit = gimp_image_get_unit (image_ID); + factor = gimp_unit_get_factor (unit); + if ((factor < 1e-5) || (xres < 1e-5) || (yres < 1e-5)) + { + factor = 1.0; xres = yres = 72.0; + } + /* Calculate size of image in inches */ + width = gimp_image_width (image_ID); + height = gimp_image_height (image_ID); + iw = width / xres / factor; + ih = height / yres / factor; + if (vals->unit_mm) + { + iw *= 25.4; ih *= 25.4; + } + vals->width = iw; + vals->height = ih; +} +#endif + static void run (char *name, int nparams, @@ -443,6 +474,9 @@ run (char *name, if ((k >= 4) && (strcmp (param[3].data.d_string+k-4, ".eps") == 0)) psvals.eps = 1; +#ifdef GIMP_HAVE_RESOLUTION_INFO + ps_set_save_size (&psvals, param[1].data.d_int32); +#endif /* First acquire information with a dialog */ if (! save_dialog ()) return; @@ -480,6 +514,10 @@ run (char *name, if (status == STATUS_SUCCESS) { +#ifdef GIMP_HAVE_RESOLUTION_INFO + if ((psvals.width == 0.0) || (psvals.height == 0.0)) + ps_set_save_size (&psvals, param[1].data.d_int32); +#endif check_save_vals (); if (save_image (param[3].data.d_string, param[1].data.d_int32, param[2].data.d_int32)) @@ -530,7 +568,7 @@ load_image (char *filename) gint32 image_ID, *image_list, *nl; guint page_count; FILE *ifp; - char *temp,*format; + char *temp; int llx, lly, urx, ury; int k, n_images, max_images, max_pagenum; @@ -592,6 +630,11 @@ load_image (char *filename) { image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury); if (image_ID == -1) break; +#ifdef GIMP_HAVE_RESOLUTION_INFO + gimp_image_set_resolution (image_ID, (float)plvals.resolution, + (float)plvals.resolution); + gimp_image_set_unit (image_ID, UNIT_INCH); +#endif if (n_images == max_images) { nl = (gint32 *)g_realloc (image_list, (max_images+10)*sizeof (gint32)); diff --git a/plug-ins/common/ps.c b/plug-ins/common/ps.c index a95d2bc192..8a4caa7d45 100644 --- a/plug-ins/common/ps.c +++ b/plug-ins/common/ps.c @@ -40,10 +40,11 @@ * V 1.05, PK, 21-Sep-98: Write b/w-images (indexed) using image-operator * V 1.06, PK, 22-Dec-98: Fix problem with writing color PS files. * Ghostview may hang when displaying the files. + * V 1.07, PK, 14-Sep-99: Add resolution to image */ -#define VERSIO 1.06 -static char dversio[] = "v1.06 22-Dec-98"; -static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.06 22-Dec-98"; +#define VERSIO 1.07 +static char dversio[] = "v1.07 14-Sep-99"; +static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99"; #include "config.h" #include @@ -302,8 +303,8 @@ query (void) { 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_FLOAT, "width", "Width of the image in PostScript file" }, - { PARAM_FLOAT, "height", "Height of image in PostScript file" }, + { PARAM_FLOAT, "width", "Width of the image in PostScript file (0: use input image size)" }, + { PARAM_FLOAT, "height", "Height of image in PostScript file (0: use input image size)" }, { PARAM_FLOAT, "x_offset", "X-offset to image from lower left corner" }, { PARAM_FLOAT, "y_offset", "Y-offset to image from lower left corner" }, { PARAM_INT32, "unit", "Unit for width/height/offset. 0: inches, 1: millimeters" }, @@ -319,7 +320,7 @@ query (void) gimp_install_procedure ("file_ps_load", _("load file of PostScript/PDF file format"), _("load file of PostScript/PDF file format"), - "Peter Kirchgessner ", + "Peter Kirchgessner ", "Peter Kirchgessner", dversio, "/PostScript", @@ -331,7 +332,7 @@ query (void) gimp_install_procedure ("file_ps_load_setargs", "set additional parameters for procedure file_ps_load", "set additional parameters for procedure file_ps_load", - "Peter Kirchgessner ", + "Peter Kirchgessner ", "Peter Kirchgessner", dversio, NULL, @@ -360,6 +361,36 @@ those with alpha channels."), } +#ifdef GIMP_HAVE_RESOLUTION_INFO +static void +ps_set_save_size (PSSaveVals *vals, + gint32 image_ID) + +{gdouble xres, yres, factor, iw, ih; + guint width, height; + GUnit unit; + + gimp_image_get_resolution (image_ID, &xres, &yres); + unit = gimp_image_get_unit (image_ID); + factor = gimp_unit_get_factor (unit); + if ((factor < 1e-5) || (xres < 1e-5) || (yres < 1e-5)) + { + factor = 1.0; xres = yres = 72.0; + } + /* Calculate size of image in inches */ + width = gimp_image_width (image_ID); + height = gimp_image_height (image_ID); + iw = width / xres / factor; + ih = height / yres / factor; + if (vals->unit_mm) + { + iw *= 25.4; ih *= 25.4; + } + vals->width = iw; + vals->height = ih; +} +#endif + static void run (char *name, int nparams, @@ -443,6 +474,9 @@ run (char *name, if ((k >= 4) && (strcmp (param[3].data.d_string+k-4, ".eps") == 0)) psvals.eps = 1; +#ifdef GIMP_HAVE_RESOLUTION_INFO + ps_set_save_size (&psvals, param[1].data.d_int32); +#endif /* First acquire information with a dialog */ if (! save_dialog ()) return; @@ -480,6 +514,10 @@ run (char *name, if (status == STATUS_SUCCESS) { +#ifdef GIMP_HAVE_RESOLUTION_INFO + if ((psvals.width == 0.0) || (psvals.height == 0.0)) + ps_set_save_size (&psvals, param[1].data.d_int32); +#endif check_save_vals (); if (save_image (param[3].data.d_string, param[1].data.d_int32, param[2].data.d_int32)) @@ -530,7 +568,7 @@ load_image (char *filename) gint32 image_ID, *image_list, *nl; guint page_count; FILE *ifp; - char *temp,*format; + char *temp; int llx, lly, urx, ury; int k, n_images, max_images, max_pagenum; @@ -592,6 +630,11 @@ load_image (char *filename) { image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury); if (image_ID == -1) break; +#ifdef GIMP_HAVE_RESOLUTION_INFO + gimp_image_set_resolution (image_ID, (float)plvals.resolution, + (float)plvals.resolution); + gimp_image_set_unit (image_ID, UNIT_INCH); +#endif if (n_images == max_images) { nl = (gint32 *)g_realloc (image_list, (max_images+10)*sizeof (gint32)); diff --git a/plug-ins/gfli/fli.c b/plug-ins/gfli/fli.c index 8aeb1ea394..ac1ce21467 100644 --- a/plug-ins/gfli/fli.c +++ b/plug-ins/gfli/fli.c @@ -95,6 +95,7 @@ void fli_read_header(FILE *f, s_fli_header *fli_header) fli_header->speed=fli_read_long(f); /* 16 */ } else { fprintf(stderr, "error: magic number is wrong !\n"); + fli_header->magic = NO_HEADER; } } } diff --git a/plug-ins/gfli/fli.h b/plug-ins/gfli/fli.h index d9e27c54dc..2f1cc7ec13 100644 --- a/plug-ins/gfli/fli.h +++ b/plug-ins/gfli/fli.h @@ -50,6 +50,7 @@ typedef struct _fli_chunk { } s_fli_chunk; /** chunk magics */ +#define NO_HEADER 0 #define HEADER_FLI 0xAF11 #define HEADER_FLC 0xAF12 #define FRAME 0xF1FA diff --git a/plug-ins/gfli/gfli.c b/plug-ins/gfli/gfli.c index 22b418e39a..134b303a5d 100644 --- a/plug-ins/gfli/gfli.c +++ b/plug-ins/gfli/gfli.c @@ -124,7 +124,7 @@ static void query () * Load/save procedures */ gimp_install_procedure ( - "file_fli_load", + "file_fli_load_frames", "load FLI-movies", "This is an experimantal plug-in to handle FLI movies", "Jens Ch. Restemeier", @@ -135,7 +135,19 @@ static void query () PROC_PLUG_IN, nload_args, nload_return_vals, load_args, load_return_vals); - gimp_register_magic_load_handler ("file_fli_load", "fli", "", "4,byte,0x11,4,byte,0x12,5,byte,0xAF"); + gimp_install_procedure ( + "file_fli_load", + "load FLI-movies", + "This is an experimantal plug-in to handle FLI movies", + "Jens Ch. Restemeier", + "Jens Ch. Restemeier", + "1997", + "/FLI", + NULL, + PROC_PLUG_IN, + nload_args - 2, nload_return_vals, + load_args, load_return_vals); + gimp_register_magic_load_handler ("file_fli_load", "fli", "", ""); gimp_install_procedure ( "file_fli_save", @@ -181,29 +193,40 @@ static void run (gchar *name, gint nparams, GParam *param, gint *nreturn_vals, G values[0].type = PARAM_STATUS; values[0].data.d_status = STATUS_CALLING_ERROR; - if (strcmp (name, "file_fli_load") == 0) { + if (strncmp (name, "file_fli_load", strlen("file_fli_load")) == 0) { switch (run_mode) { case RUN_NONINTERACTIVE: { gint32 image_id; gint32 pc; + gint32 to_frame; + gint32 from_frame; /* * check for valid parameters: * (Or can I trust GIMP ?) */ - if (nparams!=nload_args) { + if ((nparams < nload_args - 2) || (nload_args < nparams)) { *nreturn_vals = 1; values[0].data.d_status = STATUS_CALLING_ERROR; return; } - for (pc=0; pc