mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
more export stuff
--Sven
This commit is contained in:
parent
29d5575655
commit
cdc3f6e779
25 changed files with 511 additions and 285 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
1999-10-04 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tool_options.c: backed out a change from last weekend that was
|
||||
never supposed to get into CVS
|
||||
|
||||
* libgimp/gimpexport.[ch]: added a third button.
|
||||
Now "Export" performs the conversion, "Ignore" skips it and continues
|
||||
and "Cancel" cancels the save.
|
||||
|
||||
* plug-ins/bmp/bmp.c
|
||||
* plug-ins/common/gif.c
|
||||
* plug-ins/common/jpeg.c
|
||||
* plug-ins/common/png.c
|
||||
* plug-ins/common/ps.c
|
||||
* plug-ins/common/tiff.c
|
||||
* plug-ins/print/print.c: sync with the new interface.
|
||||
|
||||
* plug-ins/common/Makefile.am
|
||||
* plug-ins/common/plugin-defs.pl
|
||||
* plug-ins/common/tga.c
|
||||
* plug-ins/common/xpm.c: two more save plug-ins that know about export.
|
||||
|
||||
* plug-ins/script-fu/script-fu.c: include script-fu-constants.h
|
||||
|
||||
1999-10-03 Olof S Kylander <olof@frozenriver.com>
|
||||
|
||||
* app/airbrush_blob.c
|
||||
|
|
|
@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
|
|||
case DODGEBURN:
|
||||
case SMUDGE:
|
||||
case ERASER:
|
||||
/* case PAINTBRUSH: */
|
||||
case PAINTBRUSH:
|
||||
pressure->pressure_w =
|
||||
gtk_check_button_new_with_label (_("Pressure"));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
|
||||
|
|
|
@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
|
|||
case DODGEBURN:
|
||||
case SMUDGE:
|
||||
case ERASER:
|
||||
/* case PAINTBRUSH: */
|
||||
case PAINTBRUSH:
|
||||
pressure->pressure_w =
|
||||
gtk_check_button_new_with_label (_("Pressure"));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
|
||||
|
|
|
@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
|
|||
case DODGEBURN:
|
||||
case SMUDGE:
|
||||
case ERASER:
|
||||
/* case PAINTBRUSH: */
|
||||
case PAINTBRUSH:
|
||||
pressure->pressure_w =
|
||||
gtk_check_button_new_with_label (_("Pressure"));
|
||||
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
|
||||
|
|
|
@ -167,22 +167,30 @@ static ExportAction export_action_convert_indexed_or_grayscale =
|
|||
|
||||
/* dialog functions */
|
||||
|
||||
static GtkWidget *dialog = NULL;
|
||||
static gboolean dialog_return = FALSE;
|
||||
static GtkWidget *dialog = NULL;
|
||||
static GimpExportReturnType dialog_return = EXPORT_CANCEL;
|
||||
|
||||
static void
|
||||
export_export_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (dialog);
|
||||
dialog_return = TRUE;
|
||||
dialog_return = EXPORT_EXPORT;
|
||||
}
|
||||
|
||||
static void
|
||||
export_skip_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (dialog);
|
||||
dialog_return = EXPORT_IGNORE;
|
||||
}
|
||||
|
||||
static void
|
||||
export_cancel_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
dialog_return = FALSE;
|
||||
dialog_return = EXPORT_CANCEL;
|
||||
dialog = NULL;
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
@ -212,8 +220,8 @@ export_dialog (GList *actions,
|
|||
gchar *text;
|
||||
ExportAction *action;
|
||||
|
||||
dialog_return = FALSE;
|
||||
g_return_val_if_fail (actions != NULL && format != NULL, FALSE);
|
||||
dialog_return = EXPORT_CANCEL;
|
||||
g_return_val_if_fail (actions != NULL && format != NULL, dialog_return);
|
||||
|
||||
/*
|
||||
* Plug-ins have called gtk_init () before calling gimp_export ().
|
||||
|
@ -246,6 +254,13 @@ export_dialog (GList *actions,
|
|||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("Ignore"));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) export_skip_callback, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
|
@ -314,7 +329,7 @@ export_dialog (GList *actions,
|
|||
}
|
||||
|
||||
/* the footline */
|
||||
label = gtk_label_new (_("The export conversion won't modify your image."));
|
||||
label = gtk_label_new (_("The export conversion won't modify your original image."));
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
|
||||
gtk_widget_show (label);
|
||||
|
||||
|
@ -325,7 +340,7 @@ export_dialog (GList *actions,
|
|||
}
|
||||
|
||||
|
||||
gboolean
|
||||
GimpExportReturnType
|
||||
gimp_export_image (gint32 *image_ID_ptr,
|
||||
gint32 *drawable_ID_ptr,
|
||||
gchar *format,
|
||||
|
@ -403,7 +418,7 @@ gimp_export_image (gint32 *image_ID_ptr,
|
|||
if (actions)
|
||||
dialog_return = export_dialog (actions, format);
|
||||
|
||||
if (dialog_return)
|
||||
if (dialog_return == EXPORT_EXPORT)
|
||||
{
|
||||
*image_ID_ptr = gimp_image_duplicate (*image_ID_ptr);
|
||||
*drawable_ID_ptr = gimp_image_get_active_layer (*image_ID_ptr);
|
||||
|
@ -416,10 +431,9 @@ gimp_export_image (gint32 *image_ID_ptr,
|
|||
else if (action->choice == 1 && action->alt_action)
|
||||
action->alt_action (*image_ID_ptr, drawable_ID_ptr);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
return (dialog_return);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,13 +29,17 @@
|
|||
#define CAN_HANDLE_LAYERS 1 << 4
|
||||
#define CAN_HANDLE_LAYERS_AS_ANIMATION 1 << 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EXPORT_CANCEL,
|
||||
EXPORT_IGNORE,
|
||||
EXPORT_EXPORT
|
||||
} GimpExportReturnType;
|
||||
|
||||
gboolean gimp_export_image (gint32*, /* image_ID */
|
||||
gint32*, /* drawable_ID */
|
||||
gchar*, /* format name */
|
||||
gint); /* plug_in_capabilities */
|
||||
|
||||
|
||||
GimpExportReturnType gimp_export_image (gint32*, /* image_ID */
|
||||
gint32*, /* drawable_ID */
|
||||
gchar*, /* format name */
|
||||
gint); /* plug_in_capabilities */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ run (char *name,
|
|||
GRunModeType run_mode;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -202,6 +202,12 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
|
||||
(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;
|
||||
|
@ -236,7 +242,7 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -999,6 +999,7 @@ tga_SOURCES = \
|
|||
tga.c
|
||||
|
||||
tga_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(GTK_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
@ -1131,6 +1132,7 @@ xpm_SOURCES = \
|
|||
xpm.c
|
||||
|
||||
xpm_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(LIBXPM) \
|
||||
$(GTK_LIBS) \
|
||||
|
|
|
@ -420,7 +420,7 @@ run (char *name,
|
|||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
gint32 orig_image_ID;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -445,6 +445,12 @@ run (char *name,
|
|||
export = gimp_export_image (&image_ID, &drawable_ID, "GIF",
|
||||
(CAN_HANDLE_INDEXED | CAN_HANDLE_GRAY |
|
||||
CAN_HANDLE_ALPHA | CAN_HANDLE_LAYERS_AS_ANIMATION));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -527,7 +533,7 @@ run (char *name,
|
|||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
'spheredesigner' => { libdep => 'gtk' },
|
||||
'spread' => { libdep => 'gtk' },
|
||||
'sunras' => { libdep => 'gtk' },
|
||||
'tga' => { libdep => 'gtk' },
|
||||
'tga' => { libdep => 'gtk', ui => 1 },
|
||||
'threshold_alpha' => { libdep => 'gtk' },
|
||||
'tiff' => { libdep => 'gtk', ui => 1, optional => 1 },
|
||||
'tile' => { libdep => 'gtk' },
|
||||
|
@ -117,7 +117,7 @@
|
|||
'wind' => { libdep => 'gtk' },
|
||||
'wmf' => { libdep => 'gtk' },
|
||||
'xbm' => { libdep => 'gtk' },
|
||||
'xpm' => { libdep => 'gtk', optional => 1 },
|
||||
'xpm' => { libdep => 'gtk', ui => 1, optional => 1 },
|
||||
'xwd' => { libdep => 'glib' },
|
||||
'zealouscrop' => { libdep => 'glib' }
|
||||
);
|
||||
|
|
|
@ -185,8 +185,7 @@ run (char *name, /* I - Name of filter program. */
|
|||
gint32 orig_image_ID;
|
||||
GRunModeType run_mode;
|
||||
GParam *values; /* Return values */
|
||||
gboolean export = FALSE;
|
||||
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
/*
|
||||
* Initialize parameter data...
|
||||
|
@ -236,6 +235,12 @@ run (char *name, /* I - Name of filter program. */
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PNG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -298,7 +303,7 @@ run (char *name, /* I - Name of filter program. */
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
* Ghostview may hang when displaying the files.
|
||||
* V 1.07, PK, 14-Sep-99: Add resolution to image
|
||||
*/
|
||||
#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";
|
||||
#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 <stdio.h>
|
||||
|
@ -409,7 +409,7 @@ run (char *name,
|
|||
gint32 image_ID = -1;
|
||||
gint32 drawable_ID = -1;
|
||||
gint32 orig_image_ID = -1;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
int k;
|
||||
|
||||
l_run_mode = run_mode = param[0].data.d_int32;
|
||||
|
@ -481,6 +481,12 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
(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;
|
||||
|
@ -543,17 +549,17 @@ run (char *name,
|
|||
#endif
|
||||
check_save_vals ();
|
||||
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
|
||||
{
|
||||
/* Store psvals data */
|
||||
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
|
||||
}
|
||||
{
|
||||
/* Store psvals data */
|
||||
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
|
||||
}
|
||||
else
|
||||
{
|
||||
status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
|
||||
values[0].data.d_status = status;
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
* Ghostview may hang when displaying the files.
|
||||
* V 1.07, PK, 14-Sep-99: Add resolution to image
|
||||
*/
|
||||
#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";
|
||||
#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 <stdio.h>
|
||||
|
@ -409,7 +409,7 @@ run (char *name,
|
|||
gint32 image_ID = -1;
|
||||
gint32 drawable_ID = -1;
|
||||
gint32 orig_image_ID = -1;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
int k;
|
||||
|
||||
l_run_mode = run_mode = param[0].data.d_int32;
|
||||
|
@ -481,6 +481,12 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
(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;
|
||||
|
@ -543,17 +549,17 @@ run (char *name,
|
|||
#endif
|
||||
check_save_vals ();
|
||||
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
|
||||
{
|
||||
/* Store psvals data */
|
||||
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
|
||||
}
|
||||
{
|
||||
/* Store psvals data */
|
||||
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
|
||||
}
|
||||
else
|
||||
{
|
||||
status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
|
||||
values[0].data.d_status = status;
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
|
||||
/* Round up a division to the nearest integer. */
|
||||
#define ROUNDUP_DIVIDE(n,d) (((n) + (d - 1)) / (d))
|
||||
|
@ -112,12 +113,12 @@ struct tga_header
|
|||
guint8 colorMapType;
|
||||
|
||||
/* The image type. */
|
||||
#define TGA_TYPE_MAPPED 1
|
||||
#define TGA_TYPE_COLOR 2
|
||||
#define TGA_TYPE_GRAY 3
|
||||
#define TGA_TYPE_MAPPED_RLE 9
|
||||
#define TGA_TYPE_COLOR_RLE 10
|
||||
#define TGA_TYPE_GRAY_RLE 11
|
||||
#define TGA_TYPE_MAPPED 1
|
||||
#define TGA_TYPE_COLOR 2
|
||||
#define TGA_TYPE_GRAY 3
|
||||
#define TGA_TYPE_MAPPED_RLE 9
|
||||
#define TGA_TYPE_COLOR_RLE 10
|
||||
#define TGA_TYPE_GRAY_RLE 11
|
||||
guint8 imageType;
|
||||
|
||||
/* Color Map Specification. */
|
||||
|
@ -142,9 +143,9 @@ struct tga_header
|
|||
5: top-to-bottom ordering
|
||||
7-6: zero
|
||||
*/
|
||||
#define TGA_DESC_ABITS 0x0f
|
||||
#define TGA_DESC_ABITS 0x0f
|
||||
#define TGA_DESC_HORIZONTAL 0x10
|
||||
#define TGA_DESC_VERTICAL 0x20
|
||||
#define TGA_DESC_VERTICAL 0x20
|
||||
guint8 descriptor;
|
||||
};
|
||||
|
||||
|
@ -161,19 +162,20 @@ static 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 gint32 load_image (char *filename);
|
||||
static gint save_image (char *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID);
|
||||
static void query (void);
|
||||
static void run (char *name,
|
||||
int nparams,
|
||||
GParam *param,
|
||||
int *nreturn_vals,
|
||||
GParam **return_vals);
|
||||
|
||||
static gint save_dialog ();
|
||||
static gint32 load_image (char *filename);
|
||||
static gint save_image (char *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID);
|
||||
|
||||
static void init_gtk (void);
|
||||
static gint save_dialog (void);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
|
@ -266,6 +268,8 @@ run (char *name,
|
|||
GStatusType status = STATUS_SUCCESS;
|
||||
GRunModeType run_mode;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
#ifdef PROFILE
|
||||
struct tms tbuf1, tbuf2;
|
||||
|
@ -304,6 +308,30 @@ run (char *name,
|
|||
}
|
||||
else if (strcmp (name, "file_tga_save") == 0)
|
||||
{
|
||||
init_gtk ();
|
||||
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[1].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "TGA",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
|
||||
CAN_HANDLE_ALPHA));
|
||||
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:
|
||||
|
@ -339,7 +367,7 @@ run (char *name,
|
|||
times (&tbuf1);
|
||||
#endif
|
||||
*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))
|
||||
{
|
||||
/* Store psvals data */
|
||||
gimp_set_data ("file_tga_save", &tsvals, sizeof (tsvals));
|
||||
|
@ -348,6 +376,9 @@ run (char *name,
|
|||
}
|
||||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
|
@ -424,7 +455,10 @@ static int totbytes = 0;
|
|||
#endif
|
||||
|
||||
static int
|
||||
std_fread (guchar *buf, int datasize, int nelems, FILE *fp)
|
||||
std_fread (guchar *buf,
|
||||
int datasize,
|
||||
int nelems,
|
||||
FILE *fp)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
if (verbose > 1)
|
||||
|
@ -439,7 +473,10 @@ std_fread (guchar *buf, int datasize, int nelems, FILE *fp)
|
|||
}
|
||||
|
||||
static int
|
||||
std_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
|
||||
std_fwrite (guchar *buf,
|
||||
int datasize,
|
||||
int nelems,
|
||||
FILE *fp)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
if (verbose > 1)
|
||||
|
@ -457,7 +494,10 @@ std_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
|
|||
|
||||
/* Decode a bufferful of file. */
|
||||
static int
|
||||
rle_fread (guchar *buf, int datasize, int nelems, FILE *fp)
|
||||
rle_fread (guchar *buf,
|
||||
int datasize,
|
||||
int nelems,
|
||||
FILE *fp)
|
||||
{
|
||||
static guchar *statebuf = 0;
|
||||
static int statelen = 0;
|
||||
|
@ -597,7 +637,10 @@ rle_fread (guchar *buf, int datasize, int nelems, FILE *fp)
|
|||
loading performance than whole-stream images. */
|
||||
/* RunLength Encode a bufferful of file. */
|
||||
static int
|
||||
rle_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
|
||||
rle_fwrite (guchar *buf,
|
||||
int datasize,
|
||||
int nelems,
|
||||
FILE *fp)
|
||||
{
|
||||
/* Now runlength-encode the whole buffer. */
|
||||
int count, j, buflen;
|
||||
|
@ -713,7 +756,9 @@ rle_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
|
|||
|
||||
|
||||
static gint32
|
||||
ReadImage (FILE *fp, struct tga_header *hdr, char *filename)
|
||||
ReadImage (FILE *fp,
|
||||
struct tga_header *hdr,
|
||||
char *filename)
|
||||
{
|
||||
static gint32 image_ID;
|
||||
gint32 layer_ID;
|
||||
|
@ -1367,6 +1412,19 @@ save_image (char *filename,
|
|||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
init_gtk ()
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("tga");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
static gint
|
||||
save_dialog ()
|
||||
|
@ -1376,15 +1434,6 @@ save_dialog ()
|
|||
GtkWidget *toggle;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
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 Tga");
|
||||
|
|
|
@ -210,7 +210,7 @@ run (char *name,
|
|||
gint32 image;
|
||||
gint32 drawable;
|
||||
gint32 orig_image;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -250,7 +250,14 @@ run (char *name,
|
|||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image, &drawable, "TIFF",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA));
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
|
||||
CAN_HANDLE_ALPHA));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -332,7 +339,7 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ Previous...Inherited code from Ray Lehtiniemi, who inherited it from S & P.
|
|||
#include <X11/xpm.h>
|
||||
#include "gtk/gtk.h"
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
static const char linenoise [] =
|
||||
|
@ -60,9 +61,9 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
guchar r;
|
||||
guchar g;
|
||||
guchar b;
|
||||
guchar r;
|
||||
guchar g;
|
||||
guchar b;
|
||||
} rgbkey;
|
||||
|
||||
/* whether the image is color or not. global so I only have to pass one user value
|
||||
|
@ -73,46 +74,31 @@ to the GHFunc */
|
|||
int cpp;
|
||||
|
||||
/* Declare local functions */
|
||||
static void query (void);
|
||||
static void run (char *name,
|
||||
int nparams,
|
||||
GParam *param,
|
||||
int *nreturn_vals,
|
||||
GParam **return_vals);
|
||||
static void query (void);
|
||||
static void run (char *name,
|
||||
int nparams,
|
||||
GParam *param,
|
||||
int *nreturn_vals,
|
||||
GParam **return_vals);
|
||||
|
||||
static gint32
|
||||
load_image (char *filename);
|
||||
|
||||
static void
|
||||
parse_colors (XpmImage *xpm_image,
|
||||
guchar **cmap);
|
||||
|
||||
static void
|
||||
parse_image (gint32 image_ID,
|
||||
XpmImage *xpm_image,
|
||||
guchar *cmap);
|
||||
|
||||
static gint
|
||||
save_image (char *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID);
|
||||
|
||||
|
||||
static gint
|
||||
save_dialog ();
|
||||
|
||||
static void
|
||||
save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void
|
||||
save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void
|
||||
save_scale_update (GtkAdjustment *adjustment,
|
||||
double *scale_val);
|
||||
static gint32 load_image (char *filename);
|
||||
static void parse_colors (XpmImage *xpm_image,
|
||||
guchar **cmap);
|
||||
static void parse_image (gint32 image_ID,
|
||||
XpmImage *xpm_image,
|
||||
guchar *cmap);
|
||||
static gint save_image (char *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID);
|
||||
|
||||
static void init_gtk (void);
|
||||
static gint save_dialog (void);
|
||||
static void save_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void save_scale_update (GtkAdjustment *adjustment,
|
||||
double *scale_val);
|
||||
|
||||
|
||||
|
||||
|
@ -143,24 +129,24 @@ query ()
|
|||
{
|
||||
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 entered" },
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name entered" },
|
||||
};
|
||||
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_args = sizeof (load_args) / sizeof (load_args[0]);
|
||||
static int nload_return_vals = sizeof (load_return_vals) / sizeof (load_return_vals[0]);
|
||||
|
||||
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]);
|
||||
|
||||
|
@ -191,8 +177,8 @@ query ()
|
|||
save_args, NULL);
|
||||
|
||||
gimp_register_magic_load_handler ("file_xpm_load", "xpm", "<Load>/Xpm",
|
||||
"0,string,/* XPM */");
|
||||
gimp_register_save_handler ("file_xpm_save", "xpm", "<Save>/Xpm");
|
||||
"0, string, /* XPM */");
|
||||
gimp_register_save_handler ("file_xpm_save", "xpm", "<Save>/Xpm");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -205,6 +191,8 @@ run (char *name,
|
|||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
@ -235,6 +223,30 @@ run (char *name,
|
|||
}
|
||||
else if (strcmp (name, "file_xpm_save") == 0)
|
||||
{
|
||||
init_gtk ();
|
||||
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[1].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "XPM",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
|
||||
CAN_HANDLE_ALPHA));
|
||||
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:
|
||||
|
@ -242,9 +254,9 @@ run (char *name,
|
|||
gimp_get_data ("file_xpm_save", &xpmvals);
|
||||
|
||||
/* First acquire information with a dialog */
|
||||
if (gimp_drawable_has_alpha(param[2].data.d_int32))
|
||||
if (! save_dialog ())
|
||||
return;
|
||||
if (gimp_drawable_has_alpha (drawable_ID))
|
||||
if (! save_dialog ())
|
||||
return;
|
||||
break;
|
||||
|
||||
case RUN_NONINTERACTIVE:
|
||||
|
@ -269,14 +281,17 @@ run (char *name,
|
|||
}
|
||||
*nreturn_vals = 1;
|
||||
if (save_image (param[3].data.d_string,
|
||||
param[1].data.d_int32,
|
||||
param[2].data.d_int32))
|
||||
image_ID,
|
||||
drawable_ID))
|
||||
{
|
||||
gimp_set_data ("file_xpm_save", &xpmvals, sizeof (XpmSaveVals));
|
||||
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);
|
||||
}
|
||||
else
|
||||
g_assert (FALSE);
|
||||
|
@ -330,7 +345,8 @@ load_image (char *filename)
|
|||
|
||||
|
||||
static void
|
||||
parse_colors (XpmImage *xpm_image, guchar **cmap)
|
||||
parse_colors (XpmImage *xpm_image,
|
||||
guchar **cmap)
|
||||
{
|
||||
Display *display;
|
||||
Colormap colormap;
|
||||
|
@ -388,7 +404,9 @@ parse_colors (XpmImage *xpm_image, guchar **cmap)
|
|||
|
||||
|
||||
static void
|
||||
parse_image(gint32 image_ID, XpmImage *xpm_image, guchar *cmap)
|
||||
parse_image (gint32 image_ID,
|
||||
XpmImage *xpm_image,
|
||||
guchar *cmap)
|
||||
{
|
||||
int tile_height;
|
||||
int scanlines;
|
||||
|
@ -464,13 +482,16 @@ guint rgbhash (rgbkey *c)
|
|||
return ((guint)c->r) ^ ((guint)c->g) ^ ((guint)c->b);
|
||||
}
|
||||
|
||||
guint compare (rgbkey *c1, rgbkey *c2)
|
||||
guint compare (rgbkey *c1,
|
||||
rgbkey *c2)
|
||||
{
|
||||
return (c1->r == c2->r)&&(c1->g == c2->g)&&(c1->b == c2->b);
|
||||
}
|
||||
|
||||
|
||||
void set_XpmImage(XpmColor *array, guint index, char *colorstring)
|
||||
void set_XpmImage (XpmColor *array,
|
||||
guint index,
|
||||
char *colorstring)
|
||||
{
|
||||
char *p;
|
||||
int i, charnum, indtemp;
|
||||
|
@ -503,8 +524,9 @@ void set_XpmImage(XpmColor *array, guint index, char *colorstring)
|
|||
}
|
||||
}
|
||||
|
||||
void create_colormap_from_hash (gpointer gkey, gpointer value, gpointer
|
||||
user_data)
|
||||
void create_colormap_from_hash (gpointer gkey,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
rgbkey *key = gkey;
|
||||
char *string = g_new(char, 8);
|
||||
|
@ -543,50 +565,53 @@ save_image (char *filename,
|
|||
gint rc = FALSE;
|
||||
|
||||
/* get some basic stats about the image */
|
||||
switch (gimp_drawable_type (drawable_ID)) {
|
||||
case RGBA_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
case GRAYA_IMAGE:
|
||||
alpha = 1;
|
||||
break;
|
||||
case RGB_IMAGE:
|
||||
case INDEXED_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
alpha = 0;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
switch (gimp_drawable_type (drawable_ID))
|
||||
{
|
||||
case RGBA_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
case GRAYA_IMAGE:
|
||||
alpha = 1;
|
||||
break;
|
||||
case RGB_IMAGE:
|
||||
case INDEXED_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
alpha = 0;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (gimp_drawable_type (drawable_ID)) {
|
||||
case GRAYA_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
color = 0;
|
||||
break;
|
||||
case RGBA_IMAGE:
|
||||
case RGB_IMAGE:
|
||||
case INDEXED_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
switch (gimp_drawable_type (drawable_ID))
|
||||
{
|
||||
case GRAYA_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
color = 0;
|
||||
break;
|
||||
case RGBA_IMAGE:
|
||||
case RGB_IMAGE:
|
||||
case INDEXED_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
color = 1;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (gimp_drawable_type (drawable_ID)) {
|
||||
case GRAYA_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
case RGBA_IMAGE:
|
||||
case RGB_IMAGE:
|
||||
indexed = 0;
|
||||
break;
|
||||
case INDEXED_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
indexed = 1;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
switch (gimp_drawable_type (drawable_ID))
|
||||
{
|
||||
case GRAYA_IMAGE:
|
||||
case GRAY_IMAGE:
|
||||
case RGBA_IMAGE:
|
||||
case RGB_IMAGE:
|
||||
indexed = 0;
|
||||
break;
|
||||
case INDEXED_IMAGE:
|
||||
case INDEXEDA_IMAGE:
|
||||
indexed = 1;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
drawable = gimp_drawable_get (drawable_ID);
|
||||
width = drawable->width;
|
||||
|
@ -672,37 +697,38 @@ save_image (char *filename,
|
|||
gimp_progress_update ((double) (i+j) / (double) height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
g_free(buffer);
|
||||
|
||||
if (indexed)
|
||||
{
|
||||
guchar *cmap;
|
||||
cmap = gimp_image_get_cmap(image_ID, &ncolors);
|
||||
ncolors++; /* for transparency */
|
||||
colormap = g_new(XpmColor, ncolors);
|
||||
cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0);
|
||||
set_XpmImage(colormap, 0, "None");
|
||||
for (i=0; i<ncolors-1; i++)
|
||||
{
|
||||
char *string;
|
||||
guchar r, g, b;
|
||||
r = *(cmap++);
|
||||
g = *(cmap++);
|
||||
b = *(cmap++);
|
||||
string = g_new(char, 8);
|
||||
sprintf(string, "#%02X%02X%02X", (int)r, (int)g, (int)b);
|
||||
set_XpmImage(colormap, i+1, string);
|
||||
}
|
||||
}else
|
||||
{
|
||||
colormap = g_new(XpmColor, ncolors);
|
||||
{
|
||||
guchar *cmap;
|
||||
cmap = gimp_image_get_cmap(image_ID, &ncolors);
|
||||
ncolors++; /* for transparency */
|
||||
colormap = g_new(XpmColor, ncolors);
|
||||
cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0);
|
||||
set_XpmImage(colormap, 0, "None");
|
||||
for (i=0; i<ncolors-1; i++)
|
||||
{
|
||||
char *string;
|
||||
guchar r, g, b;
|
||||
r = *(cmap++);
|
||||
g = *(cmap++);
|
||||
b = *(cmap++);
|
||||
string = g_new(char, 8);
|
||||
sprintf(string, "#%02X%02X%02X", (int)r, (int)g, (int)b);
|
||||
set_XpmImage(colormap, i+1, string);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colormap = g_new(XpmColor, ncolors);
|
||||
|
||||
cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0);
|
||||
set_XpmImage(colormap, 0, "None");
|
||||
cpp = (double)1.0 + (double)log (ncolors) / (double)log (sizeof (linenoise) - 1.0);
|
||||
set_XpmImage (colormap, 0, "None");
|
||||
|
||||
g_hash_table_foreach (hash, create_colormap_from_hash, colormap);
|
||||
}
|
||||
g_hash_table_foreach (hash, create_colormap_from_hash, colormap);
|
||||
}
|
||||
|
||||
image = g_new(XpmImage, 1);
|
||||
|
||||
|
@ -713,17 +739,14 @@ save_image (char *filename,
|
|||
image->colorTable=colormap;
|
||||
image->data = ibuff;
|
||||
|
||||
/* do the save */
|
||||
XpmWriteFileFromXpmImage(filename, image, NULL);
|
||||
rc = TRUE;
|
||||
|
||||
/* do the save */
|
||||
XpmWriteFileFromXpmImage(filename, image, NULL);
|
||||
rc = TRUE;
|
||||
|
||||
cleanup:
|
||||
|
||||
/* clean up resources */
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
||||
if (ibuff) g_free(ibuff);
|
||||
/*if (mbuff) g_free(mbuff);*/
|
||||
if (hash) g_hash_table_destroy(hash);
|
||||
|
@ -731,6 +754,19 @@ save_image (char *filename,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
init_gtk ()
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("xpm");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
static gint
|
||||
save_dialog ()
|
||||
|
@ -742,15 +778,6 @@ save_dialog ()
|
|||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkObject *scale_data;
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
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 Xpm"));
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -357,7 +357,7 @@ run (char *name,
|
|||
Parasite *parasite;
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
int err;
|
||||
gboolean export = FALSE;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
|
@ -399,10 +399,19 @@ run (char *name,
|
|||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
|
||||
if (export)
|
||||
switch (export)
|
||||
{
|
||||
case EXPORT_EXPORT:
|
||||
display_ID = gimp_display_new (image_ID);
|
||||
gimp_displays_flush ();
|
||||
break;
|
||||
case EXPORT_IGNORE:
|
||||
break;
|
||||
case EXPORT_CANCEL:
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -475,7 +484,7 @@ run (char *name,
|
|||
/* First acquire information with a dialog */
|
||||
err = save_dialog ();
|
||||
|
||||
if (!export)
|
||||
if (export != EXPORT_EXPORT)
|
||||
{
|
||||
/* thaw undo saving and end the undo_group. */
|
||||
gimp_image_thaw_undo (image_ID);
|
||||
|
@ -565,10 +574,10 @@ run (char *name,
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
{
|
||||
/* if the image was exported, delete the new display */
|
||||
/* according to the documentation, this should also delete the image */
|
||||
/* If the image was exported, delete the new display. */
|
||||
/* This also deletes the image. */
|
||||
|
||||
if (display_ID > -1)
|
||||
gimp_display_delete (display_ID);
|
||||
|
@ -591,7 +600,7 @@ run (char *name,
|
|||
image_comment);
|
||||
gimp_image_attach_parasite (orig_image_ID, parasite);
|
||||
parasite_free (parasite);
|
||||
}
|
||||
}
|
||||
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
|
||||
|
||||
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
|
||||
|
|
|
@ -394,7 +394,7 @@ run(char *name, /* I - Name of print program. */
|
|||
#endif
|
||||
gint32 image_ID; /* image ID */
|
||||
gint32 drawable_ID; /* drawable ID */
|
||||
gboolean export; /* have we exported the image ? */
|
||||
GimpExportReturnType export = EXPORT_CANCEL; /* return value of gimp_export_image() */
|
||||
|
||||
INIT_I18N_UI();
|
||||
|
||||
|
@ -424,6 +424,12 @@ run(char *name, /* I - Name of print program. */
|
|||
export = gimp_export_image (&image_ID, &drawable_ID, "Print",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
|
||||
CAN_HANDLE_ALPHA));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -643,7 +649,7 @@ run(char *name, /* I - Name of print program. */
|
|||
|
||||
gimp_drawable_detach(drawable);
|
||||
|
||||
if (export)
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "siod.h"
|
||||
#include "script-fu-console.h"
|
||||
#include "script-fu-constants.h"
|
||||
#include "script-fu-scripts.h"
|
||||
#include "script-fu-server.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue