mirror of https://github.com/GNOME/gimp.git
plug-ins: port file-xbm to GimpPlugIn and libgimp objects
This commit is contained in:
parent
e1c2150f64
commit
9f3bc2bd7a
|
@ -1163,8 +1163,6 @@ file_wmf_LDADD = \
|
|||
$(INTLLIBS) \
|
||||
$(file_wmf_RC)
|
||||
|
||||
file_xbm_CPPFLAGS = $(AM_CPPFLAGS) -DGIMP_DEPRECATED_REPLACE_NEW_API
|
||||
|
||||
file_xbm_SOURCES = \
|
||||
file-xbm.c
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#define PLUG_IN_BINARY "file-xbm"
|
||||
#define PLUG_IN_ROLE "gimp-file-xbm"
|
||||
|
||||
|
||||
/* Wear your GIMP with pride! */
|
||||
#define DEFAULT_USE_COMMENT TRUE
|
||||
#define MAX_COMMENT 72
|
||||
|
@ -67,6 +66,7 @@
|
|||
/* Whether or not to export as X10 bitmap. */
|
||||
#define DEFAULT_X10_FORMAT FALSE
|
||||
|
||||
|
||||
typedef struct _XBMSaveVals
|
||||
{
|
||||
gchar comment[MAX_COMMENT + 1];
|
||||
|
@ -79,38 +79,53 @@ typedef struct _XBMSaveVals
|
|||
gchar mask_ext[MAX_MASK_EXT + 1];
|
||||
} XBMSaveVals;
|
||||
|
||||
static XBMSaveVals xsvals =
|
||||
|
||||
typedef struct _Xbm Xbm;
|
||||
typedef struct _XbmClass XbmClass;
|
||||
|
||||
struct _Xbm
|
||||
{
|
||||
"###", /* comment */
|
||||
DEFAULT_X10_FORMAT, /* x10_format */
|
||||
FALSE,
|
||||
0, /* x_hot */
|
||||
0, /* y_hot */
|
||||
DEFAULT_PREFIX, /* prefix */
|
||||
FALSE, /* write_mask */
|
||||
"-mask"
|
||||
GimpPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _XbmClass
|
||||
{
|
||||
GimpPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Declare some local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
static void run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
#define XBM_TYPE (xbm_get_type ())
|
||||
#define XBM (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XBM_TYPE, Xbm))
|
||||
|
||||
static gint32 load_image (const gchar *filename,
|
||||
GType xbm_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * xbm_query_procedures (GimpPlugIn *plug_in);
|
||||
static GimpProcedure * xbm_create_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static GimpValueArray * xbm_load (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GFile *file,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data);
|
||||
static GimpValueArray * xbm_save (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GFile *file,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
static GimpImage * load_image (const gchar *filename,
|
||||
GError **error);
|
||||
static gint save_image (GFile *file,
|
||||
static gboolean save_image (GFile *file,
|
||||
const gchar *prefix,
|
||||
const gchar *comment,
|
||||
gboolean save_mask,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GError **error);
|
||||
static gboolean save_dialog (gint32 drawable_ID);
|
||||
static gboolean save_dialog (GimpDrawable *drawable);
|
||||
|
||||
static gboolean print (GOutputStream *output,
|
||||
GError **error,
|
||||
|
@ -128,15 +143,22 @@ static void mask_ext_entry_callback (GtkWidget *widget,
|
|||
gpointer data);
|
||||
|
||||
|
||||
const GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
NULL, /* quit_proc */
|
||||
query, /* query_proc */
|
||||
run, /* run_proc */
|
||||
};
|
||||
G_DEFINE_TYPE (Xbm, xbm, GIMP_TYPE_PLUG_IN)
|
||||
|
||||
MAIN ()
|
||||
GIMP_MAIN (XBM_TYPE)
|
||||
|
||||
|
||||
static XBMSaveVals xsvals =
|
||||
{
|
||||
"###", /* comment */
|
||||
DEFAULT_X10_FORMAT, /* x10_format */
|
||||
FALSE,
|
||||
0, /* x_hot */
|
||||
0, /* y_hot */
|
||||
DEFAULT_PREFIX, /* prefix */
|
||||
FALSE, /* write_mask */
|
||||
"-mask"
|
||||
};
|
||||
|
||||
#ifdef VERBOSE
|
||||
static int verbose = VERBOSE;
|
||||
|
@ -144,69 +166,163 @@ static int verbose = VERBOSE;
|
|||
|
||||
|
||||
static void
|
||||
query (void)
|
||||
xbm_class_init (XbmClass *klass)
|
||||
{
|
||||
static const GimpParamDef load_args[] =
|
||||
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->query_procedures = xbm_query_procedures;
|
||||
plug_in_class->create_procedure = xbm_create_procedure;
|
||||
}
|
||||
|
||||
static void
|
||||
xbm_init (Xbm *xbm)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
xbm_query_procedures (GimpPlugIn *plug_in)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
list = g_list_append (list, g_strdup (LOAD_PROC));
|
||||
list = g_list_append (list, g_strdup (SAVE_PROC));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static GimpProcedure *
|
||||
xbm_create_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpProcedure *procedure = NULL;
|
||||
|
||||
if (! strcmp (name, LOAD_PROC))
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
||||
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
|
||||
{ GIMP_PDB_STRING, "raw-filename", "The name entered" }
|
||||
};
|
||||
procedure = gimp_load_procedure_new (plug_in, name, GIMP_PLUGIN,
|
||||
xbm_load, NULL, NULL);
|
||||
|
||||
static const GimpParamDef load_return_vals[] =
|
||||
gimp_procedure_set_menu_label (procedure, N_("X BitMap image"));
|
||||
|
||||
gimp_procedure_set_documentation (procedure,
|
||||
"Load a file in X10 or X11 bitmap "
|
||||
"(XBM) file format",
|
||||
"Load a file in X10 or X11 bitmap "
|
||||
"(XBM) file format. XBM is a lossless "
|
||||
"format for flat black-and-white "
|
||||
"(two color indexed) images.",
|
||||
name);
|
||||
gimp_procedure_set_attribution (procedure,
|
||||
"Gordon Matzigkeit",
|
||||
"Gordon Matzigkeit",
|
||||
"1998");
|
||||
|
||||
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
||||
"image/x-xbitmap");
|
||||
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
||||
"xbm,icon,bitmap");
|
||||
}
|
||||
else if (! strcmp (name, SAVE_PROC))
|
||||
{
|
||||
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
||||
};
|
||||
procedure = gimp_save_procedure_new (plug_in, name, GIMP_PLUGIN,
|
||||
xbm_save, NULL, NULL);
|
||||
|
||||
static const GimpParamDef save_args[] =
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to export" },
|
||||
{ GIMP_PDB_STRING, "filename", "The name of the file to export" },
|
||||
{ GIMP_PDB_STRING, "raw-filename", "The name entered" },
|
||||
{ GIMP_PDB_STRING, "comment", "Image description (maximum 72 bytes)" },
|
||||
{ GIMP_PDB_INT32, "x10", "Export in X10 format" },
|
||||
{ GIMP_PDB_INT32, "x-hot", "X coordinate of hotspot" },
|
||||
{ GIMP_PDB_INT32, "y-hot", "Y coordinate of hotspot" },
|
||||
{ GIMP_PDB_STRING, "prefix", "Identifier prefix [determined from filename]"},
|
||||
{ GIMP_PDB_INT32, "write-mask", "(0 = ignore, 1 = save as extra file)" },
|
||||
{ GIMP_PDB_STRING, "mask-extension", "Extension of the mask file" }
|
||||
} ;
|
||||
gimp_procedure_set_image_types (procedure, "INDEXED");
|
||||
|
||||
gimp_install_procedure (LOAD_PROC,
|
||||
"Load a file in X10 or X11 bitmap (XBM) file format",
|
||||
"Load a file in X10 or X11 bitmap (XBM) file format. XBM is a lossless format for flat black-and-white (two color indexed) images.",
|
||||
gimp_procedure_set_menu_label (procedure, N_("X BitMap image"));
|
||||
|
||||
gimp_procedure_set_documentation (procedure,
|
||||
"Export a file in X10 or X11 bitmap "
|
||||
"(XBM) file format",
|
||||
"Export a file in X10 or X11 bitmap "
|
||||
"(XBM) file format. XBM is a lossless "
|
||||
"format for flat black-and-white "
|
||||
"(two color indexed) images.",
|
||||
name);
|
||||
gimp_procedure_set_attribution (procedure,
|
||||
"Gordon Matzigkeit",
|
||||
"Gordon Matzigkeit",
|
||||
"1998",
|
||||
N_("X BitMap image"),
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (load_args),
|
||||
G_N_ELEMENTS (load_return_vals),
|
||||
load_args, load_return_vals);
|
||||
"1998");
|
||||
|
||||
gimp_register_file_handler_mime (LOAD_PROC, "image/x-xbitmap");
|
||||
gimp_register_load_handler (LOAD_PROC,
|
||||
"xbm,icon,bitmap",
|
||||
"");
|
||||
gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
|
||||
TRUE);
|
||||
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
||||
"image/x-xbitmap");
|
||||
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
||||
"xbm,icon,bitmap");
|
||||
|
||||
gimp_install_procedure (SAVE_PROC,
|
||||
"Export a file in X10 or X11 bitmap (XBM) file format",
|
||||
"Export a file in X10 or X11 bitmap (XBM) file format. XBM is a lossless format for flat black-and-white (two color indexed) images.",
|
||||
"Gordon Matzigkeit",
|
||||
"Gordon Matzigkeit",
|
||||
"1998",
|
||||
N_("X BitMap image"),
|
||||
"INDEXED",
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (save_args), 0,
|
||||
save_args, NULL);
|
||||
GIMP_PROC_ARG_STRING (procedure, "comment",
|
||||
"Comment",
|
||||
"Image description (maximum 72 bytes)",
|
||||
"Created with GIMP",
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_register_file_handler_mime (SAVE_PROC, "image/x-xbitmap");
|
||||
gimp_register_file_handler_remote (SAVE_PROC);
|
||||
gimp_register_save_handler (SAVE_PROC, "xbm,icon,bitmap", "");
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "x10",
|
||||
"X10",
|
||||
"Export in X10 format",
|
||||
DEFAULT_X10_FORMAT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "x-hot",
|
||||
"X hot",
|
||||
"X coordinate of hotspot",
|
||||
0, GIMP_MAX_IMAGE_SIZE, 0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "y-hot",
|
||||
"Y hot",
|
||||
"Y coordinate of hotspot",
|
||||
0, GIMP_MAX_IMAGE_SIZE, 0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_STRING (procedure, "prefix",
|
||||
"Prefix",
|
||||
"Identifier prefix [determined from filename]",
|
||||
DEFAULT_PREFIX,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "write-mask",
|
||||
"Write mask",
|
||||
"Write extra mask file",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_STRING (procedure, "mask-suffix",
|
||||
"Mask suffix",
|
||||
"Suffix of the mask file",
|
||||
"-mask",
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
xbm_load (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GFile *file,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
GimpImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
INIT_I18N ();
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
image = load_image (g_file_get_path (file), &error);
|
||||
|
||||
if (! image)
|
||||
return gimp_procedure_new_return_values (procedure, status, error);
|
||||
|
||||
return_vals = gimp_procedure_new_return_values (procedure,
|
||||
GIMP_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
GIMP_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
@ -235,78 +351,37 @@ init_prefix (const gchar *filename)
|
|||
return xsvals.prefix;
|
||||
}
|
||||
|
||||
static void
|
||||
run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
static GimpValueArray *
|
||||
xbm_save (GimpProcedure *procedure,
|
||||
GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GFile *file,
|
||||
const GimpValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
static GimpParam values[2];
|
||||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpParasite *parasite = NULL;
|
||||
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
||||
gchar *mask_basename = NULL;
|
||||
GError *error = NULL;
|
||||
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
||||
|
||||
INIT_I18N ();
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
g_strlcpy (xsvals.comment, "Created with GIMP", MAX_COMMENT);
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
#ifdef VERBOSE
|
||||
if (verbose)
|
||||
printf ("XBM: RUN %s\n", name);
|
||||
#endif
|
||||
|
||||
if (strcmp (name, LOAD_PROC) == 0)
|
||||
{
|
||||
GFile *file = g_file_new_for_uri (param[1].data.d_string);
|
||||
|
||||
image_ID = load_image (g_file_get_path (file), &error);
|
||||
|
||||
if (image_ID != -1)
|
||||
{
|
||||
*nreturn_vals = 2;
|
||||
values[1].type = GIMP_PDB_IMAGE;
|
||||
values[1].data.d_image = image_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
else if (strcmp (name, SAVE_PROC) == 0)
|
||||
{
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
||||
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "XBM",
|
||||
export = gimp_export_image (&image, &drawable, "XBM",
|
||||
GIMP_EXPORT_CAN_HANDLE_BITMAP |
|
||||
GIMP_EXPORT_CAN_HANDLE_ALPHA);
|
||||
|
||||
if (export == GIMP_EXPORT_CANCEL)
|
||||
{
|
||||
values[0].data.d_status = GIMP_PDB_CANCEL;
|
||||
return;
|
||||
}
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
GIMP_PDB_CANCEL,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -317,60 +392,29 @@ run (const gchar *name,
|
|||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data (SAVE_PROC, &xsvals);
|
||||
|
||||
/* Always override the prefix with the filename. */
|
||||
mask_basename = g_strdup (init_prefix (param[3].data.d_string));
|
||||
mask_basename = g_strdup (init_prefix (g_file_get_path (file)));
|
||||
break;
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
/* Make sure all the required arguments are there! */
|
||||
if (nparams < 5)
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint i = 5;
|
||||
|
||||
if (nparams > i)
|
||||
g_strlcpy (xsvals.comment, param[i].data.d_string,
|
||||
g_strlcpy (xsvals.comment, GIMP_VALUES_GET_STRING (args, 0),
|
||||
MAX_COMMENT);
|
||||
|
||||
i ++;
|
||||
if (nparams > i)
|
||||
xsvals.x10_format = (param[i].data.d_int32) ? TRUE : FALSE;
|
||||
xsvals.x10_format = GIMP_VALUES_GET_BOOLEAN (args, 1);
|
||||
xsvals.x_hot = GIMP_VALUES_GET_INT (args, 2);
|
||||
xsvals.y_hot = GIMP_VALUES_GET_INT (args, 3);
|
||||
xsvals.use_hot = xsvals.x_hot != 0 || xsvals.y_hot != 0;
|
||||
|
||||
i += 2;
|
||||
if (nparams > i)
|
||||
{
|
||||
/* They've asked for a hotspot. */
|
||||
xsvals.use_hot = TRUE;
|
||||
xsvals.x_hot = param[i - 1].data.d_int32;
|
||||
xsvals.y_hot = param[i].data.d_int32;
|
||||
}
|
||||
mask_basename = g_strdup (init_prefix (g_file_get_path (file)));
|
||||
|
||||
mask_basename = g_strdup (init_prefix (param[3].data.d_string));
|
||||
|
||||
i ++;
|
||||
if (nparams > i)
|
||||
g_strlcpy (xsvals.prefix, param[i].data.d_string,
|
||||
g_strlcpy (xsvals.prefix, GIMP_VALUES_GET_STRING (args, 4),
|
||||
MAX_PREFIX);
|
||||
|
||||
i += 2;
|
||||
if (nparams > i)
|
||||
{
|
||||
xsvals.write_mask = param[i - 1].data.d_int32;
|
||||
g_strlcpy (xsvals.mask_ext, param[i].data.d_string,
|
||||
xsvals.write_mask = GIMP_VALUES_GET_BOOLEAN (args, 5);
|
||||
g_strlcpy (xsvals.mask_ext, GIMP_VALUES_GET_STRING (args, 6),
|
||||
MAX_MASK_EXT);
|
||||
}
|
||||
|
||||
i ++;
|
||||
/* Too many arguments. */
|
||||
if (nparams > i)
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -379,8 +423,10 @@ run (const gchar *name,
|
|||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
{
|
||||
GimpParasite *parasite;
|
||||
|
||||
/* Get the parasites */
|
||||
parasite = gimp_image_get_parasite (image_ID, "gimp-comment");
|
||||
parasite = gimp_image_get_parasite (image, "gimp-comment");
|
||||
|
||||
if (parasite)
|
||||
{
|
||||
|
@ -393,7 +439,7 @@ run (const gchar *name,
|
|||
gimp_parasite_free (parasite);
|
||||
}
|
||||
|
||||
parasite = gimp_image_get_parasite (image_ID, "hot-spot");
|
||||
parasite = gimp_image_get_parasite (image, "hot-spot");
|
||||
|
||||
if (parasite)
|
||||
{
|
||||
|
@ -405,17 +451,18 @@ run (const gchar *name,
|
|||
xsvals.x_hot = x;
|
||||
xsvals.y_hot = y;
|
||||
}
|
||||
|
||||
gimp_parasite_free (parasite);
|
||||
}
|
||||
|
||||
/* Acquire information with a dialog */
|
||||
if (! save_dialog (drawable_ID))
|
||||
status = GIMP_PDB_CANCEL;
|
||||
if (! save_dialog (drawable))
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
GIMP_PDB_CANCEL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
GFile *file = g_file_new_for_uri (param[3].data.d_string);
|
||||
GFile *mask_file;
|
||||
GFile *dir;
|
||||
gchar *mask_prefix;
|
||||
|
@ -445,7 +492,7 @@ run (const gchar *name,
|
|||
xsvals.prefix,
|
||||
xsvals.comment,
|
||||
FALSE,
|
||||
image_ID, drawable_ID,
|
||||
image, drawable,
|
||||
&error)
|
||||
|
||||
&& (! xsvals.write_mask ||
|
||||
|
@ -453,7 +500,7 @@ run (const gchar *name,
|
|||
mask_prefix,
|
||||
xsvals.comment,
|
||||
TRUE,
|
||||
image_ID, drawable_ID,
|
||||
image, drawable,
|
||||
&error)))
|
||||
{
|
||||
/* Store xsvals data */
|
||||
|
@ -467,29 +514,15 @@ run (const gchar *name,
|
|||
g_free (mask_prefix);
|
||||
g_free (mask_basename);
|
||||
|
||||
g_object_unref (file);
|
||||
g_object_unref (mask_file);
|
||||
}
|
||||
|
||||
if (export == GIMP_EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
gimp_image_delete (image);
|
||||
|
||||
if (status != GIMP_PDB_SUCCESS && error)
|
||||
{
|
||||
*nreturn_vals = 2;
|
||||
values[1].type = GIMP_PDB_STRING;
|
||||
values[1].data.d_string = error->message;
|
||||
}
|
||||
|
||||
values[0].data.d_status = status;
|
||||
return gimp_procedure_new_return_values (procedure, status, error);
|
||||
}
|
||||
|
||||
|
||||
/* Return the value of a digit. */
|
||||
static gint
|
||||
getval (gint c,
|
||||
|
@ -707,15 +740,14 @@ get_int (FILE *fp)
|
|||
return val;
|
||||
}
|
||||
|
||||
|
||||
static gint32
|
||||
static GimpImage *
|
||||
load_image (const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
FILE *fp;
|
||||
GeglBuffer *buffer;
|
||||
gint32 image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
guchar *data;
|
||||
gint intbits;
|
||||
gint width = 0;
|
||||
|
@ -741,7 +773,7 @@ load_image (const gchar *filename,
|
|||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not open '%s' for reading: %s"),
|
||||
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
comment = fgetcomment (fp);
|
||||
|
@ -822,7 +854,7 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nCould not read header (ftell == %ld)"),
|
||||
gimp_filename_to_utf8 (filename), ftell (fp));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (width <= 0)
|
||||
|
@ -830,7 +862,7 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nNo image width specified"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (width > GIMP_MAX_IMAGE_SIZE)
|
||||
|
@ -838,7 +870,7 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (height <= 0)
|
||||
|
@ -846,7 +878,7 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nNo image height specified"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (height > GIMP_MAX_IMAGE_SIZE)
|
||||
|
@ -854,7 +886,7 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (intbits == 0)
|
||||
|
@ -862,11 +894,11 @@ load_image (const gchar *filename,
|
|||
g_message (_("'%s':\nNo image data type specified"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
fclose (fp);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image_ID = gimp_image_new (width, height, GIMP_INDEXED);
|
||||
gimp_image_set_filename (image_ID, filename);
|
||||
image = gimp_image_new (width, height, GIMP_INDEXED);
|
||||
gimp_image_set_filename (image, filename);
|
||||
|
||||
if (comment)
|
||||
{
|
||||
|
@ -875,7 +907,7 @@ load_image (const gchar *filename,
|
|||
parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1, (gpointer) comment);
|
||||
gimp_image_attach_parasite (image_ID, parasite);
|
||||
gimp_image_attach_parasite (image, parasite);
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
g_free (comment);
|
||||
|
@ -894,22 +926,22 @@ load_image (const gchar *filename,
|
|||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (str) + 1, (gpointer) str);
|
||||
g_free (str);
|
||||
gimp_image_attach_parasite (image_ID, parasite);
|
||||
gimp_image_attach_parasite (image, parasite);
|
||||
gimp_parasite_free (parasite);
|
||||
}
|
||||
|
||||
/* Set a black-and-white colormap. */
|
||||
gimp_image_set_colormap (image_ID, cmap, 2);
|
||||
gimp_image_set_colormap (image, cmap, 2);
|
||||
|
||||
layer_ID = gimp_layer_new (image_ID,
|
||||
layer = gimp_layer_new (image,
|
||||
_("Background"),
|
||||
width, height,
|
||||
GIMP_INDEXED_IMAGE,
|
||||
100,
|
||||
gimp_image_get_default_new_layer_mode (image_ID));
|
||||
gimp_image_insert_layer (image_ID, layer_ID, -1, 0);
|
||||
gimp_image_get_default_new_layer_mode (image));
|
||||
gimp_image_insert_layer (image, layer, NULL, 0);
|
||||
|
||||
buffer = gimp_drawable_get_buffer (layer_ID);
|
||||
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
|
||||
|
||||
/* Allocate the data. */
|
||||
tileheight = gimp_tile_height ();
|
||||
|
@ -960,7 +992,7 @@ load_image (const gchar *filename,
|
|||
|
||||
gimp_progress_update (1.0);
|
||||
|
||||
return image_ID;
|
||||
return image;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -968,8 +1000,8 @@ save_image (GFile *file,
|
|||
const gchar *prefix,
|
||||
const gchar *comment,
|
||||
gboolean save_mask,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GError **error)
|
||||
{
|
||||
GOutputStream *output;
|
||||
|
@ -991,9 +1023,9 @@ save_image (GFile *file,
|
|||
g_printerr ("%s: save_image '%s'\n", G_STRFUNC, prefix);
|
||||
#endif
|
||||
|
||||
cmap = gimp_image_get_colormap (image_ID, &colors);
|
||||
cmap = gimp_image_get_colormap (image, &colors);
|
||||
|
||||
if (! gimp_drawable_is_indexed (drawable_ID) || colors > 2)
|
||||
if (! gimp_drawable_is_indexed (drawable) || colors > 2)
|
||||
{
|
||||
/* The image is not black-and-white. */
|
||||
g_message (_("The image which you are trying to export as "
|
||||
|
@ -1004,7 +1036,7 @@ save_image (GFile *file,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
has_alpha = gimp_drawable_has_alpha (drawable_ID);
|
||||
has_alpha = gimp_drawable_has_alpha (drawable);
|
||||
|
||||
if (! has_alpha && save_mask)
|
||||
{
|
||||
|
@ -1013,10 +1045,10 @@ save_image (GFile *file,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
buffer = gimp_drawable_get_buffer (drawable_ID);
|
||||
buffer = gimp_drawable_get_buffer (drawable);
|
||||
width = gegl_buffer_get_width (buffer);
|
||||
height = gegl_buffer_get_height (buffer);
|
||||
bpp = gimp_drawable_bpp (drawable_ID);
|
||||
bpp = gimp_drawable_bpp (drawable);
|
||||
|
||||
/* Figure out which color is black, and which is white. */
|
||||
dark = 0;
|
||||
|
@ -1230,7 +1262,7 @@ save_image (GFile *file,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
save_dialog (gint32 drawable_ID)
|
||||
save_dialog (GimpDrawable *drawable)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *frame;
|
||||
|
@ -1317,7 +1349,7 @@ save_dialog (gint32 drawable_ID)
|
|||
G_BINDING_SYNC_CREATE);
|
||||
|
||||
adj = gtk_adjustment_new (xsvals.x_hot, 0,
|
||||
gimp_drawable_width (drawable_ID) - 1,
|
||||
gimp_drawable_width (drawable) - 1,
|
||||
1, 10, 0);
|
||||
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||
|
@ -1330,7 +1362,7 @@ save_dialog (gint32 drawable_ID)
|
|||
&xsvals.x_hot);
|
||||
|
||||
adj = gtk_adjustment_new (xsvals.y_hot, 0,
|
||||
gimp_drawable_height (drawable_ID) - 1,
|
||||
gimp_drawable_height (drawable) - 1,
|
||||
1, 10, 0);
|
||||
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||
|
@ -1376,7 +1408,7 @@ save_dialog (gint32 drawable_ID)
|
|||
entry, "sensitive",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
|
||||
gtk_widget_set_sensitive (frame, gimp_drawable_has_alpha (drawable_ID));
|
||||
gtk_widget_set_sensitive (frame, gimp_drawable_has_alpha (drawable));
|
||||
|
||||
/* Done. */
|
||||
gtk_widget_show (vbox);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
'file-svg' => { ui => 1, gegl => 1, libs => 'SVG_LIBS', cflags => 'SVG_CFLAGS' },
|
||||
'file-tga' => { ui => 1, gegl => 1, old_api => 1 },
|
||||
'file-wmf' => { ui => 1, gegl => 1, optional => 1, libs => 'WMF_LIBS', cflags => 'WMF_CFLAGS' },
|
||||
'file-xbm' => { ui => 1, gegl => 1, old_api => 1 },
|
||||
'file-xbm' => { ui => 1, gegl => 1 },
|
||||
'file-xmc' => { ui => 1, gegl => 1, optional => 1, libs => 'XMC_LIBS' },
|
||||
'file-xpm' => { ui => 1, gegl => 1, optional => 1, libs => 'XPM_LIBS', old_api => 1 },
|
||||
'file-xwd' => { ui => 1, gegl => 1, old_api => 1 },
|
||||
|
|
Loading…
Reference in New Issue