mirror of https://github.com/GNOME/gimp.git
parent
23f00ee6f0
commit
2a783d04a7
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Wed Oct 20 03:42:08 MEST 1999 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/Makefile.am
|
||||
* plug-ins/common/pix.c
|
||||
* plug-ins/common/plugin-defs.pl
|
||||
* plug-ins/common/png.c
|
||||
* plug-ins/common/psp.c
|
||||
* plug-ins/fits/Makefile.am
|
||||
* plug-ins/fits/fits.c
|
||||
* plug-ins/sgi/Makefile.am
|
||||
* plug-ins/sgi/sgi.c: made more save plug-ins export-aware.
|
||||
Hopefully I have converted them all now. If you find one that I
|
||||
missed or experience any problems, please drop me a mail.
|
||||
|
||||
Tue Oct 19 17:56:29 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* plug-ins/common/bz2.c
|
||||
|
|
|
@ -778,8 +778,9 @@ pix_SOURCES = \
|
|||
pix.c
|
||||
|
||||
pix_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
||||
pixelize_SOURCES = \
|
||||
|
@ -854,6 +855,7 @@ psp_SOURCES = \
|
|||
psp.c
|
||||
|
||||
psp_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(LIBZ) \
|
||||
$(GTK_LIBS) \
|
||||
|
|
|
@ -47,7 +47,9 @@ static char ident[] = "@(#) GIMP Alias|Wavefront pix image file-plugin v1.0 24-
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <libgimp/gimp.h>
|
||||
#include "gtk/gtk.h"
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
|
||||
/* #define PIX_DEBUG */
|
||||
|
||||
|
@ -63,19 +65,19 @@ static char ident[] = "@(#) GIMP Alias|Wavefront pix image file-plugin v1.0 24-
|
|||
|
||||
/* Standard Plug-in Functions */
|
||||
|
||||
static void query ();
|
||||
static void run ( char *name, int nparams, GParam *param,
|
||||
int *nreturn_vals, GParam **return_vals );
|
||||
static void query (void);
|
||||
static void run (char *name, int nparams, GParam *param,
|
||||
int *nreturn_vals, GParam **return_vals );
|
||||
|
||||
/* Local Helper Functions */
|
||||
|
||||
static gint32 load_image( char *filename );
|
||||
static gint save_image( char *filename, gint32 image_ID, gint32 drawable_ID );
|
||||
static gint32 load_image (char *filename );
|
||||
static gint save_image (char *filename, gint32 image_ID, gint32 drawable_ID );
|
||||
|
||||
static guint16 get_short( FILE * file );
|
||||
static void put_short( guint16 value, FILE * file );
|
||||
static guint32 get_long( FILE * file );
|
||||
static gchar get_char( FILE * file );
|
||||
static guint16 get_short (FILE * file );
|
||||
static void put_short (guint16 value, FILE * file );
|
||||
|
||||
static void init_gtk (void);
|
||||
|
||||
/******************
|
||||
* Implementation *
|
||||
|
@ -97,40 +99,44 @@ static void query ()
|
|||
* Register the services provided by this plug-in
|
||||
*/
|
||||
{
|
||||
static GParamDef load_args[] = {
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name entered" },
|
||||
};
|
||||
static GParamDef load_return_vals[] = {
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
};
|
||||
static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
|
||||
static int nload_return_vals = sizeof (load_return_vals) /
|
||||
sizeof (load_return_vals[0]);
|
||||
static GParamDef load_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name entered" },
|
||||
};
|
||||
static int nload_args =
|
||||
sizeof (load_args) / sizeof (load_args[0]);
|
||||
|
||||
static GParamDef save_args[] = {
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
|
||||
{ PARAM_STRING, "raw_filename",
|
||||
"The name of the file to save the image in" }
|
||||
};
|
||||
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
|
||||
static GParamDef load_return_vals[] =
|
||||
{
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
};
|
||||
static int nload_return_vals =
|
||||
sizeof (load_return_vals) / sizeof (load_return_vals[0]);
|
||||
|
||||
gimp_install_procedure ("file_pix_load",
|
||||
"loads files of the PIX file format",
|
||||
"loads files of the PIX file format",
|
||||
"Michael Taylor",
|
||||
"Michael Taylor",
|
||||
"1997",
|
||||
"<Load>/PIX",
|
||||
NULL,
|
||||
PROC_PLUG_IN,
|
||||
nload_args, nload_return_vals,
|
||||
load_args, load_return_vals);
|
||||
static GParamDef save_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to save the image in" }
|
||||
};
|
||||
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
|
||||
|
||||
gimp_install_procedure ("file_pix_load",
|
||||
"loads files of the PIX file format",
|
||||
"loads files of the PIX file format",
|
||||
"Michael Taylor",
|
||||
"Michael Taylor",
|
||||
"1997",
|
||||
"<Load>/PIX",
|
||||
NULL,
|
||||
PROC_PLUG_IN,
|
||||
nload_args, nload_return_vals,
|
||||
load_args, load_return_vals);
|
||||
|
||||
gimp_install_procedure ("file_pix_save",
|
||||
"save file in the Alias|Wavefront pix/matte file format",
|
||||
"save file in the Alias|Wavefront pix/matte file format",
|
||||
|
@ -142,13 +148,17 @@ static void query ()
|
|||
PROC_PLUG_IN,
|
||||
nsave_args, 0,
|
||||
save_args, NULL);
|
||||
|
||||
gimp_register_load_handler ("file_pix_load", "pix,matte,mask,alpha,als", "");
|
||||
gimp_register_save_handler ("file_pix_save", "pix,matte,mask,alpha,als", "");
|
||||
|
||||
gimp_register_load_handler ("file_pix_load", "pix,matte,mask,alpha,als", "");
|
||||
gimp_register_save_handler ("file_pix_save", "pix,matte,mask,alpha,als", "");
|
||||
}
|
||||
|
||||
static void run ( char *name, int nparams, GParam *param, int *nreturn_vals,
|
||||
GParam **return_vals )
|
||||
static void
|
||||
run (char *name,
|
||||
int nparams,
|
||||
GParam *param,
|
||||
int *nreturn_vals,
|
||||
GParam **return_vals )
|
||||
/*
|
||||
* Description:
|
||||
* perform registered plug-in function
|
||||
|
@ -161,103 +171,114 @@ static void run ( char *name, int nparams, GParam *param, int *nreturn_vals,
|
|||
* return_vals - parameters returned by the function
|
||||
*/
|
||||
{
|
||||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
gint32 image_ID;
|
||||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = PARAM_STATUS;
|
||||
values[0].data.d_status = STATUS_CALLING_ERROR;
|
||||
|
||||
if (strcmp (name, "file_pix_load") == 0) {
|
||||
/* Perform the image load */
|
||||
image_ID = load_image (param[1].data.d_string);
|
||||
if (image_ID != -1) {
|
||||
/* The image load was successful */
|
||||
*nreturn_vals = 2;
|
||||
values[0].data.d_status = STATUS_SUCCESS;
|
||||
values[1].type = PARAM_IMAGE;
|
||||
values[1].data.d_image = image_ID;
|
||||
} else {
|
||||
/* The image load falied */
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
} else if (strcmp (name, "file_pix_save") == 0) {
|
||||
if (status == STATUS_SUCCESS) {
|
||||
if ( !save_image ( param[3].data.d_string, param[1].data.d_int32,
|
||||
param[2].data.d_int32))
|
||||
{
|
||||
status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
values[0].data.d_status = status;
|
||||
|
||||
} else {
|
||||
g_assert (FALSE);
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = PARAM_STATUS;
|
||||
values[0].data.d_status = STATUS_CALLING_ERROR;
|
||||
|
||||
if (strcmp (name, "file_pix_load") == 0)
|
||||
{
|
||||
/* Perform the image load */
|
||||
image_ID = load_image (param[1].data.d_string);
|
||||
if (image_ID != -1)
|
||||
{
|
||||
/* The image load was successful */
|
||||
*nreturn_vals = 2;
|
||||
values[0].data.d_status = STATUS_SUCCESS;
|
||||
values[1].type = PARAM_IMAGE;
|
||||
values[1].data.d_image = image_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The image load falied */
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
else if (strcmp (name, "file_pix_save") == 0)
|
||||
{
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PIX",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_ALPHA));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
if ( !save_image (param[3].data.d_string, image_ID, drawable_ID))
|
||||
{
|
||||
status = STATUS_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
values[0].data.d_status = status;
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static guint16 get_short( FILE * file )
|
||||
static guint16
|
||||
get_short (FILE *file)
|
||||
/*
|
||||
* Description:
|
||||
* Reads a 16-bit integer from a file in such a way that the machine's
|
||||
* bit ordering should not matter
|
||||
*/
|
||||
{
|
||||
guchar buf[2];
|
||||
|
||||
fread( buf, 2, 1, file);
|
||||
return ( buf[0] << 8 ) + ( buf[1] << 0 );
|
||||
guchar buf[2];
|
||||
|
||||
fread (buf, 2, 1, file);
|
||||
return ( buf[0] << 8 ) + ( buf[1] << 0 );
|
||||
}
|
||||
|
||||
static void put_short( guint16 value, FILE * file )
|
||||
static void
|
||||
put_short (guint16 value,
|
||||
FILE *file)
|
||||
/*
|
||||
* Description:
|
||||
* Reads a 16-bit integer from a file in such a way that the machine's
|
||||
* bit ordering should not matter
|
||||
*/
|
||||
{
|
||||
guchar buf[2];
|
||||
buf[0] = (guchar)( value >> 8 );
|
||||
buf[1] = (guchar)( value % 256 );
|
||||
|
||||
fwrite( buf, 2, 1, file);
|
||||
guchar buf[2];
|
||||
buf[0] = (guchar)( value >> 8 );
|
||||
buf[1] = (guchar)( value % 256 );
|
||||
|
||||
fwrite( buf, 2, 1, file);
|
||||
}
|
||||
|
||||
static guint32 get_long( FILE * file )
|
||||
/*
|
||||
* Description:
|
||||
* Reads a 16-bit integer from a file in such a way that the machine's
|
||||
* bit ordering should not matter
|
||||
*/
|
||||
{
|
||||
guchar buf[4];
|
||||
|
||||
fread( buf, 4, 1, file );
|
||||
return ( buf[0] << 24 ) + ( buf[1] << 16 )
|
||||
+ ( buf[2] << 8 ) + ( buf[3] << 0 );
|
||||
}
|
||||
|
||||
static gchar get_char( FILE * file )
|
||||
/*
|
||||
* Description:
|
||||
* Reads a byte from a file. Provided for convenience;
|
||||
*/
|
||||
{
|
||||
gchar result;
|
||||
|
||||
fread( &result, 1, 1, file );
|
||||
return result;
|
||||
}
|
||||
|
||||
static gint32 load_image (char *filename)
|
||||
static gint32
|
||||
load_image (char *filename)
|
||||
/*
|
||||
* Description:
|
||||
* load the given image into gimp
|
||||
|
@ -270,154 +291,175 @@ static gint32 load_image (char *filename)
|
|||
*
|
||||
*/
|
||||
{
|
||||
gint i, j, tile_height, row;
|
||||
FILE * file = NULL;
|
||||
gchar * progMessage;
|
||||
guchar * dest;
|
||||
guchar * dest_base;
|
||||
GDrawable * drawable;
|
||||
gint32 image_ID;
|
||||
gint32 layer_ID;
|
||||
GPixelRgn pixel_rgn;
|
||||
gushort width, height, depth;
|
||||
|
||||
GImageType imgtype;
|
||||
GDrawableType gdtype;
|
||||
|
||||
/* Set up progress display */
|
||||
progMessage = malloc (strlen (filename) + 12);
|
||||
if (!progMessage) gimp_quit ();
|
||||
sprintf (progMessage, "Loading %s:", filename);
|
||||
gimp_progress_init (progMessage);
|
||||
free (progMessage);
|
||||
|
||||
PIX_DEBUG_PRINT("Opening file: %s\n",filename);
|
||||
|
||||
/* Open the file */
|
||||
file = fopen( filename, "r" );
|
||||
if ( NULL == file ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read header information */
|
||||
width = get_short( file );
|
||||
height = get_short( file );
|
||||
get_short( file ); /* Discard obsolete fields */
|
||||
get_short( file ); /* Discard obsolete fields */
|
||||
depth = get_short( file );
|
||||
|
||||
PIX_DEBUG_PRINT( "Width %hu\n", width );
|
||||
PIX_DEBUG_PRINT( "Height %hu\n", height );
|
||||
|
||||
if ( depth == 8 ) {
|
||||
/* Loading a matte file */
|
||||
imgtype = GRAY;
|
||||
gdtype = GRAY_IMAGE;
|
||||
} else if ( depth == 24 ) {
|
||||
/* Loading an RGB file */
|
||||
imgtype = RGB;
|
||||
gdtype = RGB_IMAGE;
|
||||
} else {
|
||||
/* Header is invalid */
|
||||
fclose( file );
|
||||
return -1;
|
||||
}
|
||||
|
||||
image_ID = gimp_image_new ( width, height, imgtype );
|
||||
gimp_image_set_filename ( image_ID, filename );
|
||||
layer_ID = gimp_layer_new ( image_ID, "Background",
|
||||
width,
|
||||
height,
|
||||
gdtype, 100, NORMAL_MODE );
|
||||
gimp_image_add_layer ( image_ID, layer_ID, 0);
|
||||
drawable = gimp_drawable_get ( layer_ID );
|
||||
gimp_pixel_rgn_init ( &pixel_rgn, drawable, 0, 0, drawable->width,
|
||||
drawable->height, TRUE, FALSE );
|
||||
|
||||
tile_height = gimp_tile_height();
|
||||
|
||||
if ( depth == 24 ) {
|
||||
/* Read a 24-bit Pix image */
|
||||
guchar record[4];
|
||||
gint readlen;
|
||||
tile_height = gimp_tile_height();
|
||||
|
||||
dest_base = dest = g_new (guchar, 3 * width * tile_height);
|
||||
|
||||
for (i = 0; i < height;) {
|
||||
for ( dest = dest_base, row = 0;
|
||||
row < tile_height && i < height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
guchar count;
|
||||
|
||||
/* Read a row of the image */
|
||||
j = 0;
|
||||
while ( j < width ) {
|
||||
readlen = fread( record, 1, 4, file );
|
||||
if ( readlen < 4 ) break;
|
||||
|
||||
for ( count = 0; count < record[0]; ++count ) {
|
||||
dest[0] = record[3];
|
||||
dest[1] = record[2];
|
||||
dest[2] = record[1];
|
||||
dest += 3;
|
||||
j++;
|
||||
if ( j >= width ) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gimp_pixel_rgn_set_rect (&pixel_rgn, dest_base, 0, i-row,
|
||||
width, row);
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
gint i, j, tile_height, row;
|
||||
FILE * file = NULL;
|
||||
gchar * progMessage;
|
||||
guchar * dest;
|
||||
guchar * dest_base;
|
||||
GDrawable * drawable;
|
||||
gint32 image_ID;
|
||||
gint32 layer_ID;
|
||||
GPixelRgn pixel_rgn;
|
||||
gushort width, height, depth;
|
||||
|
||||
GImageType imgtype;
|
||||
GDrawableType gdtype;
|
||||
|
||||
/* Set up progress display */
|
||||
progMessage = malloc (strlen (filename) + 12);
|
||||
if (!progMessage)
|
||||
gimp_quit ();
|
||||
sprintf (progMessage, "Loading %s:", filename);
|
||||
gimp_progress_init (progMessage);
|
||||
free (progMessage);
|
||||
|
||||
PIX_DEBUG_PRINT("Opening file: %s\n",filename);
|
||||
|
||||
/* Open the file */
|
||||
file = fopen( filename, "r" );
|
||||
if ( NULL == file )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read header information */
|
||||
width = get_short( file );
|
||||
height = get_short( file );
|
||||
get_short( file ); /* Discard obsolete fields */
|
||||
get_short( file ); /* Discard obsolete fields */
|
||||
depth = get_short( file );
|
||||
|
||||
PIX_DEBUG_PRINT( "Width %hu\n", width );
|
||||
PIX_DEBUG_PRINT( "Height %hu\n", height );
|
||||
|
||||
if ( depth == 8 )
|
||||
{
|
||||
/* Loading a matte file */
|
||||
imgtype = GRAY;
|
||||
gdtype = GRAY_IMAGE;
|
||||
}
|
||||
else if ( depth == 24 )
|
||||
{
|
||||
/* Loading an RGB file */
|
||||
imgtype = RGB;
|
||||
gdtype = RGB_IMAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Header is invalid */
|
||||
fclose( file );
|
||||
return -1;
|
||||
}
|
||||
|
||||
image_ID = gimp_image_new ( width, height, imgtype );
|
||||
gimp_image_set_filename ( image_ID, filename );
|
||||
layer_ID = gimp_layer_new ( image_ID, "Background",
|
||||
width,
|
||||
height,
|
||||
gdtype, 100, NORMAL_MODE );
|
||||
gimp_image_add_layer ( image_ID, layer_ID, 0);
|
||||
drawable = gimp_drawable_get ( layer_ID );
|
||||
gimp_pixel_rgn_init ( &pixel_rgn, drawable, 0, 0, drawable->width,
|
||||
drawable->height, TRUE, FALSE );
|
||||
|
||||
tile_height = gimp_tile_height();
|
||||
|
||||
if ( depth == 24 )
|
||||
{
|
||||
/* Read a 24-bit Pix image */
|
||||
guchar record[4];
|
||||
gint readlen;
|
||||
tile_height = gimp_tile_height();
|
||||
|
||||
dest_base = dest = g_new (guchar, 3 * width * tile_height);
|
||||
|
||||
for (i = 0; i < height;)
|
||||
{
|
||||
for ( dest = dest_base, row = 0;
|
||||
row < tile_height && i < height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
guchar count;
|
||||
|
||||
/* Read a row of the image */
|
||||
j = 0;
|
||||
while ( j < width )
|
||||
{
|
||||
readlen = fread( record, 1, 4, file );
|
||||
if ( readlen < 4 )
|
||||
break;
|
||||
|
||||
for ( count = 0; count < record[0]; ++count )
|
||||
{
|
||||
dest[0] = record[3];
|
||||
dest[1] = record[2];
|
||||
dest[2] = record[1];
|
||||
dest += 3;
|
||||
j++;
|
||||
if ( j >= width )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free( dest_base );
|
||||
} else {
|
||||
/* Read an 8-bit Matte image */
|
||||
guchar record[2];
|
||||
gint readlen;
|
||||
|
||||
dest_base = dest = g_new (guchar, width * tile_height);
|
||||
|
||||
for (i = 0; i < height;) {
|
||||
for ( dest = dest_base, row = 0;
|
||||
row < tile_height && i < height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
guchar count;
|
||||
|
||||
/* Read a row of the image */
|
||||
j = 0;
|
||||
while ( j < width ) {
|
||||
readlen = fread( record, 1, 2, file );
|
||||
if ( readlen < 2 ) break;
|
||||
|
||||
for ( count = 0; count < record[0]; ++count ) {
|
||||
dest[j] = record[1];
|
||||
j++;
|
||||
if ( j >= width ) break;
|
||||
}
|
||||
}
|
||||
dest += width;
|
||||
}
|
||||
gimp_pixel_rgn_set_rect (&pixel_rgn, dest_base, 0, i-row,
|
||||
width, row);
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
free( dest_base );
|
||||
}
|
||||
gimp_pixel_rgn_set_rect (&pixel_rgn, dest_base, 0, i-row,
|
||||
width, row);
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
|
||||
free( dest_base );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read an 8-bit Matte image */
|
||||
guchar record[2];
|
||||
gint readlen;
|
||||
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
fclose( file );
|
||||
dest_base = dest = g_new (guchar, width * tile_height);
|
||||
|
||||
for (i = 0; i < height;)
|
||||
{
|
||||
for ( dest = dest_base, row = 0;
|
||||
row < tile_height && i < height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
guchar count;
|
||||
|
||||
return image_ID;
|
||||
/* Read a row of the image */
|
||||
j = 0;
|
||||
while ( j < width )
|
||||
{
|
||||
readlen = fread( record, 1, 2, file );
|
||||
if ( readlen < 2 ) break;
|
||||
|
||||
for ( count = 0; count < record[0]; ++count )
|
||||
{
|
||||
dest[j] = record[1];
|
||||
j++;
|
||||
if ( j >= width ) break;
|
||||
}
|
||||
}
|
||||
dest += width;
|
||||
}
|
||||
gimp_pixel_rgn_set_rect (&pixel_rgn, dest_base, 0, i-row,
|
||||
width, row);
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
free( dest_base );
|
||||
}
|
||||
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
fclose( file );
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
||||
|
||||
static gint save_image( char *filename, gint32 image_ID, gint32 drawable_ID )
|
||||
static gint
|
||||
save_image (char *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID )
|
||||
/*
|
||||
* Description:
|
||||
* save the given file out as an alias pix or matte file
|
||||
|
@ -428,159 +470,189 @@ static gint save_image( char *filename, gint32 image_ID, gint32 drawable_ID )
|
|||
* drawable_ID - current drawable
|
||||
*/
|
||||
{
|
||||
gint depth, i, j, row, tile_height, writelen, rectHeight;
|
||||
/* gboolean savingAlpha = FALSE; */
|
||||
gboolean savingColor = TRUE;
|
||||
guchar * src;
|
||||
guchar * src_base;
|
||||
gchar * progMessage;
|
||||
GDrawable * drawable;
|
||||
GPixelRgn pixel_rgn;
|
||||
FILE * file;
|
||||
|
||||
/* Get info about image */
|
||||
drawable = gimp_drawable_get(drawable_ID);
|
||||
|
||||
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width,
|
||||
drawable->height, FALSE, FALSE);
|
||||
|
||||
switch (gimp_drawable_type(drawable_ID))
|
||||
gint depth, i, j, row, tile_height, writelen, rectHeight;
|
||||
/* gboolean savingAlpha = FALSE; */
|
||||
gboolean savingColor = TRUE;
|
||||
guchar * src;
|
||||
guchar * src_base;
|
||||
gchar * progMessage;
|
||||
GDrawable * drawable;
|
||||
GPixelRgn pixel_rgn;
|
||||
FILE * file;
|
||||
|
||||
/* Get info about image */
|
||||
drawable = gimp_drawable_get(drawable_ID);
|
||||
|
||||
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width,
|
||||
drawable->height, FALSE, FALSE);
|
||||
|
||||
switch (gimp_drawable_type(drawable_ID))
|
||||
{
|
||||
case GRAY_IMAGE:
|
||||
savingColor = FALSE;
|
||||
depth = 1;
|
||||
break;
|
||||
case GRAYA_IMAGE:
|
||||
savingColor = FALSE;
|
||||
depth = 2;
|
||||
break;
|
||||
case RGB_IMAGE:
|
||||
savingColor = TRUE;
|
||||
depth = 3;
|
||||
break;
|
||||
case RGBA_IMAGE:
|
||||
savingColor = TRUE;
|
||||
depth = 4;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
|
||||
/* Open the output file. */
|
||||
file = fopen (filename, "wb");
|
||||
if ( !file )
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* Set up progress display */
|
||||
progMessage = malloc (strlen (filename) + 12);
|
||||
if (!progMessage)
|
||||
gimp_quit ();
|
||||
sprintf (progMessage, "Saving %s:", filename);
|
||||
gimp_progress_init (progMessage);
|
||||
free (progMessage);
|
||||
|
||||
/* Write the image header */
|
||||
PIX_DEBUG_PRINT( "Width %hu\n", drawable->width );
|
||||
PIX_DEBUG_PRINT( "Height %hu\n", drawable->height );
|
||||
put_short( drawable->width, file );
|
||||
put_short( drawable->height, file );
|
||||
put_short( 0, file );
|
||||
put_short( 0, file );
|
||||
if ( savingColor )
|
||||
{
|
||||
put_short( 24, file );
|
||||
}
|
||||
else
|
||||
{
|
||||
put_short( 8, file );
|
||||
}
|
||||
|
||||
tile_height = gimp_tile_height();
|
||||
src_base = g_new( guchar, tile_height * drawable->width * depth );
|
||||
|
||||
if ( savingColor )
|
||||
{
|
||||
/* Writing a 24-bit Pix image */
|
||||
guchar record[4];
|
||||
|
||||
for (i = 0; i < drawable->height;)
|
||||
{
|
||||
case GRAY_IMAGE:
|
||||
savingColor = FALSE;
|
||||
depth = 1;
|
||||
break;
|
||||
case GRAYA_IMAGE:
|
||||
savingColor = FALSE;
|
||||
depth = 2;
|
||||
break;
|
||||
case RGB_IMAGE:
|
||||
savingColor = TRUE;
|
||||
depth = 3;
|
||||
break;
|
||||
case RGBA_IMAGE:
|
||||
savingColor = TRUE;
|
||||
depth = 4;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
|
||||
/* Open the output file. */
|
||||
file = fopen (filename, "wb");
|
||||
if ( !file ) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* Set up progress display */
|
||||
progMessage = malloc (strlen (filename) + 12);
|
||||
if (!progMessage) gimp_quit ();
|
||||
sprintf (progMessage, "Saving %s:", filename);
|
||||
gimp_progress_init (progMessage);
|
||||
free (progMessage);
|
||||
|
||||
/* Write the image header */
|
||||
PIX_DEBUG_PRINT( "Width %hu\n", drawable->width );
|
||||
PIX_DEBUG_PRINT( "Height %hu\n", drawable->height );
|
||||
put_short( drawable->width, file );
|
||||
put_short( drawable->height, file );
|
||||
put_short( 0, file );
|
||||
put_short( 0, file );
|
||||
if ( savingColor ) {
|
||||
put_short( 24, file );
|
||||
} else {
|
||||
put_short( 8, file );
|
||||
}
|
||||
|
||||
tile_height = gimp_tile_height();
|
||||
src_base = g_new( guchar, tile_height * drawable->width * depth );
|
||||
|
||||
if ( savingColor ) {
|
||||
/* Writing a 24-bit Pix image */
|
||||
guchar record[4];
|
||||
|
||||
for (i = 0; i < drawable->height;) {
|
||||
rectHeight = ( tile_height < ( drawable->height - i - 1 ) ) ?
|
||||
tile_height : ( drawable->height - i - 1 );
|
||||
gimp_pixel_rgn_get_rect (&pixel_rgn, src_base, 0, i,
|
||||
drawable->width, rectHeight);
|
||||
|
||||
for ( src = src_base, row = 0;
|
||||
row < tile_height && i < drawable->height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
/* Write a row of the image */
|
||||
record[0] = 1;
|
||||
record[3] = src[0];
|
||||
record[2] = src[1];
|
||||
record[1] = src[2];
|
||||
src += depth;
|
||||
for ( j = 1; j < drawable->width; ++j ) {
|
||||
if ( ( record[3] != src[0] ) ||
|
||||
( record[2] != src[1] ) ||
|
||||
( record[1] != src[2] ) ||
|
||||
( record[0] == 255 ) )
|
||||
{
|
||||
/* Write current RLE record and start a new one */
|
||||
|
||||
writelen = fwrite( record, 1, 4, file );
|
||||
record[0] = 1;
|
||||
record[3] = src[0];
|
||||
record[2] = src[1];
|
||||
record[1] = src[2];
|
||||
} else {
|
||||
/* increment run length in current record */
|
||||
record[0] ++;
|
||||
}
|
||||
src += depth;
|
||||
}
|
||||
/* Write last record in row */
|
||||
writelen = fwrite( record, 1, 4, file );
|
||||
}
|
||||
gimp_progress_update ((double) i / (double) drawable->height);
|
||||
rectHeight = ( tile_height < ( drawable->height - i - 1 ) ) ?
|
||||
tile_height : ( drawable->height - i - 1 );
|
||||
gimp_pixel_rgn_get_rect (&pixel_rgn, src_base, 0, i,
|
||||
drawable->width, rectHeight);
|
||||
|
||||
for ( src = src_base, row = 0;
|
||||
row < tile_height && i < drawable->height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
/* Write a row of the image */
|
||||
record[0] = 1;
|
||||
record[3] = src[0];
|
||||
record[2] = src[1];
|
||||
record[1] = src[2];
|
||||
src += depth;
|
||||
for ( j = 1; j < drawable->width; ++j )
|
||||
{
|
||||
if ( ( record[3] != src[0] ) ||
|
||||
( record[2] != src[1] ) ||
|
||||
( record[1] != src[2] ) ||
|
||||
( record[0] == 255 ) )
|
||||
{
|
||||
/* Write current RLE record and start a new one */
|
||||
|
||||
writelen = fwrite( record, 1, 4, file );
|
||||
record[0] = 1;
|
||||
record[3] = src[0];
|
||||
record[2] = src[1];
|
||||
record[1] = src[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* increment run length in current record */
|
||||
record[0] ++;
|
||||
}
|
||||
src += depth;
|
||||
}
|
||||
} else {
|
||||
/* Writing a 8-bit Matte (Mask) image */
|
||||
guchar record[2];
|
||||
|
||||
for (i = 0; i < drawable->height;) {
|
||||
rectHeight = ( tile_height < ( drawable->height - i - 1 ) ) ?
|
||||
tile_height : ( drawable->height - i - 1 );
|
||||
gimp_pixel_rgn_get_rect (&pixel_rgn, src_base, 0, i,
|
||||
drawable->width, rectHeight);
|
||||
|
||||
for ( src = src_base, row = 0;
|
||||
row < tile_height && i < drawable->height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
/* Write a row of the image */
|
||||
record[0] = 1;
|
||||
record[1] = src[0];
|
||||
src += depth;
|
||||
for ( j = 1; j < drawable->width; ++j ) {
|
||||
if ( ( record[1] != src[0] ) ||
|
||||
( record[0] == 255 ) )
|
||||
{
|
||||
/* Write current RLE record and start a new one */
|
||||
writelen = fwrite( record, 1, 2, file );
|
||||
record[0] = 1;
|
||||
record[1] = src[0];
|
||||
} else {
|
||||
/* increment run length in current record */
|
||||
record[0] ++;
|
||||
}
|
||||
src += depth;
|
||||
}
|
||||
/* Write last record in row */
|
||||
writelen = fwrite( record, 1, 2, file );
|
||||
}
|
||||
gimp_progress_update ((double) i / (double) drawable->height);
|
||||
}
|
||||
writelen = fwrite( record, 1, 4, file );
|
||||
}
|
||||
gimp_progress_update ((double) i / (double) drawable->height);
|
||||
}
|
||||
|
||||
free( src_base );
|
||||
|
||||
fclose( file );
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Writing a 8-bit Matte (Mask) image */
|
||||
guchar record[2];
|
||||
|
||||
for (i = 0; i < drawable->height;)
|
||||
{
|
||||
rectHeight = ( tile_height < ( drawable->height - i - 1 ) ) ?
|
||||
tile_height : ( drawable->height - i - 1 );
|
||||
gimp_pixel_rgn_get_rect (&pixel_rgn, src_base, 0, i,
|
||||
drawable->width, rectHeight);
|
||||
|
||||
for ( src = src_base, row = 0;
|
||||
row < tile_height && i < drawable->height;
|
||||
i += 1, row += 1)
|
||||
{
|
||||
/* Write a row of the image */
|
||||
record[0] = 1;
|
||||
record[1] = src[0];
|
||||
src += depth;
|
||||
for ( j = 1; j < drawable->width; ++j )
|
||||
{
|
||||
if ( ( record[1] != src[0] ) || ( record[0] == 255 ) )
|
||||
{
|
||||
/* Write current RLE record and start a new one */
|
||||
writelen = fwrite( record, 1, 2, file );
|
||||
record[0] = 1;
|
||||
record[1] = src[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* increment run length in current record */
|
||||
record[0] ++;
|
||||
}
|
||||
src += depth;
|
||||
}
|
||||
/* Write last record in row */
|
||||
writelen = fwrite( record, 1, 2, file );
|
||||
}
|
||||
gimp_progress_update ((double) i / (double) drawable->height);
|
||||
}
|
||||
}
|
||||
|
||||
free( src_base );
|
||||
|
||||
fclose( file );
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
init_gtk (void)
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("pix");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
'papertile' => { libdep => 'gtk' },
|
||||
'pat' => { libdep => 'gtk', ui => 1 },
|
||||
'pcx' => { libdep => 'gtk', ui => 1 },
|
||||
'pix' => { libdep => 'glib' },
|
||||
'pix' => { libdep => 'gtk', ui => 1 },
|
||||
'pixelize' => { libdep => 'gtk' },
|
||||
'plasma' => { libdep => 'gtk' },
|
||||
'plugindetails' => { libdep => 'gtk' },
|
||||
|
@ -82,7 +82,7 @@
|
|||
'polar' => { libdep => 'gtk' },
|
||||
'ps' => { libdep => 'gtk', ui => 1 },
|
||||
'psd' => { libdep => 'glib' },
|
||||
'psp' => { libdep => 'gtk', optional => 1, libopt => 'z' },
|
||||
'psp' => { libdep => 'gtk', ui => 1, optional => 1, libopt => 'z' },
|
||||
'randomize' => { libdep => 'gtk', libsupp => 'gpc' },
|
||||
'ripple' => { libdep => 'gtk' },
|
||||
'rotate' => { libdep => 'gtk' },
|
||||
|
|
|
@ -299,12 +299,12 @@ run (char *name, /* I - Name of filter program. */
|
|||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
};
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <zlib.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
#include <libgimp/parasiteio.h>
|
||||
#include <libgimp/stdplugins-intl.h>
|
||||
|
||||
|
@ -431,6 +432,20 @@ save_ok_callback (GtkWidget *widget,
|
|||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static void
|
||||
init_gtk ()
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("psp");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
static gint
|
||||
save_dialog ()
|
||||
{
|
||||
|
@ -440,19 +455,10 @@ save_dialog ()
|
|||
GtkWidget *frame;
|
||||
GtkWidget *toggle_vbox;
|
||||
GSList *group;
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
gint use_none = (psvals.compression == PSP_COMP_NONE);
|
||||
gint use_rle = (psvals.compression == PSP_COMP_RLE);
|
||||
gint use_lz77 = (psvals.compression == PSP_COMP_LZ77);
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("save");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
|
||||
dlg = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), "Save as PSP");
|
||||
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
|
||||
|
@ -1749,7 +1755,9 @@ run (char *name,
|
|||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
|
||||
tile_height = gimp_tile_height ();
|
||||
|
||||
|
@ -1778,10 +1786,33 @@ run (char *name,
|
|||
}
|
||||
else if (strcmp (name, "file_psp_save") == 0)
|
||||
{
|
||||
image_ID = orig_image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
INIT_I18N_UI();
|
||||
case RUN_WITH_LAST_VALS:
|
||||
INIT_I18N_UI();
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PSP",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA | CAN_HANDLE_LAYERS));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("file_pnm_save", &psvals);
|
||||
|
||||
|
@ -1811,7 +1842,7 @@ run (char *name,
|
|||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
if (save_image (param[3].data.d_string, param[1].data.d_int32, param[2].data.d_int32))
|
||||
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
|
||||
{
|
||||
gimp_set_data ("file_psp_save", &psvals, sizeof (PSPSaveVals));
|
||||
|
||||
|
@ -1822,5 +1853,8 @@ run (char *name,
|
|||
}
|
||||
|
||||
values[0].data.d_status = status;
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ INCLUDES = \
|
|||
|
||||
LDADD = \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(GTK_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ static char ident[] = "@(#) GIMP FITS file-plugin v1.05 20-Dec-97";
|
|||
#include <string.h>
|
||||
#include "gtk/gtk.h"
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
#include "fitsrw.h"
|
||||
|
||||
/* Load info */
|
||||
|
@ -108,6 +109,7 @@ typedef struct
|
|||
int toggle_val[2*LOAD_FITS_TOGGLES];
|
||||
} LoadDialogVals;
|
||||
|
||||
static void init_gtk (void);
|
||||
|
||||
static gint load_dialog (void);
|
||||
static void load_close_callback (GtkWidget *widget,
|
||||
|
@ -150,13 +152,13 @@ query (void)
|
|||
{
|
||||
static GParamDef load_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to load" },
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to load" },
|
||||
};
|
||||
static GParamDef load_return_vals[] =
|
||||
{
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
};
|
||||
static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
|
||||
static int nload_return_vals = sizeof (load_return_vals)
|
||||
|
@ -164,12 +166,11 @@ query (void)
|
|||
|
||||
static GParamDef save_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
|
||||
{ PARAM_STRING, "raw_filename",
|
||||
"The name of the file to save the image in" },
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to save the image in" },
|
||||
};
|
||||
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
|
||||
|
||||
|
@ -194,7 +195,7 @@ those with alpha channels.",
|
|||
"Peter Kirchgessner (pkirchg@aol.com)",
|
||||
"1997",
|
||||
"<Save>/FITS",
|
||||
"RGB*, GRAY*, INDEXED*",
|
||||
"RGB, GRAY, INDEXED",
|
||||
PROC_PLUG_IN,
|
||||
nsave_args, 0,
|
||||
save_args, NULL);
|
||||
|
@ -218,6 +219,8 @@ run (char *name,
|
|||
GRunModeType run_mode;
|
||||
GStatusType status = STATUS_SUCCESS;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
/* initialize */
|
||||
|
||||
|
@ -236,6 +239,25 @@ run (char *name,
|
|||
values[1].type = PARAM_IMAGE;
|
||||
values[1].data.d_image = -1;
|
||||
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "FITS",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
|
@ -279,6 +301,10 @@ run (char *name,
|
|||
}
|
||||
else if (strcmp (name, "file_fits_save") == 0)
|
||||
{
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
*nreturn_vals = 1;
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
|
@ -297,12 +323,13 @@ run (char *name,
|
|||
break;
|
||||
}
|
||||
|
||||
*nreturn_vals = 1;
|
||||
if (save_image (param[3].data.d_string, param[1].data.d_int32,
|
||||
param[2].data.d_int32))
|
||||
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
|
||||
values[0].data.d_status = STATUS_SUCCESS;
|
||||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -941,6 +968,21 @@ save_index (FITS_FILE *ofp,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
init_gtk ()
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("fits");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
|
||||
/* Load interface functions */
|
||||
|
||||
static gint
|
||||
|
@ -953,8 +995,7 @@ load_dialog (void)
|
|||
GtkWidget *frame;
|
||||
GtkWidget *toggle_vbox;
|
||||
GSList *group;
|
||||
gchar **argv;
|
||||
gint argc, k, j;
|
||||
gint k, j;
|
||||
char **textptr;
|
||||
static char *toggle_text[] = {
|
||||
"BLANK/NaN pixel replacement", "Black", "White",
|
||||
|
@ -962,13 +1003,8 @@ load_dialog (void)
|
|||
"Image composing", "None", "NAXIS=3, NAXIS3=2,...,4"
|
||||
};
|
||||
|
||||
init_gtk ();
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("Load");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
vals = g_malloc (sizeof (*vals));
|
||||
|
||||
vals->toggle_val[0] = (plvals.replace == 0);
|
||||
|
@ -1105,12 +1141,8 @@ static void show_fits_errors (void)
|
|||
static void show_message (char *message)
|
||||
|
||||
{
|
||||
#ifdef Simple_Message_Box_Available
|
||||
/* If there would be a simple message box like the one */
|
||||
/* used in ../app/interface.h, I would like to use it. */
|
||||
if (l_run_mode == RUN_INTERACTIVE)
|
||||
gtk_message_box (message);
|
||||
gimp_message (message);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "Fits: %s\n", message);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ INCLUDES = \
|
|||
|
||||
LDADD = \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(GTK_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
* Revision History:
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.13 1999/10/20 01:45:41 neo
|
||||
* the rest of the save plug-ins !?
|
||||
*
|
||||
*
|
||||
* --Sven
|
||||
*
|
||||
* Revision 1.12 1999/04/23 06:32:41 asbjoer
|
||||
* use MAIN macro
|
||||
*
|
||||
|
@ -177,6 +183,7 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -190,14 +197,16 @@
|
|||
* Local functions...
|
||||
*/
|
||||
|
||||
static void query(void);
|
||||
static void run(char *, int, GParam *, int *, GParam **);
|
||||
static gint32 load_image(char *);
|
||||
static gint save_image (char *, gint32, gint32);
|
||||
static gint save_dialog(void);
|
||||
static void save_close_callback(GtkWidget *, gpointer);
|
||||
static void save_ok_callback(GtkWidget *, gpointer);
|
||||
static void save_compression_callback(GtkWidget *, gpointer);
|
||||
static void query (void);
|
||||
static void run (char *, int, GParam *, int *, GParam **);
|
||||
static gint32 load_image (char *);
|
||||
static gint save_image (char *, gint32, gint32);
|
||||
|
||||
static void init_gtk (void);
|
||||
static gint save_dialog (void);
|
||||
static void save_close_callback (GtkWidget *, gpointer);
|
||||
static void save_ok_callback (GtkWidget *, gpointer);
|
||||
static void save_compression_callback (GtkWidget *, gpointer);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -231,13 +240,13 @@ query(void)
|
|||
{
|
||||
static GParamDef load_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to load" },
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to load" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to load" },
|
||||
};
|
||||
static GParamDef load_return_vals[] =
|
||||
{
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
{ PARAM_IMAGE, "image", "Output image" },
|
||||
};
|
||||
static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
|
||||
static int nload_return_vals = sizeof (load_return_vals) / sizeof (load_return_vals[0]);
|
||||
|
@ -280,14 +289,17 @@ query(void)
|
|||
*/
|
||||
|
||||
static void
|
||||
run(char *name, /* I - Name of filter program. */
|
||||
int nparams, /* I - Number of parameters passed in */
|
||||
GParam *param, /* I - Parameter values */
|
||||
int *nreturn_vals, /* O - Number of return values */
|
||||
GParam **return_vals) /* O - Return values */
|
||||
run (char *name, /* I - Name of filter program. */
|
||||
int nparams, /* I - Number of parameters passed in */
|
||||
GParam *param, /* I - Parameter values */
|
||||
int *nreturn_vals, /* O - Number of return values */
|
||||
GParam **return_vals) /* O - Return values */
|
||||
{
|
||||
gint32 image_ID; /* ID of loaded image */
|
||||
GParam *values; /* Return values */
|
||||
GParam *values; /* Return values */
|
||||
GRunModeType run_mode;
|
||||
gint32 image_ID;
|
||||
gint32 drawable_ID;
|
||||
GimpExportReturnType export = EXPORT_CANCEL;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -322,8 +334,29 @@ run(char *name, /* I - Name of filter program. */
|
|||
else if (strcmp (name, "file_sgi_save") == 0)
|
||||
{
|
||||
*nreturn_vals = 1;
|
||||
run_mode = param[0].data.d_int32;
|
||||
image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
switch (param[0].data.d_int32)
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "SGI",
|
||||
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_ALPHA));
|
||||
if (export == EXPORT_CANCEL)
|
||||
{
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE :
|
||||
/*
|
||||
|
@ -361,7 +394,7 @@ run(char *name, /* I - Name of filter program. */
|
|||
* Possibly retrieve data...
|
||||
*/
|
||||
|
||||
gimp_get_data("file_sgi_save", &compression);
|
||||
gimp_get_data ("file_sgi_save", &compression);
|
||||
break;
|
||||
|
||||
default :
|
||||
|
@ -370,12 +403,14 @@ run(char *name, /* I - Name of filter program. */
|
|||
|
||||
if (values[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
if (save_image(param[3].data.d_string, param[1].data.d_int32,
|
||||
param[2].data.d_int32))
|
||||
if (save_image(param[3].data.d_string, image_ID, drawable_ID))
|
||||
gimp_set_data("file_sgi_save", &compression, sizeof(compression));
|
||||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
};
|
||||
|
||||
if (export == EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
}
|
||||
else
|
||||
values[0].data.d_status = STATUS_EXECUTION_ERROR;
|
||||
|
@ -387,7 +422,7 @@ run(char *name, /* I - Name of filter program. */
|
|||
*/
|
||||
|
||||
static gint32
|
||||
load_image(char *filename) /* I - File to load */
|
||||
load_image (char *filename) /* I - File to load */
|
||||
{
|
||||
int i, /* Looping var */
|
||||
x, /* Current X coordinate */
|
||||
|
@ -573,26 +608,26 @@ load_image(char *filename) /* I - File to load */
|
|||
*/
|
||||
|
||||
static gint
|
||||
save_image(char *filename, /* I - File to save to */
|
||||
gint32 image_ID, /* I - Image to save */
|
||||
gint32 drawable_ID) /* I - Current drawable */
|
||||
save_image (char *filename, /* I - File to save to */
|
||||
gint32 image_ID, /* I - Image to save */
|
||||
gint32 drawable_ID) /* I - Current drawable */
|
||||
{
|
||||
int i, j, /* Looping var */
|
||||
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 */
|
||||
zsize; /* Number of channels in file */
|
||||
sgi_t *sgip; /* File pointer */
|
||||
GDrawable *drawable; /* Drawable for layer */
|
||||
GPixelRgn pixel_rgn; /* Pixel region for layer */
|
||||
guchar **pixels, /* Pixel rows */
|
||||
*pixel, /* Pixel data */
|
||||
*pptr; /* Current pixel */
|
||||
unsigned short **rows; /* SGI image data */
|
||||
char progress[255]; /* Title for progress display... */
|
||||
int i, j, /* Looping var */
|
||||
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 */
|
||||
zsize; /* Number of channels in file */
|
||||
sgi_t *sgip; /* File pointer */
|
||||
GDrawable *drawable; /* Drawable for layer */
|
||||
GPixelRgn pixel_rgn; /* Pixel region for layer */
|
||||
guchar **pixels, /* Pixel rows */
|
||||
*pixel, /* Pixel data */
|
||||
*pptr; /* Current pixel */
|
||||
unsigned short **rows; /* SGI image data */
|
||||
char progress[255]; /* Title for progress display... */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -711,8 +746,8 @@ save_image(char *filename, /* I - File to save to */
|
|||
*/
|
||||
|
||||
static void
|
||||
save_close_callback(GtkWidget *w, /* I - Close button */
|
||||
gpointer data) /* I - Callback data */
|
||||
save_close_callback (GtkWidget *w, /* I - Close button */
|
||||
gpointer data) /* I - Callback data */
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
@ -723,8 +758,8 @@ save_close_callback(GtkWidget *w, /* I - Close button */
|
|||
*/
|
||||
|
||||
static void
|
||||
save_ok_callback(GtkWidget *w, /* I - OK button */
|
||||
gpointer data) /* I - Callback data */
|
||||
save_ok_callback (GtkWidget *w, /* I - OK button */
|
||||
gpointer data) /* I - Callback data */
|
||||
{
|
||||
runme = TRUE;
|
||||
|
||||
|
@ -737,14 +772,28 @@ save_ok_callback(GtkWidget *w, /* I - OK button */
|
|||
*/
|
||||
|
||||
static void
|
||||
save_compression_callback(GtkWidget *w, /* I - Compression button */
|
||||
gpointer data) /* I - Callback data */
|
||||
save_compression_callback (GtkWidget *w, /* I - Compression button */
|
||||
gpointer data) /* I - Callback data */
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON(w)->active)
|
||||
compression = (long)data;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_gtk ()
|
||||
{
|
||||
gchar **argv;
|
||||
gint argc;
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup ("sgi");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
}
|
||||
|
||||
/*
|
||||
* 'save_dialog()' - Pop up the save dialog.
|
||||
*/
|
||||
|
@ -758,8 +807,6 @@ save_dialog(void)
|
|||
*frame, /* Frame for dialog */
|
||||
*vbox; /* Box for compression types */
|
||||
GSList *group; /* Button grouping for compression */
|
||||
gchar **argv; /* Fake command-line args */
|
||||
gint argc; /* Number of fake command-line args */
|
||||
static char *types[] = /* Compression types... */
|
||||
{
|
||||
"No Compression",
|
||||
|
@ -768,17 +815,6 @@ save_dialog(void)
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* Fake the command-line args and open a window...
|
||||
*/
|
||||
|
||||
argc = 1;
|
||||
argv = g_new (gchar *, 1);
|
||||
argv[0] = g_strdup("sgi");
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
gtk_rc_parse(gimp_gtkrc());
|
||||
|
||||
/*
|
||||
* Open a dialog window...
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue