1999-03-28 14:55:29 +08:00
/* The GIMP -- an image manipulation program
2003-07-03 08:47:26 +08:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
1999-03-28 14:55:29 +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 2 of the License , or
* ( at your option ) any later version .
*
* 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 .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
2000-12-29 23:22:01 +08:00
# include "config.h"
1999-03-28 14:55:29 +08:00
Win32 portability changes:
* config.h.win32, README.win32: Small changes.
* tools/pdbgen/pdb/*.pdb: Include <string.h>.
* app/*_cmds.c: Autogenerated files reflect above changes.
* libgimp/makefile.msc app/makefile.msc: Various updates,
including new object files. Gtk+ directory now should be called
gtk+ (not gtk-plus). Use win32-specific gdk subdir. Glib directory
now should be called just glib.
* libgimp/gimp.def: Updates.
* libgimp/gimpfeatures.h.win32: Made current with
gimpfeatures.h.in.
* libgimp/gimpfileselection.c: Define S_ISDIR and S_ISREG if
necessary.
* tools/pdbgen/pdb/fileops.pdb: Must have a
statement (even an empty one) after a label.
* app/fileops_cmds.c: Autogenerated file reflects above changes.
* app/crop.c: Include <string.h>.
* app/{app_procs,batch,fileops,datafiles,errorconsole,general,
plug_in,temp_buf,tile_swap}.c: Test NATIVE_WIN32, not
_MSC_VER. (NATIVE_WIN32 means we are using the Microsoft C
runtime, even if we might be compiling with gcc.)
* app/fileops.c: Don't include <process.h> here.
* app/fileops.h: Do include <process.h> here.
* app/gimpparasite.c: Include config.h, guard inclusion of
<unistd.h>. (Is the inclusion of unistd.h in source files all over
the place really necessary?)
* app/ink.c: MSC doesn't handle conversion from unsigned __int64
to double, so cast to signed.
* app/lut_funcs.c: Include config.h, and define rint() if necessary.
* app/pixel_processor.c: Include config.h without "..", like in
all the other places. Include <string.h>
* app/text_tool.c: Guard the "POINTS" identifier that clashes with
<windows.h>, sigh.
1999-05-05 05:32:17 +08:00
2001-08-17 22:27:31 +08:00
# include <glib-object.h>
2000-12-29 23:22:01 +08:00
2001-05-21 21:58:46 +08:00
# include "libgimpbase/gimpbasetypes.h"
2001-08-17 22:27:31 +08:00
# include "pdb-types.h"
2000-12-29 23:22:01 +08:00
# include "procedural_db.h"
2001-07-05 03:31:35 +08:00
# include "core/gimp.h"
2001-05-09 10:32:03 +08:00
# include "core/gimpcontainer.h"
# include "core/gimpdatafactory.h"
# include "core/gimpimage-convert.h"
# include "core/gimpimage.h"
# include "core/gimppalette.h"
1999-03-28 14:55:29 +08:00
2003-12-04 22:52:24 +08:00
static ProcRecord image_convert_rgb_proc ;
static ProcRecord image_convert_grayscale_proc ;
static ProcRecord image_convert_indexed_proc ;
1999-03-28 14:55:29 +08:00
void
2001-07-05 03:31:35 +08:00
register_convert_procs ( Gimp * gimp )
1999-03-28 14:55:29 +08:00
{
2003-12-04 22:52:24 +08:00
procedural_db_register ( gimp , & image_convert_rgb_proc ) ;
procedural_db_register ( gimp , & image_convert_grayscale_proc ) ;
procedural_db_register ( gimp , & image_convert_indexed_proc ) ;
1999-03-28 14:55:29 +08:00
}
static Argument *
2003-12-04 22:52:24 +08:00
image_convert_rgb_invoker ( Gimp * gimp ,
Argument * args )
1999-03-28 14:55:29 +08:00
{
gboolean success = TRUE ;
GimpImage * gimage ;
2001-07-11 20:39:49 +08:00
gimage = gimp_image_get_by_ID ( gimp , args [ 0 ] . value . pdb_int ) ;
2002-08-30 01:21:21 +08:00
if ( ! GIMP_IS_IMAGE ( gimage ) )
1999-03-28 14:55:29 +08:00
success = FALSE ;
if ( success )
2004-02-01 00:23:25 +08:00
{
if ( gimp_image_base_type ( gimage ) ! = GIMP_RGB )
gimp_image_convert ( gimage , GIMP_RGB , 0 , 0 , FALSE , FALSE , 0 , NULL ) ;
else
success = FALSE ;
}
1999-03-28 14:55:29 +08:00
2003-12-04 22:52:24 +08:00
return procedural_db_return_args ( & image_convert_rgb_proc , success ) ;
1999-03-28 14:55:29 +08:00
}
2003-12-04 22:52:24 +08:00
static ProcArg image_convert_rgb_inargs [ ] =
1999-03-28 14:55:29 +08:00
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_IMAGE ,
1999-03-28 14:55:29 +08:00
" image " ,
" The image "
}
} ;
2003-12-04 22:52:24 +08:00
static ProcRecord image_convert_rgb_proc =
1999-03-28 14:55:29 +08:00
{
2003-12-04 22:52:24 +08:00
" gimp_image_convert_rgb " ,
1999-03-28 14:55:29 +08:00
" Convert specified image to RGB color " ,
2001-12-11 23:58:07 +08:00
" This procedure converts the specified image to RGB color. This process requires an image of type GIMP_GRAY or GIMP_INDEXED. No image content is lost in this process aside from the colormap for an indexed image. " ,
1999-03-28 14:55:29 +08:00
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-03-28 14:55:29 +08:00
1 ,
2003-12-04 22:52:24 +08:00
image_convert_rgb_inargs ,
1999-03-28 14:55:29 +08:00
0 ,
NULL ,
2003-12-04 22:52:24 +08:00
{ { image_convert_rgb_invoker } }
1999-03-28 14:55:29 +08:00
} ;
static Argument *
2003-12-04 22:52:24 +08:00
image_convert_grayscale_invoker ( Gimp * gimp ,
Argument * args )
1999-03-28 14:55:29 +08:00
{
gboolean success = TRUE ;
GimpImage * gimage ;
2001-07-11 20:39:49 +08:00
gimage = gimp_image_get_by_ID ( gimp , args [ 0 ] . value . pdb_int ) ;
2002-08-30 01:21:21 +08:00
if ( ! GIMP_IS_IMAGE ( gimage ) )
1999-03-28 14:55:29 +08:00
success = FALSE ;
if ( success )
2004-02-01 00:23:25 +08:00
{
if ( gimp_image_base_type ( gimage ) ! = GIMP_GRAY )
gimp_image_convert ( gimage , GIMP_GRAY , 0 , 0 , FALSE , FALSE , 0 , NULL ) ;
else
success = FALSE ;
}
1999-03-28 14:55:29 +08:00
2003-12-04 22:52:24 +08:00
return procedural_db_return_args ( & image_convert_grayscale_proc , success ) ;
1999-03-28 14:55:29 +08:00
}
2003-12-04 22:52:24 +08:00
static ProcArg image_convert_grayscale_inargs [ ] =
1999-03-28 14:55:29 +08:00
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_IMAGE ,
1999-03-28 14:55:29 +08:00
" image " ,
" The image "
}
} ;
2003-12-04 22:52:24 +08:00
static ProcRecord image_convert_grayscale_proc =
1999-03-28 14:55:29 +08:00
{
2003-12-04 22:52:24 +08:00
" gimp_image_convert_grayscale " ,
1999-03-28 14:55:29 +08:00
" Convert specified image to grayscale (256 intensity levels) " ,
2001-12-11 23:58:07 +08:00
" This procedure converts the specified image to grayscale with 8 bits per pixel (256 intensity levels). This process requires an image of type GIMP_RGB or GIMP_INDEXED. " ,
1999-03-28 14:55:29 +08:00
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-03-28 14:55:29 +08:00
1 ,
2003-12-04 22:52:24 +08:00
image_convert_grayscale_inargs ,
1999-03-28 14:55:29 +08:00
0 ,
NULL ,
2003-12-04 22:52:24 +08:00
{ { image_convert_grayscale_invoker } }
1999-03-28 14:55:29 +08:00
} ;
static Argument *
2003-12-04 22:52:24 +08:00
image_convert_indexed_invoker ( Gimp * gimp ,
Argument * args )
1999-09-01 05:26:34 +08:00
{
gboolean success = TRUE ;
GimpImage * gimage ;
gint32 dither_type ;
gint32 palette_type ;
gint32 num_cols ;
gboolean alpha_dither ;
gboolean remove_unused ;
gchar * palette_name ;
2001-07-11 20:39:49 +08:00
gimage = gimp_image_get_by_ID ( gimp , args [ 0 ] . value . pdb_int ) ;
2002-08-30 01:21:21 +08:00
if ( ! GIMP_IS_IMAGE ( gimage ) )
1999-09-01 05:26:34 +08:00
success = FALSE ;
dither_type = args [ 1 ] . value . pdb_int ;
2002-03-20 23:02:30 +08:00
if ( dither_type < GIMP_NO_DITHER | | dither_type > GIMP_FIXED_DITHER )
1999-09-02 04:41:10 +08:00
success = FALSE ;
1999-09-01 05:26:34 +08:00
palette_type = args [ 2 ] . value . pdb_int ;
2004-02-01 00:23:25 +08:00
if ( palette_type < GIMP_MAKE_PALETTE | | palette_type > GIMP_CUSTOM_PALETTE )
success = FALSE ;
1999-09-01 05:26:34 +08:00
num_cols = args [ 3 ] . value . pdb_int ;
alpha_dither = args [ 4 ] . value . pdb_int ? TRUE : FALSE ;
remove_unused = args [ 5 ] . value . pdb_int ? TRUE : FALSE ;
palette_name = ( gchar * ) args [ 6 ] . value . pdb_pointer ;
2003-08-19 02:09:26 +08:00
if ( palette_name = = NULL | | ! g_utf8_validate ( palette_name , - 1 , NULL ) )
1999-09-01 05:26:34 +08:00
success = FALSE ;
if ( success )
{
2001-04-19 01:57:10 +08:00
GimpPalette * palette = NULL ;
2004-02-01 00:23:25 +08:00
if ( gimp_image_base_type ( gimage ) ! = GIMP_INDEXED )
1999-09-01 05:26:34 +08:00
{
switch ( palette_type )
{
2002-03-18 21:55:19 +08:00
case GIMP_MAKE_PALETTE :
1999-09-01 05:26:34 +08:00
if ( num_cols < 1 | | num_cols > MAXNUMCOLORS )
success = FALSE ;
break ;
2002-03-18 21:55:19 +08:00
case GIMP_CUSTOM_PALETTE :
2001-07-05 03:31:35 +08:00
if ( ! gimp - > palette_factory - > container - > num_children )
gimp_data_factory_data_init ( gimp - > palette_factory , FALSE ) ;
1999-09-01 05:26:34 +08:00
2001-02-12 00:14:25 +08:00
palette = ( GimpPalette * )
2001-07-05 03:31:35 +08:00
gimp_container_get_child_by_name ( gimp - > palette_factory - > container ,
2001-02-12 00:14:25 +08:00
palette_name ) ;
2001-01-22 03:53:56 +08:00
2001-02-12 00:14:25 +08:00
if ( palette = = NULL )
1999-09-01 05:26:34 +08:00
success = FALSE ;
break ;
default :
2004-02-01 00:23:25 +08:00
break ;
1999-09-01 05:26:34 +08:00
}
}
2004-02-01 00:23:25 +08:00
else
{
success = FALSE ;
}
1999-09-01 05:26:34 +08:00
if ( success )
2001-12-14 23:30:31 +08:00
gimp_image_convert ( gimage , GIMP_INDEXED , num_cols , dither_type ,
2001-04-19 01:57:10 +08:00
alpha_dither , remove_unused , palette_type , palette ) ;
1999-09-01 05:26:34 +08:00
}
2003-12-04 22:52:24 +08:00
return procedural_db_return_args ( & image_convert_indexed_proc , success ) ;
1999-09-01 05:26:34 +08:00
}
2003-12-04 22:52:24 +08:00
static ProcArg image_convert_indexed_inargs [ ] =
1999-09-01 05:26:34 +08:00
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_IMAGE ,
1999-09-01 05:26:34 +08:00
" image " ,
" The image "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-09-01 05:26:34 +08:00
" dither_type " ,
2004-02-01 00:23:25 +08:00
" The dither type to use: { GIMP_NO_DITHER (0), GIMP_FS_DITHER (1), GIMP_FSLOWBLEED_DITHER (2), GIMP_FIXED_DITHER (3) } "
1999-09-01 05:26:34 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-09-01 05:26:34 +08:00
" palette_type " ,
2002-03-18 21:55:19 +08:00
" The type of palette to use: { GIMP_MAKE_PALETTE (0), GIMP_REUSE_PALETTE (1), GIMP_WEB_PALETTE (2), GIMP_MONO_PALETTE (3), GIMP_CUSTOM_PALETTE (4) } "
1999-09-01 05:26:34 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-09-01 05:26:34 +08:00
" num_cols " ,
2004-02-01 00:23:25 +08:00
" The number of colors to quantize to, ignored unless (palette_type == GIMP_MAKE_PALETTE) "
1999-09-01 05:26:34 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-09-01 05:26:34 +08:00
" alpha_dither " ,
2004-02-01 00:23:25 +08:00
" Dither transparency to fake partial opacity "
1999-09-01 05:26:34 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-09-01 05:26:34 +08:00
" remove_unused " ,
2004-02-01 00:23:25 +08:00
" Remove unused or duplicate colour entries from final palette, ignored if (palette_type == GIMP_MAKE_PALETTE) "
1999-09-01 05:26:34 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
1999-09-01 05:26:34 +08:00
" palette " ,
2002-03-18 21:55:19 +08:00
" The name of the custom palette to use, ignored unless (palette_type == GIMP_CUSTOM_PALETTE) "
1999-09-01 05:26:34 +08:00
}
} ;
2003-12-04 22:52:24 +08:00
static ProcRecord image_convert_indexed_proc =
1999-09-01 05:26:34 +08:00
{
2003-12-04 22:52:24 +08:00
" gimp_image_convert_indexed " ,
1999-09-02 04:41:10 +08:00
" Convert specified image to and Indexed image " ,
2001-12-11 23:58:07 +08:00
" This procedure converts the specified image to 'indexed' color. This process requires an image of type GIMP_GRAY or GIMP_RGB. The 'palette_type' specifies what kind of palette to use, A type of '0' means to use an optimal palette of 'num_cols' generated from the colors in the image. A type of '1' means to re-use the previous palette (not currently implemented). A type of '2' means to use the so-called WWW-optimized palette. Type '3' means to use only black and white colors. A type of '4' means to use a palette from the gimp palettes directories. The 'dither type' specifies what kind of dithering to use. '0' means no dithering, '1' means standard Floyd-Steinberg error diffusion, '2' means Floyd-Steinberg error diffusion with reduced bleeding, '3' means dithering based on pixel location ('Fixed' dithering). " ,
1999-09-01 05:26:34 +08:00
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-09-01 05:26:34 +08:00
7 ,
2003-12-04 22:52:24 +08:00
image_convert_indexed_inargs ,
1999-09-01 05:26:34 +08:00
0 ,
NULL ,
2003-12-04 22:52:24 +08:00
{ { image_convert_indexed_invoker } }
1999-09-01 05:26:34 +08:00
} ;