95
static GimpParamDef load_args[] =
92
static const GimpParamDef load_args[] =
97
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
94
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
98
95
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
99
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to load" },
96
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to load" },
101
static GimpParamDef load_return_vals[] =
98
static const GimpParamDef load_return_vals[] =
103
100
{ GIMP_PDB_IMAGE, "image", "Output image" },
106
static GimpParamDef save_args[] =
103
static const GimpParamDef save_args[] =
108
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
109
{ GIMP_PDB_IMAGE, "image", "Input image" },
110
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
111
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
112
{ GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" },
113
{ GIMP_PDB_INT32, "compression", "Compression level (0 = none, 1 = RLE, 2 = ARLE)" }
105
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
106
{ GIMP_PDB_IMAGE, "image", "Input image" },
107
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
108
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
109
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to save the image in" },
110
{ GIMP_PDB_INT32, "compression", "Compression level (0 = none, 1 = RLE, 2 = ARLE)" }
116
gimp_install_procedure ("file_sgi_load",
117
"Loads files in SGI image file format",
118
"This plug-in loads SGI image files.",
119
"Michael Sweet <mike@easysw.com>",
120
"Copyright 1997-1998 by Michael Sweet",
122
N_("Silicon Graphics IRIS image"),
125
G_N_ELEMENTS (load_args),
126
G_N_ELEMENTS (load_return_vals),
130
gimp_register_file_handler_mime ("file_sgi_load", "image/x-sgi");
131
gimp_register_magic_load_handler ("file_sgi_load",
136
gimp_install_procedure ("file_sgi_save",
137
"Saves files in SGI image file format",
138
"This plug-in saves SGI image files.",
139
"Michael Sweet <mike@easysw.com>",
140
"Copyright 1997-1998 by Michael Sweet",
142
N_("Silicon Graphics IRIS image"),
145
G_N_ELEMENTS (save_args),
150
gimp_register_file_handler_mime ("file_sgi_save", "image/x-sgi");
151
gimp_register_save_handler ("file_sgi_save", "sgi,rgb,bw,icon", "");
113
gimp_install_procedure (LOAD_PROC,
114
"Loads files in SGI image file format",
115
"This plug-in loads SGI image files.",
116
"Michael Sweet <mike@easysw.com>",
117
"Copyright 1997-1998 by Michael Sweet",
119
N_("Silicon Graphics IRIS image"),
122
G_N_ELEMENTS (load_args),
123
G_N_ELEMENTS (load_return_vals),
127
gimp_register_file_handler_mime (LOAD_PROC, "image/x-sgi");
128
gimp_register_magic_load_handler (LOAD_PROC,
133
gimp_install_procedure (SAVE_PROC,
134
"Saves files in SGI image file format",
135
"This plug-in saves SGI image files.",
136
"Michael Sweet <mike@easysw.com>",
137
"Copyright 1997-1998 by Michael Sweet",
139
N_("Silicon Graphics IRIS image"),
142
G_N_ELEMENTS (save_args),
147
gimp_register_file_handler_mime (SAVE_PROC, "image/x-sgi");
148
gimp_register_save_handler (SAVE_PROC, "sgi,rgb,bw,icon", "");
177
if (strcmp (name, "file_sgi_load") == 0)
174
if (strcmp (name, LOAD_PROC) == 0)
179
176
image_ID = load_image (param[1].data.d_string);
181
178
if (image_ID != -1)
184
values[1].type = GIMP_PDB_IMAGE;
185
values[1].data.d_image = image_ID;
181
values[1].type = GIMP_PDB_IMAGE;
182
values[1].data.d_image = image_ID;
189
status = GIMP_PDB_EXECUTION_ERROR;
186
status = GIMP_PDB_EXECUTION_ERROR;
192
else if (strcmp (name, "file_sgi_save") == 0)
189
else if (strcmp (name, SAVE_PROC) == 0)
194
191
image_ID = param[1].data.d_int32;
195
192
drawable_ID = param[2].data.d_int32;
197
194
/* eventually export the image */
198
195
switch (run_mode)
200
case GIMP_RUN_INTERACTIVE:
201
case GIMP_RUN_WITH_LAST_VALS:
202
gimp_ui_init ("sgi", FALSE);
203
export = gimp_export_image (&image_ID, &drawable_ID, "SGI",
204
(GIMP_EXPORT_CAN_HANDLE_RGB |
205
GIMP_EXPORT_CAN_HANDLE_GRAY |
206
GIMP_EXPORT_CAN_HANDLE_ALPHA));
207
if (export == GIMP_EXPORT_CANCEL)
209
values[0].data.d_status = GIMP_PDB_CANCEL;
197
case GIMP_RUN_INTERACTIVE:
198
case GIMP_RUN_WITH_LAST_VALS:
199
gimp_ui_init (PLUG_IN_BINARY, FALSE);
200
export = gimp_export_image (&image_ID, &drawable_ID, "SGI",
201
(GIMP_EXPORT_CAN_HANDLE_RGB |
202
GIMP_EXPORT_CAN_HANDLE_GRAY |
203
GIMP_EXPORT_CAN_HANDLE_ALPHA));
204
if (export == GIMP_EXPORT_CANCEL)
206
values[0].data.d_status = GIMP_PDB_CANCEL;
217
214
switch (run_mode)
219
case GIMP_RUN_INTERACTIVE:
221
* Possibly retrieve data...
223
gimp_get_data ("file_sgi_save", &compression);
216
case GIMP_RUN_INTERACTIVE:
218
* Possibly retrieve data...
220
gimp_get_data (SAVE_PROC, &compression);
226
* Then acquire information with a dialog...
223
* Then acquire information with a dialog...
228
225
if (!save_dialog ())
229
226
status = GIMP_PDB_CANCEL;
232
case GIMP_RUN_NONINTERACTIVE:
234
* Make sure all the arguments are there!
229
case GIMP_RUN_NONINTERACTIVE:
231
* Make sure all the arguments are there!
236
233
if (nparams != 6)
238
status = GIMP_PDB_CALLING_ERROR;
235
status = GIMP_PDB_CALLING_ERROR;
242
compression = param[5].data.d_int32;
244
if (compression < 0 || compression > 2)
245
status = GIMP_PDB_CALLING_ERROR;
249
case GIMP_RUN_WITH_LAST_VALS:
251
* Possibly retrieve data...
253
gimp_get_data ("file_sgi_save", &compression);
239
compression = param[5].data.d_int32;
241
if (compression < 0 || compression > 2)
242
status = GIMP_PDB_CALLING_ERROR;
246
case GIMP_RUN_WITH_LAST_VALS:
248
* Possibly retrieve data...
250
gimp_get_data (SAVE_PROC, &compression);
260
257
if (status == GIMP_PDB_SUCCESS)
262
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
264
gimp_set_data ("file_sgi_save",
265
&compression, sizeof (compression));
269
status = GIMP_PDB_EXECUTION_ERROR;
259
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
261
gimp_set_data (SAVE_PROC, &compression, sizeof (compression));
265
status = GIMP_PDB_EXECUTION_ERROR;
273
269
if (export == GIMP_EXPORT_EXPORT)
274
gimp_image_delete (image_ID);
270
gimp_image_delete (image_ID);
414
407
if (count >= tile_height)
416
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel,
417
0, y - count, drawable->width, count);
409
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel,
410
0, y - count, drawable->width, count);
420
gimp_progress_update ((double) y / (double) sgip->ysize);
413
gimp_progress_update ((double) y / (double) sgip->ysize);
423
416
for (i = 0; i < sgip->zsize; i ++)
424
if (sgiGetRow (sgip, rows[i], sgip->ysize - 1 - y, i) < 0)
425
printf("sgiGetRow(sgip, rows[i], %d, %d) failed!\n",
426
sgip->ysize - 1 - y, i);
417
if (sgiGetRow (sgip, rows[i], sgip->ysize - 1 - y, i) < 0)
418
printf("sgiGetRow(sgip, rows[i], %d, %d) failed!\n",
419
sgip->ysize - 1 - y, i);
428
421
if (sgip->bpp == 1)
431
* 8-bit (unsigned) pixels...
424
* 8-bit (unsigned) pixels...
434
for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++)
435
for (i = 0; i < bytes; i ++, pptr ++)
427
for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++)
428
for (i = 0; i < bytes; i ++, pptr ++)
441
* 16-bit (unsigned) pixels...
434
* 16-bit (unsigned) pixels...
444
for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++)
445
for (i = 0; i < bytes; i ++, pptr ++)
446
*pptr = rows[i][x] >> 8;
437
for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++)
438
for (i = 0; i < bytes; i ++, pptr ++)
439
*pptr = rows[i][x] >> 8;
616
606
save_dialog (void)
619
609
GtkWidget *frame;
622
dlg = gimp_dialog_new (_("Save as SGI"), "sgi",
624
gimp_standard_help_func, "file-sgi-save",
626
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
627
GTK_STOCK_OK, GTK_RESPONSE_OK,
612
dialog = gimp_dialog_new (_("Save as SGI"), PLUG_IN_BINARY,
614
gimp_standard_help_func, SAVE_PROC,
616
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
617
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
621
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
626
gimp_window_set_transient (GTK_WINDOW (dialog));
631
628
frame = gimp_int_radio_group_new (TRUE, _("Compression type"),
632
G_CALLBACK (gimp_radio_button_update),
633
&compression, compression,
637
_("RLE compression"),
639
_("Aggressive RLE\n(not supported by SGI)"),
629
G_CALLBACK (gimp_radio_button_update),
630
&compression, compression,
634
_("RLE compression"),
636
_("Aggressive RLE\n(not supported by SGI)"),
644
641
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
645
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0);
642
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
643
frame, TRUE, TRUE, 0);
646
644
gtk_widget_show (frame);
648
gtk_widget_show (dlg);
650
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
652
gtk_widget_destroy (dlg);
646
gtk_widget_show (dialog);
648
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
650
gtk_widget_destroy (dialog);