1997-11-25 06:05:25 +08:00
|
|
|
/*
|
2009-01-18 06:28:01 +08:00
|
|
|
* SGI image file plug-in for GIMP.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* Copyright 1997-1998 Michael Sweet (mike@easysw.com)
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at your option)
|
|
|
|
* any later version.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* Contents:
|
|
|
|
*
|
|
|
|
* main() - Main entry - just call gimp_main()...
|
|
|
|
* query() - Respond to a plug-in query...
|
|
|
|
* run() - Run the plug-in...
|
|
|
|
* load_image() - Load a PNG image into a new image window.
|
2024-04-13 23:10:25 +08:00
|
|
|
* export_image() - Export the specified image to a PNG file.
|
2016-02-16 09:35:43 +08:00
|
|
|
* save_ok_callback() - Destroy the export dialog and export the image.
|
|
|
|
* save_dialog() - Pop up the export dialog.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2000-01-01 23:38:59 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2005-03-04 21:23:32 +08:00
|
|
|
#include <string.h>
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <libgimp/gimp.h>
|
1999-10-20 09:45:41 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2008-03-25 06:07:14 +08:00
|
|
|
#include "sgi-lib.h"
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
2000-01-26 01:46:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
#define LOAD_PROC "file-sgi-load"
|
2024-04-13 23:10:25 +08:00
|
|
|
#define EXPORT_PROC "file-sgi-export"
|
2008-08-11 18:06:13 +08:00
|
|
|
#define PLUG_IN_BINARY "file-sgi"
|
2000-01-13 23:39:26 +08:00
|
|
|
#define PLUG_IN_VERSION "1.1.1 - 17 May 1998"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
typedef struct _Sgi Sgi;
|
|
|
|
typedef struct _SgiClass SgiClass;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
struct _Sgi
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
1999-10-20 09:45:41 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
struct _SgiClass
|
|
|
|
{
|
|
|
|
GimpPlugInClass parent_class;
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
#define SGI_TYPE (sgi_get_type ())
|
2023-10-19 00:29:37 +08:00
|
|
|
#define SGI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SGI_TYPE, Sgi))
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
GType sgi_get_type (void) G_GNUC_CONST;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2023-08-06 01:07:04 +08:00
|
|
|
static GList * sgi_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * sgi_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static GimpValueArray * sgi_load (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GFile *file,
|
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpMetadataLoadFlags *flags,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data);
|
2024-04-13 23:10:25 +08:00
|
|
|
static GimpValueArray * sgi_export (GimpProcedure *procedure,
|
2023-08-06 01:07:04 +08:00
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
2024-05-07 02:38:12 +08:00
|
|
|
GimpExportOptions *options,
|
2023-08-06 01:07:04 +08:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data);
|
|
|
|
|
|
|
|
static GimpImage * load_image (GFile *file,
|
|
|
|
GError **error);
|
2024-04-13 23:10:25 +08:00
|
|
|
static gint export_image (GFile *file,
|
2023-08-06 01:07:04 +08:00
|
|
|
GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GObject *config,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static gboolean save_dialog (GimpProcedure *procedure,
|
|
|
|
GObject *config,
|
|
|
|
GimpImage *image);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (Sgi, sgi, GIMP_TYPE_PLUG_IN)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
GIMP_MAIN (SGI_TYPE)
|
2022-05-26 06:59:36 +08:00
|
|
|
DEFINE_STD_SET_I18N
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2019-08-16 03:37:43 +08:00
|
|
|
sgi_class_init (SgiClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-16 03:37:43 +08:00
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
|
|
|
|
|
|
|
plug_in_class->query_procedures = sgi_query_procedures;
|
|
|
|
plug_in_class->create_procedure = sgi_create_procedure;
|
2022-05-26 06:59:36 +08:00
|
|
|
plug_in_class->set_i18n = STD_SET_I18N;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-08-16 03:37:43 +08:00
|
|
|
sgi_init (Sgi *sgi)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-16 03:37:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
sgi_query_procedures (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
GList *list = NULL;
|
|
|
|
|
|
|
|
list = g_list_append (list, g_strdup (LOAD_PROC));
|
2024-04-13 23:10:25 +08:00
|
|
|
list = g_list_append (list, g_strdup (EXPORT_PROC));
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpProcedure *
|
|
|
|
sgi_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = NULL;
|
|
|
|
|
|
|
|
if (! strcmp (name, LOAD_PROC))
|
|
|
|
{
|
2023-08-06 09:21:27 +08:00
|
|
|
procedure = gimp_load_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
sgi_load, NULL, NULL);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
gimp_procedure_set_menu_label (procedure,
|
2023-12-12 03:13:06 +08:00
|
|
|
_("Silicon Graphics IRIS image"));
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2023-04-02 01:41:51 +08:00
|
|
|
_("Loads files in SGI image file format"),
|
|
|
|
_("This plug-in loads SGI image files."),
|
2019-08-16 03:37:43 +08:00
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Michael Sweet <mike@easysw.com>",
|
|
|
|
"Copyright 1997-1998 by Michael Sweet",
|
|
|
|
PLUG_IN_VERSION);
|
|
|
|
|
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"image/x-sgi");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"sgi,rgb,rgba,bw,icon");
|
|
|
|
gimp_file_procedure_set_magics (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"0,short,474");
|
|
|
|
}
|
2024-04-13 23:10:25 +08:00
|
|
|
else if (! strcmp (name, EXPORT_PROC))
|
2019-08-16 03:37:43 +08:00
|
|
|
{
|
2024-04-20 11:08:57 +08:00
|
|
|
procedure = gimp_export_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
FALSE, sgi_export, NULL, NULL);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
gimp_procedure_set_image_types (procedure, "*");
|
|
|
|
|
|
|
|
gimp_procedure_set_menu_label (procedure,
|
2023-12-12 03:13:06 +08:00
|
|
|
_("Silicon Graphics IRIS image"));
|
2023-04-02 01:41:51 +08:00
|
|
|
gimp_file_procedure_set_format_name (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"SGI");
|
2019-08-18 19:45:58 +08:00
|
|
|
gimp_procedure_set_icon_name (procedure, GIMP_ICON_BRUSH);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2023-04-02 01:41:51 +08:00
|
|
|
_("Exports files in SGI image file format"),
|
|
|
|
_("This plug-in exports SGI image files."),
|
2019-08-16 03:37:43 +08:00
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Michael Sweet <mike@easysw.com>",
|
|
|
|
"Copyright 1997-1998 by Michael Sweet",
|
|
|
|
PLUG_IN_VERSION);
|
|
|
|
|
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"image/x-sgi");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"sgi,rgb,rgba,bw,icon");
|
|
|
|
|
2024-05-07 02:38:12 +08:00
|
|
|
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_RGB |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_INDEXED |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA,
|
app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
actually introspectable with the GimpImage being both input and
output. Even though the logic doesn't change much (the input image may
be overriden or not), it doesn't matter for introspection because
images are handled centrally by libgimp and therefore must not be
freed. Actually deleting the image from the central list of images
though remains a manual action depending on code logic, not some
automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
because ignoring the returned value is rarely a good idea (as you
usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
because at this point, the best is to tell plug-in developers to just
pass NULL everywhere. This leaves us free to create a more useful
default constructor if needed, in the future. Main description for
GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
args would actually be (nullable) and would not transfer ownership
(calling code must still free the object). Return value's ownership on
the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
gimp_export_options_get_image() in particular.
- Fix or improve various details.
Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-17 21:06:27 +08:00
|
|
|
NULL, NULL, NULL);
|
2024-05-07 02:38:12 +08:00
|
|
|
|
2024-08-19 22:40:46 +08:00
|
|
|
gimp_procedure_add_choice_argument (procedure, "compression",
|
|
|
|
_("Compression _type"),
|
|
|
|
_("Compression level"),
|
|
|
|
gimp_choice_new_with_values ("none", SGI_COMP_NONE, _("No compression"), NULL,
|
|
|
|
"rle", SGI_COMP_RLE, _("RLE compression"), NULL,
|
|
|
|
"arle", SGI_COMP_ARLE, _("Aggressive RLE (not supported by SGI)"), NULL,
|
|
|
|
NULL),
|
|
|
|
"rle",
|
|
|
|
G_PARAM_READWRITE);
|
2019-08-16 03:37:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpValueArray *
|
2023-08-06 01:07:04 +08:00
|
|
|
sgi_load (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GFile *file,
|
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpMetadataLoadFlags *flags,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
2019-08-16 03:37:43 +08:00
|
|
|
{
|
|
|
|
GimpValueArray *return_vals;
|
2019-08-16 06:31:10 +08:00
|
|
|
GimpImage *image;
|
2019-08-16 03:37:43 +08:00
|
|
|
GError *error = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-11-28 03:58:05 +08:00
|
|
|
gegl_init (NULL, NULL);
|
|
|
|
|
2019-09-12 03:48:34 +08:00
|
|
|
image = load_image (file, &error);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
if (! image)
|
2019-08-16 03:37:43 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_EXECUTION_ERROR,
|
|
|
|
error);
|
|
|
|
|
|
|
|
return_vals = gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_SUCCESS,
|
|
|
|
NULL);
|
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
GIMP_VALUES_SET_IMAGE (return_vals, 1, image);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
static GimpValueArray *
|
2024-04-13 23:10:25 +08:00
|
|
|
sgi_export (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
2024-05-07 02:38:12 +08:00
|
|
|
GimpExportOptions *options,
|
2024-04-13 23:10:25 +08:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
2019-08-16 03:37:43 +08:00
|
|
|
{
|
2023-07-21 05:58:41 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2024-04-30 12:25:51 +08:00
|
|
|
GimpExportReturn export = GIMP_EXPORT_IGNORE;
|
2024-04-30 21:50:24 +08:00
|
|
|
GList *drawables;
|
2023-07-21 05:58:41 +08:00
|
|
|
GError *error = NULL;
|
2012-11-28 03:58:05 +08:00
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
gegl_init (NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2024-07-15 04:12:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2019-09-21 01:39:00 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
2019-08-16 03:37:43 +08:00
|
|
|
|
2023-04-02 01:41:51 +08:00
|
|
|
if (! save_dialog (procedure, G_OBJECT (config), image))
|
2019-08-16 03:37:43 +08:00
|
|
|
status = GIMP_PDB_CANCEL;
|
2019-09-24 07:00:53 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2024-05-07 02:38:12 +08:00
|
|
|
export = gimp_export_options_get_image (options, &image);
|
2024-07-15 04:12:57 +08:00
|
|
|
drawables = gimp_image_list_layers (image);
|
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
2024-04-30 21:50:24 +08:00
|
|
|
if (! export_image (file, image, drawables->data,
|
2024-04-13 23:10:25 +08:00
|
|
|
G_OBJECT (config), &error))
|
2005-08-12 23:46:46 +08:00
|
|
|
{
|
2019-08-16 03:37:43 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2005-08-12 23:46:46 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
2019-08-16 03:37:43 +08:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2024-04-30 21:50:24 +08:00
|
|
|
gimp_image_delete (image);
|
2008-08-20 20:49:41 +08:00
|
|
|
|
2024-04-30 21:50:24 +08:00
|
|
|
g_list_free (drawables);
|
2019-08-16 03:37:43 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure, status, error);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
static GimpImage *
|
2019-09-12 03:48:34 +08:00
|
|
|
load_image (GFile *file,
|
|
|
|
GError **error)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-08-20 20:49:41 +08:00
|
|
|
gint i, /* Looping var */
|
2004-06-06 02:46:05 +08:00
|
|
|
x, /* Current X coordinate */
|
|
|
|
y, /* Current Y coordinate */
|
|
|
|
image_type, /* Type of image */
|
|
|
|
layer_type, /* Type of drawable/layer */
|
|
|
|
tile_height, /* Height of tile in GIMP */
|
|
|
|
count, /* Count of rows to put in image */
|
|
|
|
bytes; /* Number of channels to use */
|
|
|
|
sgi_t *sgip; /* File pointer */
|
2019-08-16 06:31:10 +08:00
|
|
|
GimpImage *image; /* Image */
|
|
|
|
GimpLayer *layer; /* Layer */
|
2012-09-23 02:14:19 +08:00
|
|
|
GeglBuffer *buffer; /* Buffer for layer */
|
2004-06-06 02:46:05 +08:00
|
|
|
guchar **pixels, /* Pixel rows */
|
|
|
|
*pptr; /* Current pixel */
|
|
|
|
gushort **rows; /* SGI image data */
|
2021-05-19 06:52:02 +08:00
|
|
|
GimpPrecision precision;
|
|
|
|
const Babl *bablfmt = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Open the file for reading...
|
|
|
|
*/
|
|
|
|
|
2014-07-23 22:39:00 +08:00
|
|
|
gimp_progress_init_printf (_("Opening '%s'"),
|
2019-09-12 03:48:34 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2014-07-23 22:39:00 +08:00
|
|
|
|
2021-10-02 00:14:14 +08:00
|
|
|
sgip = sgiOpen (g_file_peek_path (file), SGI_READ, 0, 0, 0, 0, 0);
|
2019-09-12 03:48:34 +08:00
|
|
|
|
|
|
|
if (! sgip)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2008-08-20 20:49:41 +08:00
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
_("Could not open '%s' for reading."),
|
2019-09-12 03:48:34 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2019-10-23 20:32:11 +08:00
|
|
|
free (sgip);
|
2019-08-16 06:31:10 +08:00
|
|
|
return NULL;
|
2000-01-26 01:46:56 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Get the image dimensions and create the image...
|
|
|
|
*/
|
2004-06-06 02:46:05 +08:00
|
|
|
|
2010-10-05 14:04:17 +08:00
|
|
|
/* Sanitize dimensions (note that they are unsigned short and can
|
|
|
|
* thus never be larger than GIMP_MAX_IMAGE_SIZE
|
|
|
|
*/
|
|
|
|
if (sgip->xsize == 0 /*|| sgip->xsize > GIMP_MAX_IMAGE_SIZE*/)
|
2009-12-09 22:43:28 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
_("Invalid width: %hu"), sgip->xsize);
|
2019-10-23 20:32:11 +08:00
|
|
|
free (sgip);
|
2019-08-16 06:31:10 +08:00
|
|
|
return NULL;
|
2009-12-09 22:43:28 +08:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:04:17 +08:00
|
|
|
if (sgip->ysize == 0 /*|| sgip->ysize > GIMP_MAX_IMAGE_SIZE*/)
|
2009-12-09 22:43:28 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
_("Invalid height: %hu"), sgip->ysize);
|
2019-10-23 20:32:11 +08:00
|
|
|
free (sgip);
|
2019-08-16 06:31:10 +08:00
|
|
|
return NULL;
|
2009-12-09 22:43:28 +08:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:04:17 +08:00
|
|
|
if (sgip->zsize == 0 /*|| sgip->zsize > GIMP_MAX_IMAGE_SIZE*/)
|
2009-12-09 22:43:28 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
_("Invalid number of channels: %hu"), sgip->zsize);
|
2019-10-23 20:32:11 +08:00
|
|
|
free (sgip);
|
2019-08-16 06:31:10 +08:00
|
|
|
return NULL;
|
2009-12-09 22:43:28 +08:00
|
|
|
}
|
|
|
|
|
2004-06-06 02:46:05 +08:00
|
|
|
bytes = sgip->zsize;
|
2005-02-13 08:11:24 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (sgip->zsize)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2005-08-12 23:46:46 +08:00
|
|
|
case 1 : /* Grayscale */
|
2000-08-24 07:11:07 +08:00
|
|
|
image_type = GIMP_GRAY;
|
|
|
|
layer_type = GIMP_GRAY_IMAGE;
|
2021-05-19 06:52:02 +08:00
|
|
|
if (sgip->bpp == 1)
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U8_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("Y' u8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U16_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("Y' u16");
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
case 2 : /* Grayscale + alpha */
|
2000-08-24 07:11:07 +08:00
|
|
|
image_type = GIMP_GRAY;
|
|
|
|
layer_type = GIMP_GRAYA_IMAGE;
|
2021-05-19 06:52:02 +08:00
|
|
|
if (sgip->bpp == 1)
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U8_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("Y'A u8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U16_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("Y'A u16");
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
case 3 : /* RGB */
|
2000-08-24 07:11:07 +08:00
|
|
|
image_type = GIMP_RGB;
|
|
|
|
layer_type = GIMP_RGB_IMAGE;
|
2021-05-19 06:52:02 +08:00
|
|
|
if (sgip->bpp == 1)
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U8_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B' u8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U16_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B' u16");
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
case 4 : /* RGBA */
|
2000-08-24 07:11:07 +08:00
|
|
|
image_type = GIMP_RGB;
|
|
|
|
layer_type = GIMP_RGBA_IMAGE;
|
2021-05-19 06:52:02 +08:00
|
|
|
if (sgip->bpp == 1)
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U8_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B'A u8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U16_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B'A u16");
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
2005-02-13 08:11:24 +08:00
|
|
|
|
2004-06-06 02:46:05 +08:00
|
|
|
default:
|
|
|
|
image_type = GIMP_RGB;
|
|
|
|
layer_type = GIMP_RGBA_IMAGE;
|
|
|
|
bytes = 4;
|
2021-05-19 06:52:02 +08:00
|
|
|
if (sgip->bpp == 1)
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U8_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B'A u8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
precision = GIMP_PRECISION_U16_NON_LINEAR;
|
|
|
|
bablfmt = babl_format ("R'G'B'A u16");
|
|
|
|
}
|
2004-06-06 02:46:05 +08:00
|
|
|
break;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2021-05-19 06:52:02 +08:00
|
|
|
image = gimp_image_new_with_precision (sgip->xsize, sgip->ysize,
|
|
|
|
image_type, precision);
|
2019-08-16 06:31:10 +08:00
|
|
|
if (! image)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2008-08-20 20:49:41 +08:00
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
"Could not allocate new image: %s",
|
2019-08-16 03:37:43 +08:00
|
|
|
gimp_pdb_get_last_error (gimp_get_pdb ()));
|
2019-10-23 20:32:11 +08:00
|
|
|
free (sgip);
|
2019-08-16 06:31:10 +08:00
|
|
|
return NULL;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Create the "background" layer to hold the image...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-01 23:38:59 +08:00
|
|
|
layer = gimp_layer_new (image, _("Background"), sgip->xsize, sgip->ysize,
|
2017-01-09 06:00:19 +08:00
|
|
|
layer_type,
|
2017-08-22 02:04:25 +08:00
|
|
|
100,
|
|
|
|
gimp_image_get_default_new_layer_mode (image));
|
2019-08-16 06:31:10 +08:00
|
|
|
gimp_image_insert_layer (image, layer, NULL, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Get the drawable and set the pixel region for our load...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Temporary buffers...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-19 21:29:25 +08:00
|
|
|
tile_height = gimp_tile_height ();
|
|
|
|
pixels = g_new (guchar *, tile_height);
|
2021-05-19 06:52:02 +08:00
|
|
|
pixels[0] = g_new (guchar, ((gsize) tile_height) * sgip->xsize * sgip->bpp * bytes);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-12-10 00:11:21 +08:00
|
|
|
for (i = 1; i < tile_height; i ++)
|
2021-05-19 06:52:02 +08:00
|
|
|
pixels[i] = pixels[0] + sgip->xsize * sgip->bpp * bytes * i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-19 21:29:25 +08:00
|
|
|
rows = g_new (unsigned short *, sgip->zsize);
|
2009-12-07 23:21:44 +08:00
|
|
|
rows[0] = g_new (unsigned short, ((gsize) sgip->xsize) * sgip->zsize);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 1; i < sgip->zsize; i ++)
|
|
|
|
rows[i] = rows[0] + i * sgip->xsize;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Load the image...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (y = 0, count = 0;
|
|
|
|
y < sgip->ysize;
|
|
|
|
y ++, count ++)
|
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
if (count >= tile_height)
|
2005-08-12 23:46:46 +08:00
|
|
|
{
|
2012-09-23 02:14:19 +08:00
|
|
|
gegl_buffer_set (buffer, GEGL_RECTANGLE (0, y - count,
|
|
|
|
sgip->xsize, count), 0,
|
2021-05-19 06:52:02 +08:00
|
|
|
bablfmt, pixels[0], GEGL_AUTO_ROWSTRIDE);
|
2012-09-23 02:14:19 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
count = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
gimp_progress_update ((double) y / (double) sgip->ysize);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
for (i = 0; i < sgip->zsize; i ++)
|
2005-08-12 23:46:46 +08:00
|
|
|
if (sgiGetRow (sgip, rows[i], sgip->ysize - 1 - y, i) < 0)
|
2018-10-22 21:41:18 +08:00
|
|
|
g_printerr ("sgiGetRow(sgip, rows[i], %d, %d) failed!\n",
|
|
|
|
sgip->ysize - 1 - y, i);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
if (sgip->bpp == 1)
|
2005-08-12 23:46:46 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 8-bit (unsigned) pixels...
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++)
|
|
|
|
for (i = 0; i < bytes; i ++, pptr ++)
|
|
|
|
*pptr = rows[i][x];
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
else
|
2005-08-12 23:46:46 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 16-bit (unsigned) pixels...
|
|
|
|
*/
|
|
|
|
|
2021-05-19 06:52:02 +08:00
|
|
|
guint16 *pixels16;
|
|
|
|
|
|
|
|
for (x = 0, pixels16 = (guint16 *) pixels[count]; x < sgip->xsize; x ++)
|
|
|
|
for (i = 0; i < bytes; i ++, pixels16 ++)
|
|
|
|
*pixels16 = rows[i][x];
|
2005-08-12 23:46:46 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Do the last n rows (count always > 0)
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
gegl_buffer_set (buffer, GEGL_RECTANGLE (0, y - count,
|
|
|
|
sgip->xsize, count), 0,
|
2021-05-19 06:52:02 +08:00
|
|
|
bablfmt, pixels[0], GEGL_AUTO_ROWSTRIDE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Done with the file...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
sgiClose (sgip);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-12-10 00:11:21 +08:00
|
|
|
g_free (pixels[0]);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_free (pixels);
|
|
|
|
g_free (rows[0]);
|
|
|
|
g_free (rows);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
g_object_unref (buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
gimp_progress_update (1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-19 21:29:25 +08:00
|
|
|
return image;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2024-04-13 23:10:25 +08:00
|
|
|
export_image (GFile *file,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GObject *config,
|
|
|
|
GError **error)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-09-24 07:00:53 +08:00
|
|
|
gint compression;
|
|
|
|
gint i, j; /* Looping var */
|
|
|
|
gint x; /* Current X coordinate */
|
|
|
|
gint y; /* Current Y coordinate */
|
|
|
|
gint width; /* Drawable width */
|
|
|
|
gint height; /* Drawable height */
|
|
|
|
gint tile_height; /* Height of tile in GIMP */
|
|
|
|
gint count; /* Count of rows to put in image */
|
|
|
|
gint zsize; /* Number of channels in file */
|
2012-09-23 02:14:19 +08:00
|
|
|
sgi_t *sgip; /* File pointer */
|
|
|
|
GeglBuffer *buffer; /* Buffer for layer */
|
|
|
|
const Babl *format;
|
2019-09-24 07:00:53 +08:00
|
|
|
guchar **pixels; /* Pixel rows */
|
|
|
|
guchar *pptr; /* Current pixel */
|
2012-09-23 02:14:19 +08:00
|
|
|
gushort **rows; /* SGI image data */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2024-08-19 22:40:46 +08:00
|
|
|
compression =
|
|
|
|
gimp_procedure_config_get_choice_id (GIMP_PROCEDURE_CONFIG (config),
|
|
|
|
"compression");
|
2019-09-24 07:00:53 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
|
|
|
* Get the drawable for the current image...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2021-04-06 20:28:40 +08:00
|
|
|
width = gimp_drawable_get_width (drawable);
|
|
|
|
height = gimp_drawable_get_height (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
buffer = gimp_drawable_get_buffer (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-16 06:31:10 +08:00
|
|
|
switch (gimp_drawable_type (drawable))
|
1999-11-27 04:58:27 +08:00
|
|
|
{
|
2012-09-23 02:14:19 +08:00
|
|
|
case GIMP_GRAY_IMAGE:
|
2000-01-26 01:46:56 +08:00
|
|
|
zsize = 1;
|
2012-09-23 02:14:19 +08:00
|
|
|
format = babl_format ("Y' u8");
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
2012-11-28 03:58:05 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
case GIMP_GRAYA_IMAGE:
|
2000-01-26 01:46:56 +08:00
|
|
|
zsize = 2;
|
2012-09-23 02:14:19 +08:00
|
|
|
format = babl_format ("Y'A u8");
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
2012-11-28 03:58:05 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
case GIMP_RGB_IMAGE:
|
|
|
|
case GIMP_INDEXED_IMAGE:
|
2000-01-26 01:46:56 +08:00
|
|
|
zsize = 3;
|
2012-09-23 02:14:19 +08:00
|
|
|
format = babl_format ("R'G'B' u8");
|
2000-01-26 01:46:56 +08:00
|
|
|
break;
|
2012-11-28 03:58:05 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
case GIMP_RGBA_IMAGE:
|
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
|
|
|
format = babl_format ("R'G'B'A u8");
|
2000-01-26 01:46:56 +08:00
|
|
|
zsize = 4;
|
|
|
|
break;
|
2012-11-28 03:58:05 +08:00
|
|
|
|
1999-11-27 04:58:27 +08:00
|
|
|
default:
|
1999-11-27 10:54:25 +08:00
|
|
|
return FALSE;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
|
|
|
* Open the file for writing...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2016-02-16 09:35:43 +08:00
|
|
|
gimp_progress_init_printf (_("Exporting '%s'"),
|
2019-09-12 03:48:34 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2014-07-23 22:39:00 +08:00
|
|
|
|
2021-10-02 00:14:14 +08:00
|
|
|
sgip = sgiOpen (g_file_peek_path (file), SGI_WRITE, compression, 1,
|
2012-09-23 02:14:19 +08:00
|
|
|
width, height, zsize);
|
2019-09-12 03:48:34 +08:00
|
|
|
|
|
|
|
if (! sgip)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2008-08-20 20:49:41 +08:00
|
|
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
|
|
_("Could not open '%s' for writing."),
|
2019-09-12 03:48:34 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2000-01-13 23:39:26 +08:00
|
|
|
return FALSE;
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
|
|
|
* Allocate memory for "tile_height" rows...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-19 21:29:25 +08:00
|
|
|
tile_height = gimp_tile_height ();
|
|
|
|
pixels = g_new (guchar *, tile_height);
|
2012-09-23 02:14:19 +08:00
|
|
|
pixels[0] = g_new (guchar, ((gsize) tile_height) * width * zsize);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-12-10 00:11:21 +08:00
|
|
|
for (i = 1; i < tile_height; i ++)
|
2012-09-23 02:14:19 +08:00
|
|
|
pixels[i]= pixels[0] + width * zsize * i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
rows = g_new (gushort *, sgip->zsize);
|
2009-12-07 23:21:44 +08:00
|
|
|
rows[0] = g_new (gushort, ((gsize) sgip->xsize) * sgip->zsize);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 1; i < sgip->zsize; i ++)
|
|
|
|
rows[i] = rows[0] + i * sgip->xsize;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/*
|
2024-04-13 23:10:25 +08:00
|
|
|
* Export the image...
|
2000-01-26 01:46:56 +08:00
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
for (y = 0; y < height; y += count)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Grab more pixel data...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
if ((y + tile_height) >= height)
|
|
|
|
count = height - y;
|
2000-01-13 23:39:26 +08:00
|
|
|
else
|
2005-08-12 23:46:46 +08:00
|
|
|
count = tile_height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
gegl_buffer_get (buffer, GEGL_RECTANGLE (0, y, width, count), 1.0,
|
|
|
|
format, pixels[0],
|
|
|
|
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
|
|
|
* Convert to shorts and write each color plane separately...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
for (i = 0, pptr = pixels[0]; i < count; i ++)
|
2005-08-12 23:46:46 +08:00
|
|
|
{
|
2012-09-23 02:14:19 +08:00
|
|
|
for (x = 0; x < width; x ++)
|
2005-08-12 23:46:46 +08:00
|
|
|
for (j = 0; j < zsize; j ++, pptr ++)
|
|
|
|
rows[j][x] = *pptr;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
for (j = 0; j < zsize; j ++)
|
2012-09-23 02:14:19 +08:00
|
|
|
sgiPutRow (sgip, rows[j], height - 1 - y - i, j);
|
2005-08-12 23:46:46 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
gimp_progress_update ((double) y / (double) height);
|
2011-04-11 01:05:08 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
|
|
|
* Done with the file...
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
sgiClose (sgip);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-12-10 00:11:21 +08:00
|
|
|
g_free (pixels[0]);
|
2000-01-13 23:39:26 +08:00
|
|
|
g_free (pixels);
|
|
|
|
g_free (rows[0]);
|
|
|
|
g_free (rows);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2012-09-23 02:14:19 +08:00
|
|
|
g_object_unref (buffer);
|
|
|
|
|
|
|
|
gimp_progress_update (1.0);
|
|
|
|
|
1999-11-27 10:54:25 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-05-21 19:16:27 +08:00
|
|
|
static gboolean
|
2019-09-24 07:00:53 +08:00
|
|
|
save_dialog (GimpProcedure *procedure,
|
2023-04-02 01:41:51 +08:00
|
|
|
GObject *config,
|
|
|
|
GimpImage *image)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2024-08-19 22:40:46 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
gboolean run;
|
2019-09-24 07:00:53 +08:00
|
|
|
|
2024-04-20 11:08:57 +08:00
|
|
|
dialog = gimp_export_procedure_dialog_new (GIMP_EXPORT_PROCEDURE (procedure),
|
|
|
|
GIMP_PROCEDURE_CONFIG (config),
|
|
|
|
image);
|
2019-09-24 07:00:53 +08:00
|
|
|
|
2023-04-02 01:41:51 +08:00
|
|
|
vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
|
|
|
|
"sgi-vbox", "compression", NULL);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
2019-09-24 07:00:53 +08:00
|
|
|
|
2023-04-02 01:41:51 +08:00
|
|
|
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
|
|
|
|
"sgi-vbox", NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_show (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2023-04-02 01:41:51 +08:00
|
|
|
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|