plug-ins: port file-sunras to GimpPlugIn and libgimp objects

This commit is contained in:
Michael Natterer 2019-08-25 15:12:48 +02:00
parent 24af759483
commit bc1e611bf0
3 changed files with 405 additions and 383 deletions

View File

@ -1059,8 +1059,6 @@ file_raw_data_LDADD = \
$(INTLLIBS) \
$(file_raw_data_RC)
file_sunras_CPPFLAGS = $(AM_CPPFLAGS) -DGIMP_DEPRECATED_REPLACE_NEW_API
file_sunras_SOURCES = \
file-sunras.c

View File

@ -86,46 +86,79 @@ typedef struct
gint n; /* How many times it is repeated */
} RLEBUF;
/* Export info */
typedef struct
{
gboolean rle; /* rle or standard */
} SUNRASSaveVals;
/* 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);
static gint32 load_image (const gchar *filename,
typedef struct _Sunras Sunras;
typedef struct _SunrasClass SunrasClass;
struct _Sunras
{
GimpPlugIn parent_instance;
};
struct _SunrasClass
{
GimpPlugInClass parent_class;
};
#define SUNRAS_TYPE (sunras_get_type ())
#define SUNRAS (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SUNRAS_TYPE, Sunras))
GType sunras_get_type (void) G_GNUC_CONST;
static GList * sunras_query_procedures (GimpPlugIn *plug_in);
static GimpProcedure * sunras_create_procedure (GimpPlugIn *plug_in,
const gchar *name);
static GimpValueArray * sunras_load (GimpProcedure *procedure,
GimpRunMode run_mode,
GFile *file,
const GimpValueArray *args,
gpointer run_data);
static GimpValueArray * sunras_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 gboolean save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
GError **error);
static void set_color_table (gint32 image_ID,
static void set_color_table (GimpImage *image,
L_SUNFILEHEADER *sunhdr,
const guchar *suncolmap);
static gint32 create_new_image (const gchar *filename,
static GimpImage * create_new_image (const gchar *filename,
guint width,
guint height,
GimpImageBaseType type,
gint32 *layer_ID,
GimpLayer **layer,
GeglBuffer **buffer);
static gint32 load_sun_d1 (const gchar *filename,
static GimpImage * load_sun_d1 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
static gint32 load_sun_d8 (const gchar *filename,
static GimpImage * load_sun_d8 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
static gint32 load_sun_d24 (const gchar *filename,
static GimpImage * load_sun_d24 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
static gint32 load_sun_d32 (const gchar *filename,
static GimpImage * load_sun_d32 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
guchar *suncolmap);
@ -174,13 +207,13 @@ static void write_sun_cols (FILE *ofp,
guchar *colormap);
static gint save_index (FILE *ofp,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
gboolean grey,
gboolean rle);
static gint save_rgb (FILE *ofp,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
gboolean rle);
static gboolean save_dialog (void);
@ -192,166 +225,173 @@ static int my_fwrite (void *ptr,
FILE *stream);
G_DEFINE_TYPE (Sunras, sunras, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (SUNRAS_TYPE)
static int read_msb_first = 1;
static RLEBUF rlebuf;
const GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
/* Export info */
typedef struct
{
gboolean rle; /* rle or standard */
} SUNRASSaveVals;
static SUNRASSaveVals psvals =
{
TRUE /* rle */
};
MAIN ()
static void
query (void)
sunras_class_init (SunrasClass *klass)
{
static const GimpParamDef load_args[] =
{
{ 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 of the file to load" }
};
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
static const GimpParamDef load_return_vals[] =
{
{ GIMP_PDB_IMAGE, "image", "Output image" }
};
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 the image in" },
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to export the image in" },
{ GIMP_PDB_INT32, "rle", "Specify non-zero for rle output, zero for standard output" }
};
gimp_install_procedure (LOAD_PROC,
"load file of the SunRaster file format",
"load file of the SunRaster file format",
"Peter Kirchgessner",
"Peter Kirchgessner",
"1996",
N_("SUN Rasterfile image"),
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
load_args, load_return_vals);
gimp_register_file_handler_mime (LOAD_PROC, "image/x-sun-raster");
gimp_register_magic_load_handler (LOAD_PROC,
"im1,im8,im24,im32,rs,ras",
"",
"0,long,0x59a66a95");
gimp_install_procedure (SAVE_PROC,
"export file in the SunRaster file format",
"SUNRAS exporting handles all image types except "
"those with alpha channels.",
"Peter Kirchgessner",
"Peter Kirchgessner",
"1996",
N_("SUN Rasterfile image"),
"RGB, GRAY, INDEXED",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_file_handler_mime (SAVE_PROC, "image/x-sun-raster");
gimp_register_save_handler (SAVE_PROC,
"im1,im8,im24,im32,rs,ras", "");
plug_in_class->query_procedures = sunras_query_procedures;
plug_in_class->create_procedure = sunras_create_procedure;
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
sunras_init (Sunras *sunras)
{
static GimpParam values[2];
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_ID;
gint32 drawable_ID;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
}
run_mode = param[0].data.d_int32;
static GList *
sunras_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 *
sunras_create_procedure (GimpPlugIn *plug_in,
const gchar *name)
{
GimpProcedure *procedure = NULL;
if (! strcmp (name, LOAD_PROC))
{
procedure = gimp_load_procedure_new (plug_in, name, GIMP_PLUGIN,
sunras_load, NULL, NULL);
gimp_procedure_set_menu_label (procedure, N_("SUN Rasterfile image"));
gimp_procedure_set_documentation (procedure,
"Load file of the SunRaster file format",
"Load file of the SunRaster file format",
name);
gimp_procedure_set_attribution (procedure,
"Peter Kirchgessner",
"Peter Kirchgessner",
"1996");
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
"image/x-sun-raster");
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
"im1,im8,im24,im32,rs,ras");
gimp_file_procedure_set_magics (GIMP_FILE_PROCEDURE (procedure),
"0,long,0x59a66a95");
}
else if (! strcmp (name, SAVE_PROC))
{
procedure = gimp_save_procedure_new (plug_in, name, GIMP_PLUGIN,
sunras_save, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB, GRAY, INDEXED");
gimp_procedure_set_menu_label (procedure, N_("SUN Rasterfile image"));
gimp_procedure_set_documentation (procedure,
"Export file in the SunRaster file "
"format",
"SUNRAS exporting handles all image "
"types except those with alpha "
"channels.",
name);
gimp_procedure_set_attribution (procedure,
"Peter Kirchgessner",
"Peter Kirchgessner",
"1996");
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
"image/x-sun-raster");
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
"im1,im8,im24,im32,rs,ras");
GIMP_PROC_ARG_BOOLEAN (procedure, "rle",
"RLE",
"Use RLE output",
TRUE,
G_PARAM_READWRITE);
}
return procedure;
}
static GimpValueArray *
sunras_load (GimpProcedure *procedure,
GimpRunMode run_mode,
GFile *file,
const GimpValueArray *args,
gpointer run_data)
{
GimpValueArray *return_vals;
GimpImage *image;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
*nreturn_vals = 1;
*return_vals = values;
image = load_image (g_file_get_path (file), &error);
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
if (! image)
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
error);
if (strcmp (name, LOAD_PROC) == 0)
{
GFile *file = g_file_new_for_uri (param[1].data.d_string);
return_vals = gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS,
NULL);
image_ID = load_image (g_file_get_path (file), &error);
GIMP_VALUES_SET_IMAGE (return_vals, 1, image);
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)
{
GFile *file = g_file_new_for_uri (param[3].data.d_string);
return return_vals;
}
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
static GimpValueArray *
sunras_save (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
GimpDrawable *drawable,
GFile *file,
const GimpValueArray *args,
gpointer run_data)
{
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
/* eventually export the image */
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, "SUNRAS",
export = gimp_export_image (&image, &drawable, "SUNRAS",
GIMP_EXPORT_CAN_HANDLE_RGB |
GIMP_EXPORT_CAN_HANDLE_GRAY |
GIMP_EXPORT_CAN_HANDLE_INDEXED);
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:
break;
}
@ -359,28 +399,17 @@ run (const gchar *name,
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
/* Possibly retrieve data */
gimp_get_data (SAVE_PROC, &psvals);
/* First acquire information with a dialog */
if (! save_dialog ())
status = GIMP_PDB_CANCEL;
break;
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != 6)
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
psvals.rle = (param[5].data.d_int32) ? TRUE : FALSE;
}
psvals.rle = GIMP_VALUES_GET_BOOLEAN (args, 0);
break;
case GIMP_RUN_WITH_LAST_VALS:
/* Possibly retrieve data */
gimp_get_data (SAVE_PROC, &psvals);
break;
@ -390,11 +419,9 @@ run (const gchar *name,
if (status == GIMP_PDB_SUCCESS)
{
if (save_image (g_file_get_path (file),
image_ID, drawable_ID,
if (save_image (g_file_get_path (file), image, drawable,
&error))
{
/* Store psvals data */
gimp_set_data (SAVE_PROC, &psvals, sizeof (SUNRASSaveVals));
}
else
@ -404,29 +431,16 @@ run (const gchar *name,
}
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);
}
static gint32
static GimpImage *
load_image (const gchar *filename,
GError **error)
{
gint32 image_ID;
GimpImage *image;
FILE *ifp;
L_SUNFILEHEADER sunhdr;
guchar *suncolmap = NULL;
@ -440,7 +454,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;
}
read_msb_first = 1; /* SUN raster is always most significant byte first */
@ -452,7 +466,7 @@ load_image (const gchar *filename,
_("Could not open '%s' as SUN-raster-file"),
gimp_filename_to_utf8 (filename));
fclose (ifp);
return -1;
return NULL;
}
if (sunhdr.l_ras_type > 5)
@ -461,7 +475,7 @@ load_image (const gchar *filename,
"%s",
_("The type of this SUN-rasterfile is not supported"));
fclose (ifp);
return -1;
return NULL;
}
if (sunhdr.l_ras_maplength > (256 * 3))
@ -492,7 +506,7 @@ load_image (const gchar *filename,
gimp_filename_to_utf8 (filename));
fclose (ifp);
g_free (suncolmap);
return -1;
return NULL;
}
}
else if (sunhdr.l_ras_maplength > 0)
@ -507,7 +521,7 @@ load_image (const gchar *filename,
g_message (_("'%s':\nNo image width specified"),
gimp_filename_to_utf8 (filename));
fclose (ifp);
return -1;
return NULL;
}
if (sunhdr.l_ras_width > GIMP_MAX_IMAGE_SIZE)
@ -515,7 +529,7 @@ load_image (const gchar *filename,
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
gimp_filename_to_utf8 (filename));
fclose (ifp);
return -1;
return NULL;
}
if (sunhdr.l_ras_height <= 0)
@ -523,7 +537,7 @@ load_image (const gchar *filename,
g_message (_("'%s':\nNo image height specified"),
gimp_filename_to_utf8 (filename));
fclose (ifp);
return -1;
return NULL;
}
if (sunhdr.l_ras_height > GIMP_MAX_IMAGE_SIZE)
@ -531,29 +545,29 @@ load_image (const gchar *filename,
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
gimp_filename_to_utf8 (filename));
fclose (ifp);
return -1;
return NULL;
}
switch (sunhdr.l_ras_depth)
{
case 1: /* bitmap */
image_ID = load_sun_d1 (filename, ifp, &sunhdr, suncolmap);
image = load_sun_d1 (filename, ifp, &sunhdr, suncolmap);
break;
case 8: /* 256 colors */
image_ID = load_sun_d8 (filename, ifp, &sunhdr, suncolmap);
image = load_sun_d8 (filename, ifp, &sunhdr, suncolmap);
break;
case 24: /* True color */
image_ID = load_sun_d24 (filename, ifp, &sunhdr, suncolmap);
image = load_sun_d24 (filename, ifp, &sunhdr, suncolmap);
break;
case 32: /* True color with extra byte */
image_ID = load_sun_d32 (filename, ifp, &sunhdr, suncolmap);
image = load_sun_d32 (filename, ifp, &sunhdr, suncolmap);
break;
default:
image_ID = -1;
image = NULL;
break;
}
gimp_progress_update (1.0);
@ -562,30 +576,29 @@ load_image (const gchar *filename,
g_free (suncolmap);
if (image_ID == -1)
if (! image)
{
g_message (_("This image depth is not supported"));
return -1;
return NULL;
}
return image_ID;
return image;
}
static gboolean
save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
GError **error)
{
FILE *ofp;
GimpImageType drawable_type;
gboolean retval;
drawable_type = gimp_drawable_type (drawable_ID);
drawable_type = gimp_drawable_type (drawable);
/* Make sure we're not exporting an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID))
if (gimp_drawable_has_alpha (drawable))
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("SUNRAS export cannot handle images with alpha channels"));
@ -618,20 +631,27 @@ save_image (const gchar *filename,
}
if (drawable_type == GIMP_INDEXED_IMAGE)
retval = save_index (ofp,image_ID, drawable_ID, FALSE, psvals.rle);
{
retval = save_index (ofp, image, drawable, FALSE, psvals.rle);
}
else if (drawable_type == GIMP_GRAY_IMAGE)
retval = save_index (ofp,image_ID, drawable_ID, TRUE, psvals.rle);
{
retval = save_index (ofp, image, drawable, TRUE, psvals.rle);
}
else if (drawable_type == GIMP_RGB_IMAGE)
retval = save_rgb (ofp,image_ID, drawable_ID, psvals.rle);
{
retval = save_rgb (ofp, image, drawable, psvals.rle);
}
else
{
retval = FALSE;
}
fclose (ofp);
return retval;
}
static L_CARD32
read_card32 (FILE *ifp,
gint *err)
@ -991,7 +1011,7 @@ write_sun_cols (FILE *ofp,
/* Set a GIMP colortable using the sun colormap */
static void
set_color_table (gint32 image_ID,
set_color_table (GimpImage *image,
L_SUNFILEHEADER *sunhdr,
const guchar *suncolmap)
{
@ -1016,20 +1036,20 @@ set_color_table (gint32 image_ID,
ColorMap[j*3], ColorMap[j*3+1], ColorMap[j*3+2]);
#endif
gimp_image_set_colormap (image_ID, ColorMap, ncols);
gimp_image_set_colormap (image, ColorMap, ncols);
}
/* Create an image. Sets layer_ID, drawable and rgn. Returns image_ID */
static gint32
/* Create an image. Sets layer, drawable and rgn. Returns image */
static GimpImage *
create_new_image (const gchar *filename,
guint width,
guint height,
GimpImageBaseType type,
gint32 *layer_ID,
GimpLayer **layer,
GeglBuffer **buffer)
{
gint32 image_ID;
GimpImage *image;
GimpImageType gdtype;
switch (type)
@ -1045,26 +1065,26 @@ create_new_image (const gchar *filename,
break;
default:
g_warning ("Unsupported image type");
return -1;
return NULL;
}
image_ID = gimp_image_new (width, height, type);
gimp_image_set_filename (image_ID, filename);
image = gimp_image_new (width, height, type);
gimp_image_set_filename (image, filename);
*layer_ID = gimp_layer_new (image_ID, _("Background"), width, height,
*layer = gimp_layer_new (image, _("Background"), width, height,
gdtype,
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));
return image_ID;
return image;
}
/* Load SUN-raster-file with depth 1 */
static gint32
static GimpImage *
load_sun_d1 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
@ -1074,7 +1094,8 @@ load_sun_d1 (const gchar *filename,
int width, height, linepad, scan_lines, tile_height;
int i, j;
guchar *dest, *data;
gint32 layer_ID, image_ID;
GimpImage *image;
GimpLayer *layer;
GeglBuffer *buffer;
guchar bit2byte[256 * 8];
L_SUNFILEHEADER sun_bwhdr;
@ -1085,22 +1106,22 @@ load_sun_d1 (const gchar *filename,
width = sunhdr->l_ras_width;
height = sunhdr->l_ras_height;
image_ID = create_new_image (filename, width, height, GIMP_INDEXED,
&layer_ID, &buffer);
image = create_new_image (filename, width, height, GIMP_INDEXED,
&layer, &buffer);
tile_height = gimp_tile_height ();
data = g_malloc (tile_height * width);
if (suncolmap != NULL) /* Set up the specified color map */
{
set_color_table (image_ID, sunhdr, suncolmap);
set_color_table (image, sunhdr, suncolmap);
}
else /* No colormap available. Set up a dummy b/w-colormap */
{ /* Copy the original header and simulate b/w-colormap */
memcpy ((char *)&sun_bwhdr,(char *)sunhdr,sizeof (L_SUNFILEHEADER));
sun_bwhdr.l_ras_maptype = 2;
sun_bwhdr.l_ras_maplength = 6;
set_color_table (image_ID, &sun_bwhdr, sun_bwcolmap);
set_color_table (image, &sun_bwhdr, sun_bwcolmap);
}
/* Get an array for mapping 8 bits in a byte to 8 bytes */
@ -1164,13 +1185,13 @@ load_sun_d1 (const gchar *filename,
g_object_unref (buffer);
return image_ID;
return image;
}
/* Load SUN-raster-file with depth 8 */
static gint32
static GimpImage *
load_sun_d8 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
@ -1181,7 +1202,8 @@ load_sun_d8 (const gchar *filename,
gint ncols;
int scan_lines, tile_height;
guchar *dest, *data;
gint32 layer_ID, image_ID;
GimpImage *image;
GimpLayer *layer;
GeglBuffer *buffer;
int err = 0;
gboolean rle = (sunhdr->l_ras_type == RAS_TYPE_RLE);
@ -1208,15 +1230,15 @@ load_sun_d8 (const gchar *filename,
}
}
image_ID = create_new_image (filename, width, height,
image = create_new_image (filename, width, height,
grayscale ? GIMP_GRAY : GIMP_INDEXED,
&layer_ID, &buffer);
&layer, &buffer);
tile_height = gimp_tile_height ();
data = g_malloc (tile_height * width);
if (!grayscale)
set_color_table (image_ID, sunhdr, suncolmap);
set_color_table (image, sunhdr, suncolmap);
linepad = (sunhdr->l_ras_width % 2);
@ -1258,12 +1280,12 @@ load_sun_d8 (const gchar *filename,
g_object_unref (buffer);
return image_ID;
return image;
}
/* Load SUN-raster-file with depth 24 */
static gint32
static GimpImage *
load_sun_d24 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
@ -1273,7 +1295,8 @@ load_sun_d24 (const gchar *filename,
guchar *data;
int width, height, linepad, tile_height, scan_lines;
int i, j;
gint32 layer_ID, image_ID;
GimpImage *image;
GimpLayer *layer;
GeglBuffer *buffer;
int err = 0;
gboolean rle = (sunhdr->l_ras_type == RAS_TYPE_RLE);
@ -1281,8 +1304,8 @@ load_sun_d24 (const gchar *filename,
width = sunhdr->l_ras_width;
height = sunhdr->l_ras_height;
image_ID = create_new_image (filename, width, height, GIMP_RGB,
&layer_ID, &buffer);
image = create_new_image (filename, width, height, GIMP_RGB,
&layer, &buffer);
tile_height = gimp_tile_height ();
data = g_malloc (tile_height * width * 3);
@ -1341,13 +1364,13 @@ load_sun_d24 (const gchar *filename,
g_object_unref (buffer);
return image_ID;
return image;
}
/* Load SUN-raster-file with depth 32 */
static gint32
static GimpImage *
load_sun_d32 (const gchar *filename,
FILE *ifp,
L_SUNFILEHEADER *sunhdr,
@ -1357,7 +1380,8 @@ load_sun_d32 (const gchar *filename,
guchar *data;
int width, height, tile_height, scan_lines;
int i, j;
gint32 layer_ID, image_ID;
GimpImage *image;
GimpLayer *layer;
GeglBuffer *buffer;
int err = 0;
int cerr;
@ -1370,8 +1394,8 @@ load_sun_d32 (const gchar *filename,
cerr = 0;
image_ID = create_new_image (filename, width, height, GIMP_RGB,
&layer_ID, &buffer);
image = create_new_image (filename, width, height, GIMP_RGB,
&layer, &buffer);
tile_height = gimp_tile_height ();
data = g_malloc (tile_height * width * 3);
@ -1440,14 +1464,14 @@ load_sun_d32 (const gchar *filename,
g_object_unref (buffer);
return image_ID;
return image;
}
static gint
static gboolean
save_index (FILE *ofp,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
gboolean grey,
gboolean rle)
{
@ -1466,7 +1490,7 @@ save_index (FILE *ofp,
const Babl *format;
WRITE_FUN *write_fun;
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);
@ -1496,7 +1520,7 @@ save_index (FILE *ofp,
}
else
{
cmap = gimp_image_get_colormap (image_ID, &ncols);
cmap = gimp_image_get_colormap (image, &ncols);
for (j = 0; j < ncols; j++)
{
@ -1623,10 +1647,10 @@ save_index (FILE *ofp,
}
static gint
static gboolean
save_rgb (FILE *ofp,
gint32 image_ID,
gint32 drawable_ID,
GimpImage *image,
GimpDrawable *drawable,
gboolean rle)
{
int height, width, tile_height, linepad;
@ -1636,7 +1660,7 @@ save_rgb (FILE *ofp,
GeglBuffer *buffer;
const Babl *format;
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);

View File

@ -43,7 +43,7 @@
'file-ps' => { ui => 1, gegl => 1, optional => 1, libs => 'GS_LIBS' },
'file-psp' => { ui => 1, gegl => 1, libs => 'Z_LIBS' },
'file-raw-data' => { ui => 1, gegl => 1 },
'file-sunras' => { ui => 1, gegl => 1, old_api => 1 },
'file-sunras' => { ui => 1, gegl => 1 },
'file-svg' => { ui => 1, gegl => 1, libs => 'SVG_LIBS', cflags => 'SVG_CFLAGS' },
'file-tga' => { ui => 1, gegl => 1 },
'file-wmf' => { ui => 1, gegl => 1, optional => 1, libs => 'WMF_LIBS', cflags => 'WMF_CFLAGS' },