1
/* The GIMP -- an image manipulation program
1
/* GIMP - The GNU Image Manipulation Program
2
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
* SUN raster reading and writing code Copyright (C) 1996 Peter Kirchgessner
4
4
* (email: peter@kirchgessner.net, WWW: http://www.kirchgessner.net)
36
36
* V 1.96, PK, 21-Nov-99: Internationalization
37
37
* V 1.97, PK, 20-Dec-00: Recognize extensions .rs and .ras too
39
static char ident[] = "@(#) GIMP SunRaster file-plugin v1.97 20-Dec-00";
41
40
#include "config.h"
46
43
#include <string.h>
45
#include <glib/gstdio.h>
53
47
#include <libgimp/gimp.h>
54
48
#include <libgimp/gimpui.h>
56
50
#include "libgimp/stdplugins-intl.h"
53
#define LOAD_PROC "file-sunras-load"
54
#define SAVE_PROC "file-sunras-save"
55
#define PLUG_IN_BINARY "sunras"
59
58
typedef int WRITE_FUN(void*,size_t,size_t,FILE*);
61
60
typedef gulong L_CARD32;
189
static GimpParamDef load_args[] =
188
static const GimpParamDef load_args[] =
191
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
190
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
192
191
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
193
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to load" }
192
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to load" }
196
static GimpParamDef load_return_vals[] =
195
static const GimpParamDef load_return_vals[] =
198
197
{ GIMP_PDB_IMAGE, "image", "Output image" }
201
static GimpParamDef save_args[] =
200
static const GimpParamDef save_args[] =
203
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
202
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
204
203
{ GIMP_PDB_IMAGE, "image", "Input image" },
205
204
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
206
205
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
207
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" },
206
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to save the image in" },
208
207
{ GIMP_PDB_INT32, "rle", "Specify non-zero for rle output, zero for standard output" }
211
gimp_install_procedure ("file_sunras_load",
210
gimp_install_procedure (LOAD_PROC,
212
211
"load file of the SunRaster file format",
213
212
"load file of the SunRaster file format",
214
213
"Peter Kirchgessner",
221
220
G_N_ELEMENTS (load_return_vals),
222
221
load_args, load_return_vals);
224
gimp_register_file_handler_mime ("file_sunras_load", "image/x-sun-raster");
225
gimp_register_magic_load_handler ("file_sunras_load",
223
gimp_register_file_handler_mime (LOAD_PROC, "image/x-sun-raster");
224
gimp_register_magic_load_handler (LOAD_PROC,
226
225
"im1,im8,im24,im32,rs,ras",
228
227
"0,long,0x59a66a95");
230
gimp_install_procedure ("file_sunras_save",
229
gimp_install_procedure (SAVE_PROC,
231
230
"save file in the SunRaster file format",
232
231
"SUNRAS saving handles all image types except "
233
232
"those with alpha channels.",
240
239
G_N_ELEMENTS (save_args), 0,
241
240
save_args, NULL);
243
gimp_register_file_handler_mime ("file_sunras_save", "image/x-sun-raster");
244
gimp_register_save_handler ("file_sunras_save",
242
gimp_register_file_handler_mime (SAVE_PROC, "image/x-sun-raster");
243
gimp_register_save_handler (SAVE_PROC,
245
244
"im1,im8,im24,im32,rs,ras", "");
269
268
values[0].type = GIMP_PDB_STATUS;
270
269
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
272
if (strcmp (name, "file_sunras_load") == 0)
271
if (strcmp (name, LOAD_PROC) == 0)
274
273
image_ID = load_image (param[1].data.d_string);
284
283
status = GIMP_PDB_EXECUTION_ERROR;
287
else if (strcmp (name, "file_sunras_save") == 0)
286
else if (strcmp (name, SAVE_PROC) == 0)
289
288
image_ID = param[1].data.d_int32;
290
289
drawable_ID = param[2].data.d_int32;
295
294
case GIMP_RUN_INTERACTIVE:
296
295
case GIMP_RUN_WITH_LAST_VALS:
297
gimp_ui_init ("sunras", FALSE);
296
gimp_ui_init (PLUG_IN_BINARY, FALSE);
298
297
export = gimp_export_image (&image_ID, &drawable_ID, "SUNRAS",
299
298
(GIMP_EXPORT_CAN_HANDLE_RGB |
300
299
GIMP_EXPORT_CAN_HANDLE_GRAY |
314
313
case GIMP_RUN_INTERACTIVE:
315
314
/* Possibly retrieve data */
316
gimp_get_data ("file_sunras_save", &psvals);
315
gimp_get_data (SAVE_PROC, &psvals);
318
317
/* First acquire information with a dialog */
319
318
if (! save_dialog ())
346
345
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
348
347
/* Store psvals data */
349
gimp_set_data ("file_sunras_save", &psvals,
350
sizeof (SUNRASSaveVals));
348
gimp_set_data (SAVE_PROC, &psvals, sizeof (SUNRASSaveVals));
375
char *temp = ident; /* Just to satisfy gcc/lint */
376
373
L_SUNFILEHEADER sunhdr;
377
374
guchar *suncolmap = NULL;
379
ifp = fopen (filename, "rb");
376
ifp = g_fopen (filename, "rb");
382
379
g_message (_("Could not open '%s' for reading: %s"),
433
430
*4 + sunhdr.l_ras_maplength, SEEK_SET);
436
temp = g_strdup_printf (_("Opening '%s'..."),
437
gimp_filename_to_utf8 (filename));
438
gimp_progress_init (temp);
433
gimp_progress_init_printf (_("Opening '%s'"),
434
gimp_filename_to_utf8 (filename));
441
436
switch (sunhdr.l_ras_depth)
518
temp = g_strdup_printf (_("Saving '%s'..."),
519
gimp_filename_to_utf8 (filename));
520
gimp_progress_init (temp);
512
gimp_progress_init_printf (_("Saving '%s'"),
513
gimp_filename_to_utf8 (filename));
523
515
if (drawable_type == GIMP_INDEXED_IMAGE)
524
516
retval = save_index (ofp,image_ID, drawable_ID, 0, (int)psvals.rle);
1572
1564
static gboolean
1573
1565
save_dialog (void)
1576
1568
GtkWidget *frame;
1579
dlg = gimp_dialog_new (_("Save as SUNRAS"), "sunras",
1581
gimp_standard_help_func, "file-sunras-save",
1583
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1584
GTK_STOCK_OK, GTK_RESPONSE_OK,
1571
dialog = gimp_dialog_new (_("Save as SUNRAS"), PLUG_IN_BINARY,
1573
gimp_standard_help_func, SAVE_PROC,
1575
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1576
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
1580
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
1582
GTK_RESPONSE_CANCEL,
1585
gimp_window_set_transient (GTK_WINDOW (dialog));
1588
1587
/* file save type */
1589
1588
frame = gimp_int_radio_group_new (TRUE, _("Data Formatting"),
1598
1597
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
1599
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
1598
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
1599
frame, TRUE, TRUE, 0);
1600
1600
gtk_widget_show (frame);
1602
gtk_widget_show (dlg);
1604
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
1606
gtk_widget_destroy (dlg);
1602
gtk_widget_show (dialog);
1604
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
1606
gtk_widget_destroy (dialog);