Commit 2a783d04 authored by Sven Neumann's avatar Sven Neumann
Browse files

the rest of the save plug-ins !?


--Sven
parent 23f00ee6
Wed Oct 20 03:42:08 MEST 1999 Sven Neumann <sven@gimp.org>
* plug-ins/common/Makefile.am
* plug-ins/common/pix.c
* plug-ins/common/plugin-defs.pl
* plug-ins/common/png.c
* plug-ins/common/psp.c
* plug-ins/fits/Makefile.am
* plug-ins/fits/fits.c
* plug-ins/sgi/Makefile.am
* plug-ins/sgi/sgi.c: made more save plug-ins export-aware.
Hopefully I have converted them all now. If you find one that I
missed or experience any problems, please drop me a mail.
Tue Oct 19 17:56:29 PDT 1999 Manish Singh <yosh@gimp.org>
 
* plug-ins/common/bz2.c
......
......@@ -778,8 +778,9 @@ pix_SOURCES = \
pix.c
pix_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(INTLLIBS)
pixelize_SOURCES = \
......@@ -854,6 +855,7 @@ psp_SOURCES = \
psp.c
psp_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \
$(LIBZ) \
$(GTK_LIBS) \
......
This diff is collapsed.
......@@ -73,7 +73,7 @@
'papertile' => { libdep => 'gtk' },
'pat' => { libdep => 'gtk', ui => 1 },
'pcx' => { libdep => 'gtk', ui => 1 },
'pix' => { libdep => 'glib' },
'pix' => { libdep => 'gtk', ui => 1 },
'pixelize' => { libdep => 'gtk' },
'plasma' => { libdep => 'gtk' },
'plugindetails' => { libdep => 'gtk' },
......@@ -82,7 +82,7 @@
'polar' => { libdep => 'gtk' },
'ps' => { libdep => 'gtk', ui => 1 },
'psd' => { libdep => 'glib' },
'psp' => { libdep => 'gtk', optional => 1, libopt => 'z' },
'psp' => { libdep => 'gtk', ui => 1, optional => 1, libopt => 'z' },
'randomize' => { libdep => 'gtk', libsupp => 'gpc' },
'ripple' => { libdep => 'gtk' },
'rotate' => { libdep => 'gtk' },
......
......@@ -299,12 +299,12 @@ run (char *name, /* I - Name of filter program. */
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
};
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
......
......@@ -50,6 +50,7 @@
#include <zlib.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include <libgimp/parasiteio.h>
#include <libgimp/stdplugins-intl.h>
......@@ -431,6 +432,20 @@ save_ok_callback (GtkWidget *widget,
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("psp");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
static gint
save_dialog ()
{
......@@ -440,19 +455,10 @@ save_dialog ()
GtkWidget *frame;
GtkWidget *toggle_vbox;
GSList *group;
gchar **argv;
gint argc;
gint use_none = (psvals.compression == PSP_COMP_NONE);
gint use_rle = (psvals.compression == PSP_COMP_RLE);
gint use_lz77 = (psvals.compression == PSP_COMP_LZ77);
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("save");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), "Save as PSP");
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
......@@ -1749,7 +1755,9 @@ run (char *name,
static GParam values[2];
GRunModeType run_mode;
GStatusType status = STATUS_SUCCESS;
GimpExportReturnType export = EXPORT_CANCEL;
gint32 image_ID;
gint32 drawable_ID;
tile_height = gimp_tile_height ();
......@@ -1778,10 +1786,33 @@ run (char *name,
}
else if (strcmp (name, "file_psp_save") == 0)
{
image_ID = orig_image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
/* eventually export the image */
switch (run_mode)
{
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
INIT_I18N_UI();
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PSP",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA | CAN_HANDLE_LAYERS));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
}
switch (run_mode)
{
case RUN_INTERACTIVE:
INIT_I18N_UI();
/* Possibly retrieve data */
gimp_get_data ("file_pnm_save", &psvals);
......@@ -1811,7 +1842,7 @@ run (char *name,
if (status == STATUS_SUCCESS)
{
if (save_image (param[3].data.d_string, param[1].data.d_int32, param[2].data.d_int32))
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{
gimp_set_data ("file_psp_save", &psvals, sizeof (PSPSaveVals));
......@@ -1822,5 +1853,8 @@ run (char *name,
}
values[0].data.d_status = status;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
}
......@@ -16,6 +16,7 @@ INCLUDES = \
LDADD = \
$(top_builddir)/libgimp/libgimp.la \
$(top_builddir)/libgimp/libgimpui.la \
$(GTK_LIBS) \
$(INTLLIBS)
......
......@@ -35,6 +35,7 @@ static char ident[] = "@(#) GIMP FITS file-plugin v1.05 20-Dec-97";
#include <string.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "fitsrw.h"
/* Load info */
......@@ -108,6 +109,7 @@ typedef struct
int toggle_val[2*LOAD_FITS_TOGGLES];
} LoadDialogVals;
static void init_gtk (void);
static gint load_dialog (void);
static void load_close_callback (GtkWidget *widget,
......@@ -150,13 +152,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_STRING, "raw_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)
......@@ -164,12 +166,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]);
......@@ -194,7 +195,7 @@ those with alpha channels.",
"Peter Kirchgessner (pkirchg@aol.com)",
"1997",
"<Save>/FITS",
"RGB*, GRAY*, INDEXED*",
"RGB, GRAY, INDEXED",
PROC_PLUG_IN,
nsave_args, 0,
save_args, NULL);
......@@ -218,6 +219,8 @@ run (char *name,
GRunModeType run_mode;
GStatusType status = STATUS_SUCCESS;
gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
/* initialize */
......@@ -236,6 +239,25 @@ run (char *name,
values[1].type = PARAM_IMAGE;
values[1].data.d_image = -1;
/* eventually export the image */
switch (run_mode)
{
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "FITS",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
}
switch (run_mode)
{
case RUN_INTERACTIVE:
......@@ -279,6 +301,10 @@ run (char *name,
}
else if (strcmp (name, "file_fits_save") == 0)
{
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
*nreturn_vals = 1;
switch (run_mode)
{
case RUN_INTERACTIVE:
......@@ -297,12 +323,13 @@ run (char *name,
break;
}
*nreturn_vals = 1;
if (save_image (param[3].data.d_string, param[1].data.d_int32,
param[2].data.d_int32))
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
values[0].data.d_status = STATUS_SUCCESS;
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
}
......@@ -941,6 +968,21 @@ save_index (FITS_FILE *ofp,
}
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("fits");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
/* Load interface functions */
static gint
......@@ -953,8 +995,7 @@ load_dialog (void)
GtkWidget *frame;
GtkWidget *toggle_vbox;
GSList *group;
gchar **argv;
gint argc, k, j;
gint k, j;
char **textptr;
static char *toggle_text[] = {
"BLANK/NaN pixel replacement", "Black", "White",
......@@ -962,13 +1003,8 @@ load_dialog (void)
"Image composing", "None", "NAXIS=3, NAXIS3=2,...,4"
};
init_gtk ();
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("Load");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
vals = g_malloc (sizeof (*vals));
vals->toggle_val[0] = (plvals.replace == 0);
......@@ -1105,12 +1141,8 @@ static void show_fits_errors (void)
static void show_message (char *message)
{
#ifdef Simple_Message_Box_Available
/* If there would be a simple message box like the one */
/* used in ../app/interface.h, I would like to use it. */
if (l_run_mode == RUN_INTERACTIVE)
gtk_message_box (message);
gimp_message (message);
else
#endif
fprintf (stderr, "Fits: %s\n", message);
}
......@@ -16,6 +16,7 @@ INCLUDES = \
LDADD = \
$(top_builddir)/libgimp/libgimp.la \
$(top_builddir)/libgimp/libgimpui.la \
$(GTK_LIBS) \
$(INTLLIBS)
......
......@@ -34,6 +34,12 @@
* Revision History:
*
* $Log$
* Revision 1.13 1999/10/20 01:45:41 neo
* the rest of the save plug-ins !?
*
*
* --Sven
*
* Revision 1.12 1999/04/23 06:32:41 asbjoer
* use MAIN macro
*
......@@ -177,6 +183,7 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
/*
......@@ -190,14 +197,16 @@
* Local functions...
*/
static void query(void);
static void run(char *, int, GParam *, int *, GParam **);
static gint32 load_image(char *);
static gint save_image (char *, gint32, gint32);
static gint save_dialog(void);
static void save_close_callback(GtkWidget *, gpointer);
static void save_ok_callback(GtkWidget *, gpointer);
static void save_compression_callback(GtkWidget *, gpointer);
static void query (void);
static void run (char *, int, GParam *, int *, GParam **);
static gint32 load_image (char *);
static gint save_image (char *, gint32, gint32);
static void init_gtk (void);
static gint save_dialog (void);
static void save_close_callback (GtkWidget *, gpointer);
static void save_ok_callback (GtkWidget *, gpointer);
static void save_compression_callback (GtkWidget *, gpointer);
/*
......@@ -231,13 +240,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_STRING, "raw_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) / sizeof (load_return_vals[0]);
......@@ -280,14 +289,17 @@ query(void)
*/
static void
run(char *name, /* I - Name of filter program. */
int nparams, /* I - Number of parameters passed in */
GParam *param, /* I - Parameter values */
int *nreturn_vals, /* O - Number of return values */
GParam **return_vals) /* O - Return values */
run (char *name, /* I - Name of filter program. */
int nparams, /* I - Number of parameters passed in */
GParam *param, /* I - Parameter values */
int *nreturn_vals, /* O - Number of return values */
GParam **return_vals) /* O - Return values */
{
gint32 image_ID; /* ID of loaded image */
GParam *values; /* Return values */
GParam *values; /* Return values */
GRunModeType run_mode;
gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
/*
......@@ -322,8 +334,29 @@ run(char *name, /* I - Name of filter program. */
else if (strcmp (name, "file_sgi_save") == 0)
{
*nreturn_vals = 1;
switch (param[0].data.d_int32)
run_mode = param[0].data.d_int32;
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
/* eventually export the image */
switch (run_mode)
{
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "SGI",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_ALPHA));
if (export == EXPORT_CANCEL)
{
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
}
switch (run_mode)
{
case RUN_INTERACTIVE :
/*
......@@ -361,7 +394,7 @@ run(char *name, /* I - Name of filter program. */
* Possibly retrieve data...
*/
gimp_get_data("file_sgi_save", &compression);
gimp_get_data ("file_sgi_save", &compression);
break;
default :
......@@ -370,12 +403,14 @@ run(char *name, /* I - Name of filter program. */
if (values[0].data.d_status == STATUS_SUCCESS)
{
if (save_image(param[3].data.d_string, param[1].data.d_int32,
param[2].data.d_int32))
if (save_image(param[3].data.d_string, image_ID, drawable_ID))
gimp_set_data("file_sgi_save", &compression, sizeof(compression));
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
};
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
......@@ -387,7 +422,7 @@ run(char *name, /* I - Name of filter program. */
*/
static gint32
load_image(char *filename) /* I - File to load */
load_image (char *filename) /* I - File to load */
{
int i, /* Looping var */
x, /* Current X coordinate */
......@@ -573,26 +608,26 @@ load_image(char *filename) /* I - File to load */
*/
static gint
save_image(char *filename, /* I - File to save to */
gint32 image_ID, /* I - Image to save */
gint32 drawable_ID) /* I - Current drawable */
save_image (char *filename, /* I - File to save to */
gint32 image_ID, /* I - Image to save */
gint32 drawable_ID) /* I - Current drawable */
{
int i, j, /* Looping var */
x, /* Current X coordinate */
y, /* Current Y coordinate */
image_type, /* Type of image */
layer_type, /* Type of drawable/layer */
tile_height, /* Height of tile in GIMP */
count, /* Count of rows to put in image */
zsize; /* Number of channels in file */
sgi_t *sgip; /* File pointer */
GDrawable *drawable; /* Drawable for layer */
GPixelRgn pixel_rgn; /* Pixel region for layer */
guchar **pixels, /* Pixel rows */
*pixel, /* Pixel data */
*pptr; /* Current pixel */
unsigned short **rows; /* SGI image data */
char progress[255]; /* Title for progress display... */
int i, j, /* Looping var */
x, /* Current X coordinate */
y, /* Current Y coordinate */
image_type, /* Type of image */
layer_type, /* Type of drawable/layer */
tile_height, /* Height of tile in GIMP */
count, /* Count of rows to put in image */
zsize; /* Number of channels in file */
sgi_t *sgip; /* File pointer */
GDrawable *drawable; /* Drawable for layer */
GPixelRgn pixel_rgn; /* Pixel region for layer */
guchar **pixels, /* Pixel rows */
*pixel, /* Pixel data */
*pptr; /* Current pixel */
unsigned short **rows; /* SGI image data */
char progress[255]; /* Title for progress display... */
/*
......@@ -711,8 +746,8 @@ save_image(char *filename, /* I - File to save to */
*/
static void
save_close_callback(GtkWidget *w, /* I - Close button */
gpointer data) /* I - Callback data */
save_close_callback (GtkWidget *w, /* I - Close button */
gpointer data) /* I - Callback data */
{
gtk_main_quit();
}
......@@ -723,8 +758,8 @@ save_close_callback(GtkWidget *w, /* I - Close button */
*/
static void
save_ok_callback(GtkWidget *w, /* I - OK button */
gpointer data) /* I - Callback data */
save_ok_callback (GtkWidget *w, /* I - OK button */
gpointer data) /* I - Callback data */
{
runme = TRUE;
......@@ -737,14 +772,28 @@ save_ok_callback(GtkWidget *w, /* I - OK button */
*/
static void
save_compression_callback(GtkWidget *w, /* I - Compression button */
gpointer data) /* I - Callback data */
save_compression_callback (GtkWidget *w, /* I - Compression button */
gpointer data) /* I - Callback data */
{
if (GTK_TOGGLE_BUTTON(w)->active)
compression = (long)data;
}
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("sgi");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
/*
* 'save_dialog()' - Pop up the save dialog.
*/
......@@ -758,8 +807,6 @@ save_dialog(void)
*frame, /* Frame for dialog */
*vbox; /* Box for compression types */
GSList *group; /* Button grouping for compression */
gchar **argv; /* Fake command-line args */