mirror of https://github.com/GNOME/gimp.git
parent
1c10cb054a
commit
763bd6ab98
|
@ -61,12 +61,12 @@ libgimpi_a_SOURCES = \
|
|||
gimpwidgets.h \
|
||||
gimpwire.c \
|
||||
gimpwire.h \
|
||||
parasite.c \
|
||||
parasite.h \
|
||||
parasiteF.h \
|
||||
parasiteP.h \
|
||||
parasiteio.c \
|
||||
parasiteio.h
|
||||
gimpparasite.c \
|
||||
gimpparasite.h \
|
||||
gimpparasiteF.h \
|
||||
gimpparasiteP.h \
|
||||
gimpparasiteio.c \
|
||||
gimpparasiteio.h
|
||||
|
||||
if STATICLIBS
|
||||
## Evil hack to insure all deps are satisfied on first-run make
|
||||
|
@ -80,27 +80,27 @@ endif
|
|||
|
||||
libgimp_la_SOURCES = \
|
||||
gimp.c \
|
||||
gimpchannel.c \
|
||||
gimpchannel_pdb.c \
|
||||
gimpcolorbutton.h \
|
||||
gimpcolorspace.c \
|
||||
gimpdisplay.c \
|
||||
gimpdrawable.c \
|
||||
gimpdisplay_pdb.c \
|
||||
gimpdrawable_pdb.c \
|
||||
gimpenv.c \
|
||||
gimpgradient.c \
|
||||
gimphelp.c \
|
||||
gimpimage.c \
|
||||
gimplayer.c \
|
||||
gimpgradient_pdb.c \
|
||||
gimphelp_pdb.c \
|
||||
gimpimage_pdb.c \
|
||||
gimplayer_pdb.c \
|
||||
gimpmatrix.c \
|
||||
gimpmatrix.h \
|
||||
gimppalette.c \
|
||||
gimpparasite.c \
|
||||
gimppalette_pdb.c \
|
||||
gimpparasite_pdb.c \
|
||||
gimppixelrgn.c \
|
||||
gimpprotocol.c \
|
||||
gimpprotocol.h \
|
||||
gimpselection.c \
|
||||
gimpselection_pdb.c \
|
||||
gimpsignal.c \
|
||||
gimptile.c \
|
||||
gimpunit.c \
|
||||
gimpunit_pdb.c \
|
||||
gimpunit.h \
|
||||
gimputils.c \
|
||||
gimputils.h \
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1999 Manish Singh <yosh@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_DISPLAY_H__
|
||||
#define __GIMP_COLOR_DISPLAY_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include <libgimp/parasiteF.h>
|
||||
|
||||
typedef void (* GimpColorDisplayInit) (void);
|
||||
typedef gpointer (* GimpColorDisplayNew) (gint type);
|
||||
typedef gpointer (* GimpColorDisplayClone) (gpointer cd_ID);
|
||||
typedef void (* GimpColorDisplayConvert) (gpointer cd_ID,
|
||||
guchar *buf,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bpp,
|
||||
gint bpl);
|
||||
typedef void (* GimpColorDisplayDestroy) (gpointer cd_ID);
|
||||
typedef void (* GimpColorDisplayFinalize) (void);
|
||||
typedef void (* GimpColorDisplayLoadState) (gpointer cd_ID,
|
||||
GimpParasite *state);
|
||||
typedef GimpParasite * (* GimpColorDisplaySaveState) (gpointer cd_ID);
|
||||
typedef void (* GimpColorDisplayConfigure) (gpointer cd_ID,
|
||||
GFunc ok_func,
|
||||
gpointer ok_data,
|
||||
GFunc cancel_func,
|
||||
gpointer cancel_data);
|
||||
typedef void (* GimpColorDisplayConfigureCancel) (gpointer cd_ID);
|
||||
|
||||
typedef struct _GimpColorDisplayMethods GimpColorDisplayMethods;
|
||||
|
||||
struct _GimpColorDisplayMethods
|
||||
{
|
||||
GimpColorDisplayInit init;
|
||||
GimpColorDisplayNew new;
|
||||
GimpColorDisplayClone clone;
|
||||
GimpColorDisplayConvert convert;
|
||||
GimpColorDisplayDestroy destroy;
|
||||
GimpColorDisplayFinalize finalize;
|
||||
GimpColorDisplayLoadState load;
|
||||
GimpColorDisplaySaveState save;
|
||||
GimpColorDisplayConfigure configure;
|
||||
GimpColorDisplayConfigureCancel cancel;
|
||||
};
|
||||
|
||||
/*
|
||||
* The following two functions are implemted and exported by gimp/app
|
||||
* but need to be marked for it here too ...
|
||||
*/
|
||||
G_MODULE_EXPORT
|
||||
gboolean gimp_color_display_register (const char *name,
|
||||
GimpColorDisplayMethods *methods);
|
||||
G_MODULE_EXPORT
|
||||
gboolean gimp_color_display_unregister (const char *name);
|
||||
|
||||
#endif /* __GIMP_COLOR_DISPLAY_H__ */
|
|
@ -1,109 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Colour selector module (C) 1999 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser 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.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_SELECTOR_H__
|
||||
#define __COLOR_SELECTOR_H__
|
||||
|
||||
|
||||
/********************************/
|
||||
/* color selector registration */
|
||||
|
||||
|
||||
/* A function of this type should be called by the color selector each
|
||||
* time the user modifies the selected color. */
|
||||
typedef void (*GimpColorSelector_Callback)(void *data, int r, int g, int b);
|
||||
|
||||
|
||||
/* A function of this type is called to create a new instance of the
|
||||
* color selector. The new selector should set its current color to
|
||||
* the RGB triple given (each component is in the range 0 - 255
|
||||
* inclusive, with white at 255,255,255 and black at 0,0,0).
|
||||
*
|
||||
* The selector should call "cb" with argument "data" each time the
|
||||
* user modifies the selected color.
|
||||
*
|
||||
* The selector must return a GtkWidget which implements the color
|
||||
* selection UI. The selector can optionally return "selector_data",
|
||||
* an opaque pointer which will be passed in to subsequent invokations
|
||||
* on the selector. */
|
||||
typedef GtkWidget * (*GimpColorSelector_NewFunc)(int r, int g, int b,
|
||||
GimpColorSelector_Callback cb,
|
||||
void *data,
|
||||
void **selector_data);
|
||||
|
||||
/* A function of this type is called when the color selector is no
|
||||
* longer required. This function should not free widgets that are
|
||||
* containted within the UI widget returned by new(), since they are
|
||||
* destroyed on behalf of the selector by the caller of this
|
||||
* function. */
|
||||
typedef void (*GimpColorSelector_FreeFunc)(void *selector_data);
|
||||
|
||||
|
||||
/* A function of this type is called to change the selector's current
|
||||
* color. The required color is specified as in the new() function.
|
||||
* If the "set_current" parameter is FALSE, then only the old color
|
||||
* should be set - if "set_current" is TRUE, both the old color and
|
||||
* the current color should be set to the RGB triple given. This
|
||||
* function merely gives a hint to the color selector; the selector
|
||||
* can choose to ignore this information. */
|
||||
typedef void (*GimpColorSelector_SetColorFunc)(void *selector_data,
|
||||
int r, int g, int b,
|
||||
int set_current);
|
||||
|
||||
typedef struct _GimpColorSelectorMethods GimpColorSelectorMethods;
|
||||
|
||||
struct _GimpColorSelectorMethods {
|
||||
GimpColorSelector_NewFunc new;
|
||||
GimpColorSelector_FreeFunc free;
|
||||
GimpColorSelector_SetColorFunc setcolor;
|
||||
};
|
||||
|
||||
typedef void *GimpColorSelectorID;
|
||||
|
||||
#ifndef __COLOR_NOTEBOOK_C__ /* Bypass when compiling the source for
|
||||
* these functions. */
|
||||
|
||||
/* Register a color selector. Returns an identifier for the color
|
||||
* selector on success, or NULL if the name is already in use. Both
|
||||
* the name and method table are internalised, so may be freed after
|
||||
* this call. */
|
||||
GimpColorSelectorID gimp_color_selector_register (const char *name,
|
||||
const char *help_page,
|
||||
GimpColorSelectorMethods *methods);
|
||||
|
||||
/* Remove the selector "id" from active service. New instances of the
|
||||
* selector will not be created, but existing ones are allowed to
|
||||
* continue. If "callback" is non-NULL, it will be called once all
|
||||
* instances have finished. The callback could be used to unload
|
||||
* dynamiclly loaded code, for example.
|
||||
*
|
||||
* Returns TRUE on success, FALSE if "id" was not found. */
|
||||
gboolean gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data);
|
||||
#endif /* !__COLOR_NOTEBOOK_C__ */
|
||||
|
||||
#endif /* __COLOR_SELECTOR_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h"
|
||||
#include "libgimp/gimpparasite.h"
|
||||
#include "libgimp/gimpparasiteP.h"
|
||||
#include "libgimp/gimpunit.h"
|
||||
#include "libgimp/gimputils.h"
|
||||
#include "libgimp/gimpvector.h"
|
||||
|
|
|
@ -1,326 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
gint32
|
||||
gimp_channel_new (gint32 image_ID,
|
||||
gchar *name,
|
||||
guint width,
|
||||
guint height,
|
||||
gdouble opacity,
|
||||
guchar *color)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 channel_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_new",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_INT32, width,
|
||||
PARAM_INT32, height,
|
||||
PARAM_STRING, name,
|
||||
PARAM_FLOAT, opacity,
|
||||
PARAM_COLOR, color,
|
||||
PARAM_END);
|
||||
|
||||
channel_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
channel_ID = return_vals[1].data.d_channel;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return channel_ID;
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_channel_copy (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_copy",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
channel_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
channel_ID = return_vals[1].data.d_channel;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return channel_ID;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_delete (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_delete",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_channel_width (gint32 channel_ID)
|
||||
{
|
||||
return gimp_drawable_width (channel_ID);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_channel_height (gint32 channel_ID)
|
||||
{
|
||||
return gimp_drawable_height (channel_ID);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_channel_get_image_id (gint32 channel_ID)
|
||||
{
|
||||
return gimp_drawable_image_id (channel_ID);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_channel_get_layer_id (gint32 channel_ID)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_get_color (gint32 channel_ID,
|
||||
guchar *red,
|
||||
guchar *green,
|
||||
guchar *blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_color",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*red = return_vals[1].data.d_color.red;
|
||||
*green = return_vals[1].data.d_color.green;
|
||||
*blue = return_vals[1].data.d_color.blue;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gchar*
|
||||
gimp_channel_get_name (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *name;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_name",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
name = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
name = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_channel_get_opacity (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gdouble opacity;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_opacity",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
opacity = 0.0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
opacity = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return opacity;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_channel_get_visible (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean visible;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_visible",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
visible = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
visible = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_color (gint32 channel_ID,
|
||||
guchar red,
|
||||
guchar green,
|
||||
guchar blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
guchar color[3];
|
||||
|
||||
color[0] = red;
|
||||
color[1] = green;
|
||||
color[2] = blue;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_set_color",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_COLOR, color,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_name (gint32 channel_ID,
|
||||
gchar *name)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_set_name",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_STRING, name,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_opacity (gint32 channel_ID,
|
||||
gdouble opacity)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_set_opacity",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_FLOAT, opacity,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_visible (gint32 channel_ID,
|
||||
gboolean visible)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_set_visible",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_INT32, visible,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_channel_get_show_masked (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint show_masked;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_show_masked",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
show_masked = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
show_masked = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return show_masked;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_channel_set_show_masked (gint32 channel_ID,
|
||||
gint show_masked)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_set_show_masked",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_INT32, show_masked,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_channel_get_tattoo (gint32 channel_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint tattoo;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_channel_get_tattoo",
|
||||
&nreturn_vals,
|
||||
PARAM_CHANNEL, channel_ID,
|
||||
PARAM_END);
|
||||
|
||||
tattoo = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
tattoo = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return tattoo;
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
gint32
|
||||
gimp_display_new (gint32 image_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gint32 display_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_display_new",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
|
||||
display_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
display_ID = return_vals[1].data.d_display;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return display_ID;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_delete (gint32 display_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_display_delete",
|
||||
&nreturn_vals,
|
||||
PARAM_DISPLAY, display_ID,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_displays_flush ()
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_displays_flush",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
|
@ -1,694 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
#define TILE_WIDTH _gimp_tile_width
|
||||
#define TILE_HEIGHT _gimp_tile_height
|
||||
|
||||
|
||||
extern gint _gimp_tile_width;
|
||||
extern gint _gimp_tile_height;
|
||||
|
||||
|
||||
GDrawable*
|
||||
gimp_drawable_get (gint32 drawable_ID)
|
||||
{
|
||||
GDrawable *drawable;
|
||||
|
||||
drawable = g_new (GDrawable, 1);
|
||||
drawable->id = drawable_ID;
|
||||
drawable->width = gimp_drawable_width (drawable_ID);
|
||||
drawable->height = gimp_drawable_height (drawable_ID);
|
||||
drawable->bpp = gimp_drawable_bpp (drawable_ID);
|
||||
drawable->ntile_rows = (drawable->height + TILE_HEIGHT - 1) / TILE_HEIGHT;
|
||||
drawable->ntile_cols = (drawable->width + TILE_WIDTH - 1) / TILE_WIDTH;
|
||||
drawable->tiles = NULL;
|
||||
drawable->shadow_tiles = NULL;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_detach (GDrawable *drawable)
|
||||
{
|
||||
if (drawable)
|
||||
{
|
||||
gimp_drawable_flush (drawable);
|
||||
if (drawable->tiles)
|
||||
g_free (drawable->tiles);
|
||||
if (drawable->shadow_tiles)
|
||||
g_free (drawable->shadow_tiles);
|
||||
g_free (drawable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_flush (GDrawable *drawable)
|
||||
{
|
||||
GTile *tiles;
|
||||
gint ntiles;
|
||||
gint i;
|
||||
|
||||
if (drawable)
|
||||
{
|
||||
if (drawable->tiles)
|
||||
{
|
||||
tiles = drawable->tiles;
|
||||
ntiles = drawable->ntile_rows * drawable->ntile_cols;
|
||||
|
||||
for (i = 0; i < ntiles; i++)
|
||||
if ((tiles[i].ref_count > 0) && tiles[i].dirty)
|
||||
gimp_tile_flush (&tiles[i]);
|
||||
}
|
||||
|
||||
if (drawable->shadow_tiles)
|
||||
{
|
||||
tiles = drawable->shadow_tiles;
|
||||
ntiles = drawable->ntile_rows * drawable->ntile_cols;
|
||||
|
||||
for (i = 0; i < ntiles; i++)
|
||||
if ((tiles[i].ref_count > 0) && tiles[i].dirty)
|
||||
gimp_tile_flush (&tiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_delete (GDrawable *drawable)
|
||||
{
|
||||
if (drawable)
|
||||
{
|
||||
if (gimp_drawable_is_layer (drawable->id))
|
||||
gimp_layer_delete (drawable->id);
|
||||
else
|
||||
gimp_channel_delete (drawable->id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_update (gint32 drawable_ID,
|
||||
gint x,
|
||||
gint y,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_update",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_INT32, x,
|
||||
PARAM_INT32, y,
|
||||
PARAM_INT32, width,
|
||||
PARAM_INT32, height,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_merge_shadow (gint32 drawable_ID,
|
||||
gint undoable)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_merge_shadow",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_INT32, undoable,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_drawable_image_id (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 image_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_image",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
image_ID = -1;
|
||||
if (return_vals[0].data.d_int32 == STATUS_SUCCESS)
|
||||
image_ID = return_vals[1].data.d_image;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
||||
gchar*
|
||||
gimp_drawable_name (gint32 drawable_ID)
|
||||
{
|
||||
if (gimp_drawable_is_layer (drawable_ID))
|
||||
return gimp_layer_get_name (drawable_ID);
|
||||
return gimp_channel_get_name (drawable_ID);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_drawable_width (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
guint width;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_width",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
width = 0;
|
||||
if (return_vals[0].data.d_int32 == STATUS_SUCCESS)
|
||||
width = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_drawable_height (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
guint height;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_height",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
height = 0;
|
||||
if (return_vals[0].data.d_int32 == STATUS_SUCCESS)
|
||||
height = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_drawable_bpp (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
guint bpp;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_bytes",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
bpp = 0;
|
||||
if (return_vals[0].data.d_int32 == STATUS_SUCCESS)
|
||||
bpp = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return bpp;
|
||||
}
|
||||
|
||||
GDrawableType
|
||||
gimp_drawable_type (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_type",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = -1;
|
||||
if (return_vals[0].data.d_int32 == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_visible (gint32 drawable_ID)
|
||||
{
|
||||
if (gimp_drawable_is_layer (drawable_ID))
|
||||
return gimp_layer_get_visible (drawable_ID);
|
||||
|
||||
return gimp_channel_get_visible (drawable_ID);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_channel (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_channel",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_rgb (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_rgb",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_gray (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_gray",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_has_alpha (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_has_alpha",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_indexed (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_indexed",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_layer (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_layer",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_is_layer_mask (gint32 drawable_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_is_layer_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_mask_bounds (gint32 drawable_ID,
|
||||
gint *x1,
|
||||
gint *y1,
|
||||
gint *x2,
|
||||
gint *y2)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_mask_bounds",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
result = return_vals[1].data.d_int32;
|
||||
*x1 = return_vals[2].data.d_int32;
|
||||
*y1 = return_vals[3].data.d_int32;
|
||||
*x2 = return_vals[4].data.d_int32;
|
||||
*y2 = return_vals[5].data.d_int32;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_offsets (gint32 drawable_ID,
|
||||
gint *offset_x,
|
||||
gint *offset_y)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_offsets",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*offset_x = return_vals[1].data.d_int32;
|
||||
*offset_y = return_vals[2].data.d_int32;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_fill (gint32 drawable_ID,
|
||||
GimpFillType fill_type)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_fill",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_INT32, fill_type,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_set_name (gint32 drawable_ID,
|
||||
gchar *name)
|
||||
{
|
||||
if (gimp_drawable_is_layer (drawable_ID))
|
||||
gimp_layer_set_name (drawable_ID, name);
|
||||
else
|
||||
gimp_channel_set_name (drawable_ID, name);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_set_visible (gint32 drawable_ID,
|
||||
gint visible)
|
||||
{
|
||||
if (gimp_drawable_is_layer (drawable_ID))
|
||||
gimp_layer_set_visible (drawable_ID, visible);
|
||||
else
|
||||
gimp_channel_set_visible (drawable_ID, visible);
|
||||
}
|
||||
|
||||
GTile*
|
||||
gimp_drawable_get_tile (GDrawable *drawable,
|
||||
gint shadow,
|
||||
gint row,
|
||||
gint col)
|
||||
{
|
||||
GTile *tiles;
|
||||
guint right_tile;
|
||||
guint bottom_tile;
|
||||
gint ntiles;
|
||||
gint tile_num;
|
||||
gint i, j, k;
|
||||
|
||||
if (drawable)
|
||||
{
|
||||
if (shadow)
|
||||
tiles = drawable->shadow_tiles;
|
||||
else
|
||||
tiles = drawable->tiles;
|
||||
|
||||
if (!tiles)
|
||||
{
|
||||
ntiles = drawable->ntile_rows * drawable->ntile_cols;
|
||||
tiles = g_new (GTile, ntiles);
|
||||
|
||||
right_tile = drawable->width - ((drawable->ntile_cols - 1) * TILE_WIDTH);
|
||||
bottom_tile = drawable->height - ((drawable->ntile_rows - 1) * TILE_HEIGHT);
|
||||
|
||||
for (i = 0, k = 0; i < drawable->ntile_rows; i++)
|
||||
{
|
||||
for (j = 0; j < drawable->ntile_cols; j++, k++)
|
||||
{
|
||||
tiles[k].bpp = drawable->bpp;
|
||||
tiles[k].tile_num = k;
|
||||
tiles[k].ref_count = 0;
|
||||
tiles[k].dirty = FALSE;
|
||||
tiles[k].shadow = shadow;
|
||||
tiles[k].data = NULL;
|
||||
tiles[k].drawable = drawable;
|
||||
|
||||
if (j == (drawable->ntile_cols - 1))
|
||||
tiles[k].ewidth = right_tile;
|
||||
else
|
||||
tiles[k].ewidth = TILE_WIDTH;
|
||||
|
||||
if (i == (drawable->ntile_rows - 1))
|
||||
tiles[k].eheight = bottom_tile;
|
||||
else
|
||||
tiles[k].eheight = TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
if (shadow)
|
||||
drawable->shadow_tiles = tiles;
|
||||
else
|
||||
drawable->tiles = tiles;
|
||||
}
|
||||
|
||||
tile_num = row * drawable->ntile_cols + col;
|
||||
return &tiles[tile_num];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GTile*
|
||||
gimp_drawable_get_tile2 (GDrawable *drawable,
|
||||
gint shadow,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
gint row, col;
|
||||
|
||||
col = x / TILE_WIDTH;
|
||||
row = y / TILE_HEIGHT;
|
||||
|
||||
return gimp_drawable_get_tile (drawable, shadow, row, col);
|
||||
}
|
||||
|
||||
GimpParasite *
|
||||
gimp_drawable_parasite_find (gint32 drawable_ID,
|
||||
const gchar *name)
|
||||
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
GimpParasite *parasite;
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_parasite_find",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_STRING, name,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
parasite = gimp_parasite_copy (&return_vals[1].data.d_parasite);
|
||||
}
|
||||
else
|
||||
parasite = NULL;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return parasite;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_parasite_attach (gint32 drawable_ID,
|
||||
const GimpParasite *parasite)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_parasite_attach",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_PARASITE, parasite,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_drawable_attach_new_parasite (gint32 drawable,
|
||||
const gchar *name,
|
||||
gint flags,
|
||||
gint size,
|
||||
const gpointer data)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
GimpParasite *p = gimp_parasite_new (name, flags, size, data);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_parasite_attach",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable,
|
||||
PARAM_PARASITE, p,
|
||||
PARAM_END);
|
||||
|
||||
gimp_parasite_free(p);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_parasite_detach (gint32 drawable_ID,
|
||||
const gchar *name)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_parasite_detach",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_STRING, name,
|
||||
PARAM_END);
|
||||
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
guchar *
|
||||
gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
||||
gint *width,
|
||||
gint *height,
|
||||
gint *bytes)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
guchar *drawable_data = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_drawable_thumbnail",
|
||||
&nreturn_vals,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_INT32, *width,
|
||||
PARAM_INT32, *height,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*width = return_vals[1].data.d_int32;
|
||||
*height = return_vals[2].data.d_int32;
|
||||
*bytes = return_vals[3].data.d_int32;
|
||||
drawable_data = g_new (guchar, return_vals[4].data.d_int32);
|
||||
g_memmove (drawable_data, return_vals[5].data.d_int32array, return_vals[4].data.d_int32);
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return drawable_data;
|
||||
}
|
||||
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
char **
|
||||
gimp_gradients_get_list(gint *num_gradients)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
char **gradient_names;
|
||||
int i;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gradients_get_list",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
*num_gradients = 0;
|
||||
gradient_names = NULL;
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*num_gradients = return_vals[1].data.d_int32;
|
||||
gradient_names = g_new (char *, *num_gradients);
|
||||
for (i = 0; i < *num_gradients; i++)
|
||||
gradient_names[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return gradient_names;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
gimp_gradients_get_active(void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
char *result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gradients_get_active",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
result = NULL;
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_gradients_set_active(char *name)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gradients_set_active",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, name,
|
||||
PARAM_END);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
|
||||
gdouble *
|
||||
gimp_gradients_sample_uniform(gint num_samples)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gdouble *result;
|
||||
int nresult;
|
||||
int i;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gradients_sample_uniform",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, num_samples,
|
||||
PARAM_END);
|
||||
|
||||
result = NULL;
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
nresult = return_vals[1].data.d_int32;
|
||||
result = g_new(gdouble, nresult);
|
||||
for (i = 0; i < nresult; i++)
|
||||
result[i] = return_vals[2].data.d_floatarray[i];
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
gdouble *
|
||||
gimp_gradients_sample_custom(gint num_samples, gdouble *positions)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gdouble *result;
|
||||
int nresult;
|
||||
int i;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gradients_sample_custom",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, num_samples,
|
||||
PARAM_FLOATARRAY, positions,
|
||||
PARAM_END);
|
||||
|
||||
result = NULL;
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
nresult = return_vals[1].data.d_int32;
|
||||
result = g_new (gdouble, nresult);
|
||||
for (i = 0; i < nresult; i++)
|
||||
result[i] = return_vals[2].data.d_floatarray[i];
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimphelp.c
|
||||
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
void
|
||||
gimp_standard_help_func (gchar *help_data)
|
||||
{
|
||||
gimp_help (gimp_get_progname (), help_data);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_help (gchar *prog_name,
|
||||
gchar *help_data)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_help",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, prog_name,
|
||||
PARAM_STRING, help_data,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plugin_help_register (gchar *help_path)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_plugin_help_register",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, help_path,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
1277
libgimp/gimpimage.c
1277
libgimp/gimpimage.c
File diff suppressed because it is too large
Load Diff
|
@ -1,594 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
gint32
|
||||
gimp_layer_new (gint32 image_ID,
|
||||
char *name,
|
||||
guint width,
|
||||
guint height,
|
||||
GDrawableType type,
|
||||
gdouble opacity,
|
||||
GLayerMode mode)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gint32 layer_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_new",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_INT32, width,
|
||||
PARAM_INT32, height,
|
||||
PARAM_INT32, type,
|
||||
PARAM_STRING, name,
|
||||
PARAM_FLOAT, opacity,
|
||||
PARAM_INT32, mode,
|
||||
PARAM_END);
|
||||
|
||||
layer_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
layer_ID = return_vals[1].data.d_layer;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return layer_ID;
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_layer_copy (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_copy",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_END);
|
||||
|
||||
layer_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
layer_ID = return_vals[1].data.d_layer;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return layer_ID;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_delete (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_delete",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_layer_width (gint32 layer_ID)
|
||||
{
|
||||
return gimp_drawable_width (layer_ID);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_layer_height (gint32 layer_ID)
|
||||
{
|
||||
return gimp_drawable_height (layer_ID);
|
||||
}
|
||||
|
||||
guint
|
||||
gimp_layer_bpp (gint32 layer_ID)
|
||||
{
|
||||
return gimp_drawable_bpp (layer_ID);
|
||||
}
|
||||
|
||||
GDrawableType
|
||||
gimp_layer_type (gint32 layer_ID)
|
||||
{
|
||||
return gimp_drawable_type (layer_ID);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_add_alpha (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_add_alpha",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_layer_create_mask (gint32 layer_ID,
|
||||
GimpAddMaskType mask_type)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gint32 mask_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_create_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, mask_type,
|
||||
PARAM_END);
|
||||
|
||||
mask_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
mask_ID = return_vals[1].data.d_channel;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return mask_ID;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_resize (gint32 layer_ID,
|
||||
guint new_width,
|
||||
guint new_height,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_resize",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, new_width,
|
||||
PARAM_INT32, new_height,
|
||||
PARAM_INT32, offset_x,
|
||||
PARAM_INT32, offset_y,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_scale (gint32 layer_ID,
|
||||
guint new_width,
|
||||
guint new_height,
|
||||
gint local_origin)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_scale",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, new_width,
|
||||
PARAM_INT32, new_height,
|
||||
PARAM_INT32, local_origin,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_translate (gint32 layer_ID,
|
||||
gint offset_x,
|
||||
gint offset_y)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_translate",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, offset_x,
|
||||
PARAM_INT32, offset_y,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_is_floating_selection (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_is_floating_sel",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = FALSE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_layer_get_image_id (gint32 layer_ID)
|
||||
{
|
||||
return gimp_drawable_image_id (layer_ID);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_layer_get_mask_id (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gint32 mask_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
mask_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
mask_ID = return_vals[1].data.d_channel;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return mask_ID;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_get_apply_mask (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_apply_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_get_edit_mask (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_edit_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GLayerMode
|
||||
gimp_layer_get_mode (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_mode",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char*
|
||||
gimp_layer_get_name (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
char *result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_name",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_layer_get_opacity (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
gdouble result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_opacity",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_get_preserve_transparency (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_preserve_trans",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_get_show_mask (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_show_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_layer_get_visible (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_visible",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_apply_mask (gint32 layer_ID,
|
||||
gint apply_mask)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_apply_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, apply_mask,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_edit_mask (gint32 layer_ID,
|
||||
gint edit_mask)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_edit_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, edit_mask,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_mode (gint32 layer_ID,
|
||||
GLayerMode mode)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_mode",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, mode,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_name (gint32 layer_ID,
|
||||
char *name)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_name",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_STRING, name,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_offsets (gint32 layer_ID,
|
||||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_offsets",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, offset_x,
|
||||
PARAM_INT32, offset_y,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_opacity (gint32 layer_ID,
|
||||
gdouble opacity)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_opacity",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_FLOAT, opacity,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_preserve_transparency (gint32 layer_ID,
|
||||
int preserve_transparency)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_preserve_trans",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, preserve_transparency,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_show_mask (gint32 layer_ID,
|
||||
gint show_mask)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_show_mask",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, show_mask,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_visible (gint32 layer_ID,
|
||||
gint visible)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_set_visible",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_INT32, visible,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_layer_get_tattoo (gint32 layer_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
int tattoo;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_layer_get_tattoo",
|
||||
&nreturn_vals,
|
||||
PARAM_LAYER, layer_ID,
|
||||
PARAM_END);
|
||||
|
||||
tattoo = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
tattoo = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return tattoo;
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_palette_get_background (guchar *red,
|
||||
guchar *green,
|
||||
guchar *blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_background",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*red = return_vals[1].data.d_color.red;
|
||||
*green = return_vals[1].data.d_color.green;
|
||||
*blue = return_vals[1].data.d_color.blue;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_get_foreground (guchar *red,
|
||||
guchar *green,
|
||||
guchar *blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_foreground",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
*red = return_vals[1].data.d_color.red;
|
||||
*green = return_vals[1].data.d_color.green;
|
||||
*blue = return_vals[1].data.d_color.blue;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_set_background (guchar red,
|
||||
guchar green,
|
||||
guchar blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
guchar color[3];
|
||||
|
||||
color[0] = red;
|
||||
color[1] = green;
|
||||
color[2] = blue;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_set_background",
|
||||
&nreturn_vals,
|
||||
PARAM_COLOR, color,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_set_foreground (guchar red,
|
||||
guchar green,
|
||||
guchar blue)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
guchar color[3];
|
||||
|
||||
color[0] = red;
|
||||
color[1] = green;
|
||||
color[2] = blue;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_set_foreground",
|
||||
&nreturn_vals,
|
||||
PARAM_COLOR, color,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_set_default_colors (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_set_default_colors",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_swap_colors (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_swap_colors",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libgimp/parasiteF.h"
|
||||
#include "libgimp/gimpparasiteF.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
gint32
|
||||
gimp_selection_bounds (gint32 image_ID,
|
||||
gint *non_empty,
|
||||
gint *x1,
|
||||
gint *y1,
|
||||
gint *x2,
|
||||
gint *y2)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_selection_bounds",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
result = FALSE;
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
result = TRUE;
|
||||
*non_empty = return_vals[1].data.d_int32;
|
||||
*x1 = return_vals[2].data.d_int32;
|
||||
*y1 = return_vals[3].data.d_int32;
|
||||
*x2 = return_vals[4].data.d_int32;
|
||||
*y2 = return_vals[5].data.d_int32;
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_selection_float (gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 x_offset,
|
||||
gint32 y_offset)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 layer_ID;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_selection_float",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_DRAWABLE, drawable_ID,
|
||||
PARAM_INT32, x_offset,
|
||||
PARAM_INT32, y_offset,
|
||||
PARAM_END);
|
||||
|
||||
layer_ID = -1;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
layer_ID = return_vals[1].data.d_layer;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return layer_ID;
|
||||
}
|
||||
|
||||
gint32
|
||||
gimp_selection_is_empty (gint32 image_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 is_empty;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
is_empty = TRUE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
is_empty = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return is_empty;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_selection_none (gint32 image_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_selection_none",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -1,525 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunit.c
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpunit.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
/* internal structures */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gboolean delete_on_exit;
|
||||
gdouble factor;
|
||||
gint digits;
|
||||
gchar *identifier;
|
||||
gchar *symbol;
|
||||
gchar *abbreviation;
|
||||
gchar *singular;
|
||||
gchar *plural;
|
||||
} GimpUnitDef;
|
||||
|
||||
static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
|
||||
{
|
||||
/* pseudo unit */
|
||||
{ FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") },
|
||||
|
||||
/* standard units */
|
||||
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
|
||||
{ FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
|
||||
|
||||
/* professional units */
|
||||
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
|
||||
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
|
||||
};
|
||||
|
||||
/* not a unit at all but kept here to have the strings in one place
|
||||
*/
|
||||
static GimpUnitDef gimp_unit_percent =
|
||||
{
|
||||
FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_units:
|
||||
*
|
||||
* Returns the number of units which are known to the #GimpUnit system.
|
||||
*
|
||||
* Returns: The number of defined units.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_units (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gint number;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
number = GIMP_UNIT_END;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
number = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_built_in_units:
|
||||
*
|
||||
* Returns the number of #GimpUnit's which are hardcoded in the unit system
|
||||
* (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units"
|
||||
* UNIT_PIXEL and UNIT_PERCENT).
|
||||
*
|
||||
* Returns: The number of built-in units.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_new:
|
||||
* @identifier: The unit's identifier string.
|
||||
* @factor: The unit's factor (how many units are in one inch).
|
||||
* @digits: The unit's suggested number of digits (see gimp_unit_get_digits()).
|
||||
* @symbol: The symbol of the unit (e.g. "''" for inch).
|
||||
* @abbreviation: The abbreviation of the unit.
|
||||
* @singular: The singular form of the unit.
|
||||
* @plural: The plural form of the unit.
|
||||
*
|
||||
* Returns the integer ID of the new #GimpUnit.
|
||||
*
|
||||
* Note that a new unit is always created with it's deletion flag
|
||||
* set to #TRUE. You will have to set it to #FALSE with
|
||||
* gimp_unit_set_deletion_flag() to make the unit definition persistent.
|
||||
*
|
||||
* Returns: The ID of the new unit.
|
||||
*
|
||||
*/
|
||||
GimpUnit
|
||||
gimp_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
GimpUnit unit;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_new",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, g_strdup (identifier),
|
||||
PARAM_FLOAT, factor,
|
||||
PARAM_INT32, digits,
|
||||
PARAM_STRING, g_strdup (symbol),
|
||||
PARAM_STRING, g_strdup (abbreviation),
|
||||
PARAM_STRING, g_strdup (singular),
|
||||
PARAM_STRING, g_strdup (plural),
|
||||
PARAM_END);
|
||||
|
||||
unit = GIMP_UNIT_INCH;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
unit = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_deletion_flag:
|
||||
* @unit: The unit you want to know the @deletion_flag of.
|
||||
*
|
||||
* Returns: The unit's @deletion_flag.
|
||||
*
|
||||
*/
|
||||
gboolean
|
||||
gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gboolean flag;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return FALSE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
flag = TRUE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
flag = return_vals[1].data.d_int32 ? TRUE : FALSE;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_set_deletion_flag:
|
||||
* @unit: The unit you want to set the @deletion_flag for.
|
||||
* @deletion_flag: The new deletion_flag.
|
||||
*
|
||||
* Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is
|
||||
* #TRUE when GIMP exits, this unit will not be saved in the uses's
|
||||
* "unitrc" file.
|
||||
*
|
||||
* Trying to change the @deletion_flag of a built-in unit will be silently
|
||||
* ignored.
|
||||
*
|
||||
*/
|
||||
void
|
||||
gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
g_return_if_fail (unit >= GIMP_UNIT_PIXEL);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_INT32, deletion_flag,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_factor:
|
||||
* @unit: The unit you want to know the factor of.
|
||||
*
|
||||
* A #GimpUnit's @factor is defined to be:
|
||||
*
|
||||
* distance_in_units == (@factor * distance_in_inches)
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The unit's factor.
|
||||
*
|
||||
*/
|
||||
gdouble
|
||||
gimp_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gdouble factor;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].factor;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_factor",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
factor = 1.0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
factor = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_digits:
|
||||
* @unit: The unit you want to know the digits.
|
||||
*
|
||||
* Returns the number of digits an entry field should provide to get
|
||||
* approximately the same accuracy as an inch input field with two digits.
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The suggested number of digits.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gint digits;
|
||||
|
||||
if (unit < 0)
|
||||
return 0;
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].digits;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_digits",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
digits = gimp_unit_defs[GIMP_UNIT_INCH].digits;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
digits = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return digits;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_identifier:
|
||||
* @unit: The unit you want to know the identifier of.
|
||||
*
|
||||
* This is an unstranslated string.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's identifier.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *identifier;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].identifier);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.identifier);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_identifier",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
identifier = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
identifier = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return identifier ? identifier : g_strdup ("");
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_symbol:
|
||||
* @unit: The unit you want to know the symbol of.
|
||||
*
|
||||
* This is e.g. "''" for UNIT_INCH.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's symbol.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *symbol;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].symbol);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.symbol);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_symbol",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
symbol = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
symbol = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return symbol ? symbol : g_strdup ("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_abbreviation:
|
||||
* @unit: The unit you want to know the abbreviation of.
|
||||
*
|
||||
* For built-in units, this function returns the translated abbreviation
|
||||
* of the unit.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's abbreviation.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *abbreviation;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].abbreviation);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.abbreviation);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
abbreviation = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
abbreviation = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return abbreviation ? abbreviation : g_strdup ("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_singular:
|
||||
* @unit: The unit you want to know the singular form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated singular form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's singular form.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *singular;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gettext (gimp_unit_defs[unit].singular));
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gettext (gimp_unit_percent.singular));
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_singular",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
singular = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
singular = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return singular ? singular : g_strdup ("");
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_plural:
|
||||
* @unit: The unit you want to know the plural form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated plural form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's plural form.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *plural;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gettext (gimp_unit_defs[unit].plural));
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gettext (gimp_unit_percent.plural));
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_plural",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
plural = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
plural = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return plural ? plural : g_strdup ("");
|
||||
}
|
|
@ -1,525 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunit.c
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpunit.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
/* internal structures */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gboolean delete_on_exit;
|
||||
gdouble factor;
|
||||
gint digits;
|
||||
gchar *identifier;
|
||||
gchar *symbol;
|
||||
gchar *abbreviation;
|
||||
gchar *singular;
|
||||
gchar *plural;
|
||||
} GimpUnitDef;
|
||||
|
||||
static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
|
||||
{
|
||||
/* pseudo unit */
|
||||
{ FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") },
|
||||
|
||||
/* standard units */
|
||||
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
|
||||
{ FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
|
||||
|
||||
/* professional units */
|
||||
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
|
||||
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
|
||||
};
|
||||
|
||||
/* not a unit at all but kept here to have the strings in one place
|
||||
*/
|
||||
static GimpUnitDef gimp_unit_percent =
|
||||
{
|
||||
FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_units:
|
||||
*
|
||||
* Returns the number of units which are known to the #GimpUnit system.
|
||||
*
|
||||
* Returns: The number of defined units.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_units (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gint number;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_number_of_units",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
number = GIMP_UNIT_END;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
number = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_built_in_units:
|
||||
*
|
||||
* Returns the number of #GimpUnit's which are hardcoded in the unit system
|
||||
* (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo units"
|
||||
* UNIT_PIXEL and UNIT_PERCENT).
|
||||
*
|
||||
* Returns: The number of built-in units.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_new:
|
||||
* @identifier: The unit's identifier string.
|
||||
* @factor: The unit's factor (how many units are in one inch).
|
||||
* @digits: The unit's suggested number of digits (see gimp_unit_get_digits()).
|
||||
* @symbol: The symbol of the unit (e.g. "''" for inch).
|
||||
* @abbreviation: The abbreviation of the unit.
|
||||
* @singular: The singular form of the unit.
|
||||
* @plural: The plural form of the unit.
|
||||
*
|
||||
* Returns the integer ID of the new #GimpUnit.
|
||||
*
|
||||
* Note that a new unit is always created with it's deletion flag
|
||||
* set to #TRUE. You will have to set it to #FALSE with
|
||||
* gimp_unit_set_deletion_flag() to make the unit definition persistent.
|
||||
*
|
||||
* Returns: The ID of the new unit.
|
||||
*
|
||||
*/
|
||||
GimpUnit
|
||||
gimp_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
GimpUnit unit;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_new",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, g_strdup (identifier),
|
||||
PARAM_FLOAT, factor,
|
||||
PARAM_INT32, digits,
|
||||
PARAM_STRING, g_strdup (symbol),
|
||||
PARAM_STRING, g_strdup (abbreviation),
|
||||
PARAM_STRING, g_strdup (singular),
|
||||
PARAM_STRING, g_strdup (plural),
|
||||
PARAM_END);
|
||||
|
||||
unit = GIMP_UNIT_INCH;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
unit = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_deletion_flag:
|
||||
* @unit: The unit you want to know the @deletion_flag of.
|
||||
*
|
||||
* Returns: The unit's @deletion_flag.
|
||||
*
|
||||
*/
|
||||
gboolean
|
||||
gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gboolean flag;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return FALSE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_deletion_flag",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
flag = TRUE;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
flag = return_vals[1].data.d_int32 ? TRUE : FALSE;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_set_deletion_flag:
|
||||
* @unit: The unit you want to set the @deletion_flag for.
|
||||
* @deletion_flag: The new deletion_flag.
|
||||
*
|
||||
* Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is
|
||||
* #TRUE when GIMP exits, this unit will not be saved in the uses's
|
||||
* "unitrc" file.
|
||||
*
|
||||
* Trying to change the @deletion_flag of a built-in unit will be silently
|
||||
* ignored.
|
||||
*
|
||||
*/
|
||||
void
|
||||
gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
g_return_if_fail (unit >= GIMP_UNIT_PIXEL);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_set_deletion_flag",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_INT32, deletion_flag,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_factor:
|
||||
* @unit: The unit you want to know the factor of.
|
||||
*
|
||||
* A #GimpUnit's @factor is defined to be:
|
||||
*
|
||||
* distance_in_units == (@factor * distance_in_inches)
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The unit's factor.
|
||||
*
|
||||
*/
|
||||
gdouble
|
||||
gimp_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gdouble factor;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].factor;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_factor",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
factor = 1.0;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
factor = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_digits:
|
||||
* @unit: The unit you want to know the digits.
|
||||
*
|
||||
* Returns the number of digits an entry field should provide to get
|
||||
* approximately the same accuracy as an inch input field with two digits.
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The suggested number of digits.
|
||||
*
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gint digits;
|
||||
|
||||
if (unit < 0)
|
||||
return 0;
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].digits;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_digits",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
digits = gimp_unit_defs[GIMP_UNIT_INCH].digits;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
digits = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return digits;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_identifier:
|
||||
* @unit: The unit you want to know the identifier of.
|
||||
*
|
||||
* This is an unstranslated string.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's identifier.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *identifier;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].identifier);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.identifier);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_identifier",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
identifier = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
identifier = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return identifier ? identifier : g_strdup ("");
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_symbol:
|
||||
* @unit: The unit you want to know the symbol of.
|
||||
*
|
||||
* This is e.g. "''" for UNIT_INCH.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's symbol.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *symbol;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].symbol);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.symbol);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_symbol",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
symbol = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
symbol = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return symbol ? symbol : g_strdup ("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_abbreviation:
|
||||
* @unit: The unit you want to know the abbreviation of.
|
||||
*
|
||||
* For built-in units, this function returns the translated abbreviation
|
||||
* of the unit.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's abbreviation.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *abbreviation;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gimp_unit_defs[unit].abbreviation);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gimp_unit_percent.abbreviation);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_abbreviation",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
abbreviation = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
abbreviation = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return abbreviation ? abbreviation : g_strdup ("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_get_singular:
|
||||
* @unit: The unit you want to know the singular form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated singular form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's singular form.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *singular;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gettext (gimp_unit_defs[unit].singular));
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gettext (gimp_unit_percent.singular));
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_singular",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
singular = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
singular = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return singular ? singular : g_strdup ("");
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_plural:
|
||||
* @unit: The unit you want to know the plural form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated plural form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string has to be g_free()'d by plugins but is a pointer to a
|
||||
* constant string when this function is used from inside the GIMP.
|
||||
*
|
||||
* Returns: The unit's plural form.
|
||||
*
|
||||
*/
|
||||
gchar *
|
||||
gimp_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
gchar *plural;
|
||||
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, g_strdup (""));
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_strdup (gettext (gimp_unit_defs[unit].plural));
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_strdup (gettext (gimp_unit_percent.plural));
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_unit_get_plural",
|
||||
&nreturn_vals,
|
||||
PARAM_INT32, unit,
|
||||
PARAM_END);
|
||||
|
||||
plural = NULL;
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
plural = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return plural ? plural : g_strdup ("");
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasite.c
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "parasiteP.h"
|
||||
#include "parasite.h"
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <process.h> /* For _getpid() */
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
gimp_parasite_print (GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
{
|
||||
g_print ("pid %d: attempt to print a null parasite\n", getpid ());
|
||||
return;
|
||||
}
|
||||
|
||||
g_print ("pid %d: parasite: %p\n", getpid (), parasite);
|
||||
|
||||
if (parasite->name)
|
||||
g_print ("\tname: %s\n", parasite->name);
|
||||
else
|
||||
g_print ("\tname: NULL\n");
|
||||
|
||||
g_print ("\tflags: %d\n", parasite->flags);
|
||||
g_print ("\tsize: %d\n", parasite->size);
|
||||
if (parasite->size > 0)
|
||||
g_print ("\tdata: %p\n", parasite->data);
|
||||
}
|
||||
#endif
|
||||
|
||||
GimpParasite *
|
||||
gimp_parasite_new (const gchar *name,
|
||||
guint32 flags,
|
||||
guint32 size,
|
||||
const gpointer data)
|
||||
{
|
||||
GimpParasite *parasite;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
parasite = g_new (GimpParasite, 1);
|
||||
parasite->name = g_strdup (name);
|
||||
parasite->flags = (flags & 0xFF);
|
||||
parasite->size = size;
|
||||
if (size)
|
||||
parasite->data = g_memdup (data, size);
|
||||
else
|
||||
parasite->data = NULL;
|
||||
|
||||
return parasite;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_parasite_free (GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return;
|
||||
|
||||
if (parasite->name)
|
||||
g_free (parasite->name);
|
||||
if (parasite->data)
|
||||
g_free (parasite->data);
|
||||
|
||||
g_free (parasite);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_parasite_is_type (const GimpParasite *parasite,
|
||||
const gchar *name)
|
||||
{
|
||||
if (!parasite || !parasite->name)
|
||||
return FALSE;
|
||||
|
||||
return (strcmp (parasite->name, name) == 0);
|
||||
}
|
||||
|
||||
GimpParasite *
|
||||
gimp_parasite_copy (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return NULL;
|
||||
|
||||
return gimp_parasite_new (parasite->name, parasite->flags,
|
||||
parasite->size, parasite->data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_parasite_compare (const GimpParasite *a,
|
||||
const GimpParasite *b)
|
||||
{
|
||||
if (a && b &&
|
||||
a->name && b->name &&
|
||||
strcmp (a->name, b->name) == 0 &&
|
||||
a->flags == b->flags &&
|
||||
a->size == b->size)
|
||||
{
|
||||
if (a->data == NULL && b->data == NULL)
|
||||
return TRUE;
|
||||
else if (a->data && b->data && memcmp (a->data, b->data, a->size) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gulong
|
||||
gimp_parasite_flags (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return 0;
|
||||
|
||||
return parasite->flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_parasite_is_persistent (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (parasite->flags & GIMP_PARASITE_PERSISTENT);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_parasite_is_undoable (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (parasite->flags & GIMP_PARASITE_UNDOABLE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_parasite_has_flag (const GimpParasite *parasite,
|
||||
gulong flag)
|
||||
{
|
||||
if (parasite == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (parasite->flags & flag);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_parasite_name (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite)
|
||||
return parasite->name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
gimp_parasite_data (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite)
|
||||
return parasite->data;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glong
|
||||
gimp_parasite_data_size (const GimpParasite *parasite)
|
||||
{
|
||||
if (parasite)
|
||||
return parasite->size;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasite.h
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PARASITE_H__
|
||||
#define __GIMP_PARASITE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libgimp/parasiteF.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define GIMP_PARASITE_PERSISTENT 1
|
||||
#define GIMP_PARASITE_UNDOABLE 2
|
||||
|
||||
#define GIMP_PARASITE_ATTACH_PARENT (0x80 << 8)
|
||||
#define GIMP_PARASITE_PARENT_PERSISTENT (GIMP_PARASITE_PERSISTENT << 8)
|
||||
#define GIMP_PARASITE_PARENT_UNDOABLE (GIMP_PARASITE_UNDOABLE << 8)
|
||||
|
||||
#define GIMP_PARASITE_ATTACH_GRANDPARENT (0x80 << 16)
|
||||
#define GIMP_PARASITE_GRANDPARENT_PERSISTENT (GIMP_PARASITE_PERSISTENT << 16)
|
||||
#define GIMP_PARASITE_GRANDPARENT_UNDOABLE (GIMP_PARASITE_UNDOABLE << 16)
|
||||
|
||||
GimpParasite * gimp_parasite_new (const gchar *name,
|
||||
guint32 flags,
|
||||
guint32 size,
|
||||
const gpointer data);
|
||||
void gimp_parasite_free (GimpParasite *parasite);
|
||||
|
||||
GimpParasite * gimp_parasite_copy (const GimpParasite *parasite);
|
||||
|
||||
gboolean gimp_parasite_compare (const GimpParasite *a,
|
||||
const GimpParasite *b);
|
||||
|
||||
gboolean gimp_parasite_is_type (const GimpParasite *parasite,
|
||||
const gchar *name);
|
||||
gboolean gimp_parasite_is_persistent (const GimpParasite *parasite);
|
||||
gboolean gimp_parasite_is_undoable (const GimpParasite *parasite);
|
||||
gboolean gimp_parasite_has_flag (const GimpParasite *parasite,
|
||||
gulong flag);
|
||||
gulong gimp_parasite_flags (const GimpParasite *parasite);
|
||||
const gchar * gimp_parasite_name (const GimpParasite *parasite);
|
||||
void * gimp_parasite_data (const GimpParasite *parasite);
|
||||
glong gimp_parasite_data_size (const GimpParasite *parasite);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_PARASITE_H__ */
|
|
@ -1,27 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasiteF.h
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GIMP_PARASITE_F_H__
|
||||
#define __GIMP_PARASITE_F_H__
|
||||
|
||||
typedef struct _GimpParasite GimpParasite;
|
||||
|
||||
#endif /* __GIMP_PARASITE_F_H__ */
|
|
@ -1,44 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasiteP.h
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GIMP_PARASITE_P_H__
|
||||
#define __GIMP_PARASITE_P_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct _GimpParasite
|
||||
{
|
||||
gchar *name; /* The name of the parasite. USE A UNIQUE PREFIX! */
|
||||
guint32 flags; /* save Parasite in XCF file, etc. */
|
||||
guint32 size; /* amount of data */
|
||||
gpointer data; /* a pointer to the data. plugin is *
|
||||
* responsible for tracking byte order */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_PARASITE_P_H__ */
|
|
@ -1,172 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasiteio.c
|
||||
* Copyright (C) 1999 Tor Lillqvist <tml@iki.fi>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Functions for bulding and parsing string representations of
|
||||
* various standard parasite types.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "parasiteio.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_pixpipe_params_init (GimpPixPipeParams *params)
|
||||
{
|
||||
gint i;
|
||||
|
||||
params->step = 100;
|
||||
params->ncells = 1;
|
||||
params->cellwidth = 1;
|
||||
params->cellheight = 1;
|
||||
params->dim = 1;
|
||||
params->cols = 1;
|
||||
params->rows = 1;
|
||||
params->placement = "constant";
|
||||
params->free_placement_string = FALSE;
|
||||
for (i = 0; i < GIMP_PIXPIPE_MAXDIM; i++)
|
||||
{
|
||||
params->selection[i] = "random";
|
||||
params->free_selection_string = FALSE;
|
||||
}
|
||||
params->rank[0] = 1;
|
||||
for (i = 1; i < GIMP_PIXPIPE_MAXDIM; i++)
|
||||
params->rank[i] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixpipe_params_parse (gchar *string,
|
||||
GimpPixPipeParams *params)
|
||||
{
|
||||
gchar *p, *q, *r; /* Don't you love single-char identifiers? */
|
||||
gint i; /* No, we don't!! <Sven> */
|
||||
|
||||
q = string;
|
||||
while ((p = strtok (q, " \r\n")) != NULL)
|
||||
{
|
||||
q = NULL;
|
||||
r = strchr (p, ':');
|
||||
if (r)
|
||||
*r = 0;
|
||||
|
||||
if (strcmp (p, "ncells") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->ncells = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "step") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->step = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "dim") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->dim = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "cols") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->cols = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "rows") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->rows = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "cellwidth") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->cellwidth = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "cellheight") == 0)
|
||||
{
|
||||
if (r)
|
||||
params->cellheight = atoi (r + 1);
|
||||
}
|
||||
else if (strcmp (p, "placement") == 0)
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
params->placement = g_strdup (r + 1);
|
||||
params->free_placement_string = TRUE;
|
||||
}
|
||||
}
|
||||
else if (strncmp (p, "rank", strlen ("rank")) == 0 && r)
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
i = atoi (p + strlen ("rank"));
|
||||
if (i >= 0 && i < params->dim)
|
||||
params->rank[i] = atoi (r + 1);
|
||||
}
|
||||
}
|
||||
else if (strncmp (p, "sel", strlen ("sel")) == 0 && r)
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
i = atoi (p + strlen ("sel"));
|
||||
if (i >= 0 && i < params->dim)
|
||||
{
|
||||
params->selection[i] = g_strdup (r + 1);
|
||||
params->free_selection_string = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r)
|
||||
*r = ':';
|
||||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_pixpipe_params_build (GimpPixPipeParams *params)
|
||||
{
|
||||
GString *s = g_string_new (NULL);
|
||||
gchar *str;
|
||||
|
||||
gint i;
|
||||
|
||||
g_string_sprintf (s, "ncells:%d cellwidth:%d cellheight:%d "
|
||||
"step:%d dim:%d cols:%d rows:%d placement:%s",
|
||||
params->ncells, params->cellwidth, params->cellheight,
|
||||
params->step, params->dim,
|
||||
params->cols, params->rows,
|
||||
params->placement);
|
||||
|
||||
for (i = 0; i < params->dim; i++)
|
||||
{
|
||||
g_string_sprintfa (s, " rank%d:%d", i, params->rank[i]);
|
||||
g_string_sprintfa (s, " sel%d:%s", i, params->selection[i]);
|
||||
}
|
||||
|
||||
str = s->str;
|
||||
g_string_free (s, FALSE);
|
||||
|
||||
return str;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpparasiteio.h
|
||||
* Copyright (C) 1999 Tor Lillqvist <tml@iki.fi>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GIMP_PARASITE_IO_H__
|
||||
#define __GIMP_PARASITE_IO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Data structures for various standard parasites used by plug-ins and
|
||||
* the GIMP core, and functions to build and parse their string
|
||||
* representations.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pixmap brush pipes.
|
||||
*/
|
||||
|
||||
#define GIMP_PIXPIPE_MAXDIM 4
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint step;
|
||||
gint ncells;
|
||||
gint dim;
|
||||
gint cols;
|
||||
gint rows;
|
||||
gint cellwidth;
|
||||
gint cellheight;
|
||||
gchar *placement;
|
||||
gboolean free_placement_string;
|
||||
gint rank[GIMP_PIXPIPE_MAXDIM];
|
||||
gchar *selection[GIMP_PIXPIPE_MAXDIM];
|
||||
gboolean free_selection_string;
|
||||
} GimpPixPipeParams;
|
||||
|
||||
/* Initalize with dummy values */
|
||||
void gimp_pixpipe_params_init (GimpPixPipeParams *params);
|
||||
|
||||
/* Parse a string into a GimpPixPipeParams */
|
||||
void gimp_pixpipe_params_parse (gchar *parameters,
|
||||
GimpPixPipeParams *params);
|
||||
|
||||
/* Build a string representation of GimpPixPipeParams */
|
||||
gchar * gimp_pixpipe_params_build (GimpPixPipeParams *params);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_PARASITE_IO_H__ */
|
|
@ -26,7 +26,7 @@
|
|||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libgimp/parasiteF.h"
|
||||
#include "libgimp/gimpparasiteF.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in New Issue