Commit 5131a011 authored by Manish Singh's avatar Manish Singh

#include <glib.h>

* app/procedural_db.h: #include <glib.h>

* app/channel_ops.[ch]: exported OFFSET_BACKGROUND and
OFFSET_TRANSPARENT as an enum

* app/convert.[ch]: exported MACNUMCOLORS, theCustomPalette,
convert_image, removed PDB procs

* app/text_tool.[ch]: exported PIXELS and POINTS as an enum

* app/convert_cmds.c
* app/edit_cmds.c
* app/floating_sel_cmds.c
* app/gdisplay_cmds.c
* app/paths_cmds.c
* app/undo_cmds.c: pdbgen autogenerated files now

* app/internal_procs.c: use the pdbgen register_foo functions

* app/edit_cmds.h
* app/floating_sel_cmds.h
* app/gdisplay_cmds.h
* app/paths_cmds.h
* app/undo_cmds.h: removed

* app/Makefile.am: reflect above changes

* Makefile.am: paths.xbm->path.xbm, fix typo in EXTRA_DIST

-Yosh
parent a1a1b78c
Sat Mar 27 22:37:35 PST 1999 Manish Singh <yosh@gimp.org>
* app/procedural_db.h: #include <glib.h>
* app/channel_ops.[ch]: exported OFFSET_BACKGROUND and
OFFSET_TRANSPARENT as an enum
* app/convert.[ch]: exported MACNUMCOLORS, theCustomPalette,
convert_image, removed PDB procs
* app/text_tool.[ch]: exported PIXELS and POINTS as an enum
* app/convert_cmds.c
* app/edit_cmds.c
* app/floating_sel_cmds.c
* app/gdisplay_cmds.c
* app/paths_cmds.c
* app/undo_cmds.c: pdbgen autogenerated files now
* app/internal_procs.c: use the pdbgen register_foo functions
* app/edit_cmds.h
* app/floating_sel_cmds.h
* app/gdisplay_cmds.h
* app/paths_cmds.h
* app/undo_cmds.h: removed
* app/Makefile.am: reflect above changes
* Makefile.am: paths.xbm->path.xbm, fix typo in EXTRA_DIST
Sun Mar 28 00:28:57 EST 1999 Adrian Likins <adrian@gimp.org>
* app/paintbrush.c: added the ability to select the
......@@ -195,8 +226,6 @@ Fri Mar 19 20:24:20 PST 1999 Manish Singh <yosh@gimp.org>
* app/threshold.c
* app/xcf.c: remove unused vars, other minor code cleanups
* app/procedural_db.h: #include <glib.h>
* Makefile.am: add README.perl to EXTRA_DIST
Fri Mar 19 04:01:04 EST 1999 Adrian Likins <adrian@gimp.org>
......
......@@ -18,7 +18,7 @@ EXTRA_DIST = \
pixmaps/new.xpm \
pixmaps/no.xpm \
pixmaps/raise.xpm \
pixmaps/paths.xbm \
pixmaps/path.xbm \
pixmaps/penadd.xpm \
pixmaps/pendel.xpm \
pixmaps/penedit.xpm \
......
......@@ -95,6 +95,7 @@ gimp_SOURCES = \
commands.h \
convert.c \
convert.h \
convert_cmds.c \
convolve.c \
convolve.h \
crop.c \
......@@ -126,7 +127,6 @@ gimp_SOURCES = \
drawable_cmds.c \
drawable_cmds.h \
edit_cmds.c \
edit_cmds.h \
edit_selection.c \
edit_selection.h \
ellipse_select.c \
......@@ -146,7 +146,6 @@ gimp_SOURCES = \
floating_sel.c \
floating_sel.h \
floating_sel_cmds.c \
floating_sel_cmds.h \
file_new_dialog.c \
file_new_dialog.h \
frac.c \
......@@ -161,7 +160,6 @@ gimp_SOURCES = \
gdisplayP.h \
gdisplayF.h \
gdisplay_cmds.c \
gdisplay_cmds.h \
gdisplay_ops.c \
gdisplay_ops.h \
general.c \
......@@ -200,6 +198,7 @@ gimp_SOURCES = \
gimphistogram.h \
gimphistogramP.h \
gimpunit.c \
gimpunit_cmds.h \
global_edit.c \
global_edit.h \
gradient.c \
......@@ -277,7 +276,6 @@ gimp_SOURCES = \
parasitelistF.h \
parasitelistP.h \
paths_cmds.c \
paths_cmds.h \
paths_dialog.h \
paths_dialog.c \
pathsP.h \
......@@ -351,8 +349,6 @@ gimp_SOURCES = \
undo.c \
undo.h \
undo_cmds.c \
undo_cmds.h \
unit_cmds.h \
unitrc.h \
wilber.h \
vector2d.c \
......
......@@ -33,8 +33,6 @@
#include "channel_pvt.h"
#define ENTRY_WIDTH 60
#define OFFSET_BACKGROUND 0
#define OFFSET_TRANSPARENT 1
typedef struct
{
......
......@@ -21,6 +21,11 @@
#include "procedural_db.h"
#include "gimpimageF.h"
typedef enum {
OFFSET_BACKGROUND,
OFFSET_TRANSPARENT
} ChannelOffsetType;
/* channel_ops functions */
void channel_ops_offset (GimpImage*);
......
......@@ -96,8 +96,6 @@
#include "drawable_pvt.h" /* ick ick. */
#include "tile_manager_pvt.h" /* ick ick ick. */
#define MAXNUMCOLORS 256
#define NODITHER 0
#define FSDITHER 1
#define NODESTRUCTDITHER 2
......@@ -233,11 +231,6 @@ typedef struct
int reusepal_flag;
} IndexedDialog;
static Argument * convert_rgb_invoker (Argument *);
static Argument * convert_grayscale_invoker (Argument *);
static Argument * convert_indexed_invoker (Argument *);
static Argument * convert_indexed_palette_invoker (Argument *);
static void indexed_ok_callback (GtkWidget *, gpointer);
static void indexed_cancel_callback (GtkWidget *, gpointer);
static gint indexed_delete_callback (GtkWidget *, GdkEvent *, gpointer);
......@@ -245,7 +238,6 @@ static void indexed_num_cols_update (GtkWidget *, gpointer);
static void indexed_radio_update (GtkWidget *, gpointer);
static void indexed_dither_update (GtkWidget *, gpointer);
static void convert_image (GImage *, int, int, int, int);
static void rgb_converter (Layer *, TileManager *, int);
static void grayscale_converter (Layer *, TileManager *, int);
......@@ -268,9 +260,10 @@ static gboolean needs_quantize;
static GtkWidget *build_palette_menu(int *default_palette);
static void palette_entries_callback(GtkWidget *w, gpointer client_data);
static PaletteEntriesP theCustomPalette = NULL;
static gboolean UserHasWebPal = FALSE;
PaletteEntriesP theCustomPalette = NULL;
/* Defaults */
static int snum_cols = 256;
......@@ -744,7 +737,7 @@ indexed_dither_update (GtkWidget *w,
dialog->dither = FALSE;
}
static void
void
convert_image (GImage *gimage,
int new_type,
int num_cols, /* used only for new_type == INDEXED */
......@@ -3133,319 +3126,3 @@ initialize_median_cut (int type,
return quantobj;
}
/*
* Procedure database functions and data structures
*/
/* The convert-rgb procedure definition */
ProcArg convert_rgb_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
}
};
ProcRecord convert_rgb_proc =
{
"gimp_convert_rgb",
"Convert specified image to RGB color",
"This procedure converts the specified image to RGB color. This process requires an image of type GRAY or INDEXED. No image content is lost in this process aside from the colormap for an indexed image.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
convert_rgb_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { convert_rgb_invoker } },
};
static Argument *
convert_rgb_invoker (Argument *args)
{
int success = TRUE;
int int_value;
GImage *gimage;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* make sure the drawable is not RGB color */
if (success)
success = (gimage_base_type (gimage) != RGB);
if (success)
convert_image ((void *) gimage, RGB, 0, 0, 0);
return procedural_db_return_args (&convert_rgb_proc, success);
}
/* The convert-grayscale procedure definition */
ProcArg convert_grayscale_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
}
};
ProcRecord convert_grayscale_proc =
{
"gimp_convert_grayscale",
"Convert specified image to grayscale (256 intensity levels)",
"This procedure converts the specified image to grayscale with 8 bits per pixel (256 intensity levels). This process requires an image of type RGB or INDEXED.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
1,
convert_grayscale_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { convert_grayscale_invoker } },
};
static Argument *
convert_grayscale_invoker (Argument *args)
{
int success = TRUE;
int int_value;
GImage *gimage;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* make sure the drawable is not GRAYSCALE color */
if (success)
success = (gimage_base_type (gimage) != GRAY);
if (success)
convert_image ((void *) gimage, GRAY, 0, 0, 0);
return procedural_db_return_args (&convert_grayscale_proc, success);
}
/* The convert-indexed procedure definition */
ProcArg convert_indexed_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_INT32,
"dither",
"Floyd-Steinberg dithering"
},
{ PDB_INT32,
"num_cols",
"the number of colors to quantize to"
}
};
ProcRecord convert_indexed_proc =
{
"gimp_convert_indexed",
"Convert specified image to indexed color",
"This procedure converts the specified image to indexed color. This process requires an image of type GRAY or RGB. The 'num_cols' arguments specifies how many colors the resulting image should be quantized to (1-256).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
3,
convert_indexed_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { convert_indexed_invoker } },
};
static Argument *
convert_indexed_invoker (Argument *args)
{
int success = TRUE;
int int_value;
GImage *gimage;
int dither;
int num_cols;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* make sure the drawable is not INDEXED color */
if (success)
success = (gimage_base_type (gimage) != INDEXED);
if (success)
dither = (args[1].value.pdb_int) ? TRUE : FALSE;
if (success)
{
num_cols = args[2].value.pdb_int;
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
}
if (success)
convert_image ((void *) gimage, INDEXED, num_cols, dither, 0);
return procedural_db_return_args (&convert_indexed_proc, success);
}
/* The convert-indexed-palette procedure definition */
ProcArg convert_indexed_palette_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_INT32,
"dither",
"Floyd-Steinberg dithering"
},
{ PDB_INT32,
"palette_type",
"The type of palette to use, (0 optimal) (1 reuse) (2 WWW) (3 Mono) (4 Custom)"
},
{ PDB_INT32,
"num_cols",
"the number of colors to quantize to, ignored unless (palette_type == 0)"
},
{ PDB_STRING,
"palette",
"The name of the custom palette to use, ignored unless (palette_type == 4)"
}
};
ProcRecord convert_indexed_palette_proc =
{
"gimp_convert_indexed_palette",
"Convert specified image to indexed color",
"This procedure converts the specified image to indexed color. This process requires an image of type GRAY or 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. A type of `2' means to use the 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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
5,
convert_indexed_palette_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { convert_indexed_palette_invoker } },
};
static Argument *
convert_indexed_palette_invoker (Argument *args)
{
int success = TRUE;
int int_value;
GImage *gimage;
int dither;
int num_cols=0;
int palette_type;
char *palette_name;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* make sure the drawable is not INDEXED color */
if (success)
success = (gimage_base_type (gimage) != INDEXED);
if (success)
dither = (args[1].value.pdb_int) ? TRUE : FALSE;
if (success)
{
PaletteEntriesP entries, the_palette = NULL;
GSList *list;
palette_type = args[2].value.pdb_int;
switch(palette_type) {
case MAKE_PALETTE:
num_cols = args[3].value.pdb_int;
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
break;
case REUSE_PALETTE:
break;
case WEB_PALETTE:
break;
case MONO_PALETTE:
break;
case CUSTOM_PALETTE:
palette_name = args[4].value.pdb_pointer;
/* fprintf(stderr, "looking for palette `%s'\n", palette_name); */
if (!palette_entries_list) palette_init_palettes(FALSE);
for(list = palette_entries_list;
list;
list = g_slist_next(list)) {
entries = (PaletteEntriesP) list->data;
if (strcmp(palette_name, entries->name)==0) {
/* fprintf(stderr, "found it!\n"); */
the_palette = entries;
break;
}
}
if (the_palette == NULL) {
/* fprintf(stderr, "didn't find it\n"); */
success = FALSE;
}
else
theCustomPalette = the_palette;
break;
default:
success = FALSE;
}
}
if (success)
convert_image ((void *) gimage, INDEXED, num_cols, dither, palette_type);
return procedural_db_return_args (&convert_indexed_palette_proc, success);
}
......@@ -31,15 +31,15 @@ typedef enum {
CUSTOM_PALETTE
} ConvertPaletteType;
#define MAXNUMCOLORS 256
/* convert functions */
void convert_to_rgb (GimpImage *);
void convert_to_grayscale (GimpImage *);
void convert_to_indexed (GimpImage *);
void convert_to_rgb (GimpImage *);
void convert_to_grayscale (GimpImage *);
void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *, int, int, int, int);
/* Procedure definition and marshalling function */
extern ProcRecord convert_rgb_proc;
extern ProcRecord convert_grayscale_proc;
extern ProcRecord convert_indexed_proc;
extern ProcRecord convert_indexed_palette_proc;
extern PaletteEntriesP theCustomPalette;
#endif /* __CONVERT_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* 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. */
#include "procedural_db.h"
#include "convert.h"
#include "gimage.h"
#include "palette.h"
static ProcRecord convert_rgb_proc;
static ProcRecord convert_grayscale_proc;
static ProcRecord convert_indexed_proc;
static ProcRecord convert_indexed_palette_proc;
void
register_convert_procs (void)
{
procedural_db_register (&convert_rgb_proc);
procedural_db_register (&convert_grayscale_proc);
procedural_db_register (&convert_indexed_proc);
procedural_db_register (&convert_indexed_palette_proc);
}
static Argument *
convert_rgb_invoker (Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
if (success)
if ((success = (gimage_base_type (gimage) != RGB)))
convert_image ((void *) gimage, RGB, 0, 0, 0);
return procedural_db_return_args (&convert_rgb_proc, success);
}
static ProcArg convert_rgb_inargs[] =
{
{
PDB_IMAGE,
"image",
"The image"
}
};
static ProcRecord convert_rgb_proc =
{
"gimp_convert_rgb",
"Convert specified image to RGB color",
"This procedure converts the specified image to RGB color. This process requires an image of type GRAY or INDEXED. No image content is lost in this process aside from the colormap for an indexed image.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
1,
convert_rgb_inargs,
0,
NULL,
{ { convert_rgb_invoker } }
};
static Argument *
convert_grayscale_invoker (Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
if (success)
if ((success = (gimage_base_type (gimage) != GRAY)))
convert_image ((void *) gimage, GRAY, 0, 0, 0);
return procedural_db_return_args (&convert_grayscale_proc, success);
}
static ProcArg convert_grayscale_inargs[] =
{
{
PDB_IMAGE,
"image",
"The image"
}
};
static ProcRecord convert_grayscale_proc =
{
"gimp_convert_grayscale",
"Convert specified image to grayscale (256 intensity levels)",
"This procedure converts the specified image to grayscale with 8 bits per pixel (256 intensity levels). This process requires an image of type RGB or INDEXED.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
1,
convert_grayscale_inargs,
0,
NULL,
{ { convert_grayscale_invoker } }
};
static Argument *
convert_indexed_invoker (Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gboolean dither;
gint32 num_cols;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
dither = args[1].value.pdb_int ? TRUE : FALSE;
num_cols = args[2].value.pdb_int;
if (success)
{
success = (gimage_base_type (gimage) != INDEXED);
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
if (success)
convert_image ((void *) gimage, INDEXED, num_cols, dither, 0);
}
return procedural_db_return_args (&convert_indexed_proc, success);
}
static ProcArg convert_indexed_inargs[] =
{
{
PDB_IMAGE,
"image",
"The image"
},
{
PDB_INT32,
"dither",
"Floyd-Steinberg dithering"
},
{
PDB_INT32,
"num_cols",
"the number of colors to quantize to"
}
};
static ProcRecord convert_indexed_proc =
{
"gimp_convert_indexed",
"Convert specified image to indexed color",
"This procedure converts the specified image to indexed color. This process requires an image of type GRAY or RGB. The 'num_cols' arguments specifies how many colors the resulting image should be quantized to (1-256).",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
3,
convert_indexed_inargs,
0,
NULL,
{ { convert_indexed_invoker } }
};
static Argument *
convert_indexed_palette_invoker (Argument *args)
{
gboolean success = TRUE;
GimpImage *gimage;
gboolean dither;
gint32 palette_type;
gint32 num_cols;
gchar *palette_name;
gimage = pdb_id_to_image (args[0].value.pdb_int);
if (gimage == NULL)
success = FALSE;
dither = args[1].value.pdb_int ? TRUE : FALSE;
palette_type = args[2].value.pdb_int;
num_cols = args[3].value.pdb_int;
if (success)
{
palette_name = (gchar *) args[4].value.pdb_pointer;
success = palette_name != NULL;
}
if (success)
{
if ((success = (gimage_base_type (gimage) != INDEXED)))
{
PaletteEntriesP entries, the_palette = NULL;
GSList *list;
switch (palette_type)
{
case MAKE_PALETTE:
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
break;
case REUSE_PALETTE:
case WEB_PALETTE: