gimp.h 8.49 KB
Newer Older
1 2
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
Manish Singh's avatar
Manish Singh committed
3
 *
4 5
 * gimp.h
 *
Manish Singh's avatar
Manish Singh committed
6
 * This library is free software; you can redistribute it and/or
Marc Lehmann's avatar
Marc Lehmann committed
7
 * modify it under the terms of the GNU Lesser General Public
Manish Singh's avatar
Manish Singh committed
8
 * License as published by the Free Software Foundation; either
9 10 11 12 13
 * 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
14
 * Lesser General Public License for more details.
Manish Singh's avatar
Manish Singh committed
15
 *
Marc Lehmann's avatar
Marc Lehmann committed
16
 * You should have received a copy of the GNU Lesser General Public
17 18 19
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
20 21
 */

Elliot Lee's avatar
Elliot Lee committed
22 23 24 25
#ifndef __GIMP_H__
#define __GIMP_H__

#include <glib.h>
26

27
#include <libgimp/gimpenums.h>
28 29
#include <libgimp/gimptypes.h>

30
#include <libgimp/gimpcolorspace.h>
31
#include <libgimp/gimpdrawable.h>
32 33 34 35 36
#include <libgimp/gimpfeatures.h>
#include <libgimp/gimpenv.h>
#include <libgimp/gimplimits.h>
#include <libgimp/gimpmath.h>
#include <libgimp/gimpparasite.h>
37 38
#include <libgimp/gimppixelrgn.h>
#include <libgimp/gimptile.h>
39 40 41 42
#include <libgimp/gimpunit.h>
#include <libgimp/gimputils.h>
#include <libgimp/gimpvector.h>

43
#include <libgimp/gimp_pdb.h>
44

45
#include <libgimp/gimpcompat.h>  /* to be removed in 1.3 */
Elliot Lee's avatar
Elliot Lee committed
46

47
#ifdef G_OS_WIN32
48
#  include <stdlib.h>		/* For _-argc and __argv */
49 50 51 52 53
#  ifdef LIBGIMP_COMPILATION
#    define GIMPVAR __declspec(dllexport)
#  else  /* !LIBGIMP_COMPILATION */
#    define GIMPVAR extern __declspec(dllimport)
#  endif /* !LIBGIMP_COMPILATION */
54
#else  /* !G_OS_WIN32 */
55 56
#  define GIMPVAR extern
#endif
Elliot Lee's avatar
Elliot Lee committed
57 58 59 60 61

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

62

63
/* more convenient names for some pdb functions */  
64 65 66 67 68 69 70 71 72 73

#define gimp_get_data                 gimp_procedural_db_get_data
#define gimp_get_data_size            gimp_procedural_db_get_data_size
#define gimp_set_data                 gimp_procedural_db_set_data
#define gimp_query_procedure          gimp_procedural_db_proc_info

#define gimp_image_convert_rgb        gimp_convert_rgb
#define gimp_image_convert_grayscale  gimp_convert_grayscale
#define gimp_image_convert_indexed    gimp_convert_indexed

Elliot Lee's avatar
Elliot Lee committed
74

75 76 77
GIMPVAR guint gimp_major_version;
GIMPVAR guint gimp_minor_version;
GIMPVAR guint gimp_micro_version;
78

79
GIMPVAR GIOChannel *_readchannel;
Manish Singh's avatar
Manish Singh committed
80

81 82 83 84 85 86 87 88 89 90 91
typedef void (* GimpInitProc)  (void);
typedef void (* GimpQuitProc)  (void);
typedef void (* GimpQueryProc) (void);
typedef void (* GimpRunProc)   (gchar      *name,
				gint        nparams,
				GimpParam  *param,
				gint       *nreturn_vals,
				GimpParam **return_vals);


struct _GimpPlugInInfo
Elliot Lee's avatar
Elliot Lee committed
92 93
{
  /* called when the gimp application initially starts up */
94
  GimpInitProc  init_proc;
Elliot Lee's avatar
Elliot Lee committed
95 96

  /* called when the gimp application exits */
97
  GimpQuitProc  quit_proc;
Elliot Lee's avatar
Elliot Lee committed
98 99 100 101 102

  /* called by the gimp so that the plug-in can inform the
   *  gimp of what it does. (ie. installing a procedure database
   *  procedure).
   */
103
  GimpQueryProc query_proc;
Elliot Lee's avatar
Elliot Lee committed
104 105 106 107

  /* called to run a procedure the plug-in installed in the
   *  procedure database.
   */
108
  GimpRunProc   run_proc;
Elliot Lee's avatar
Elliot Lee committed
109 110
};

111
struct _GimpParamDef
Elliot Lee's avatar
Elliot Lee committed
112
{
113 114 115
  GimpPDBArgType  type;
  gchar          *name;
  gchar          *description;
Elliot Lee's avatar
Elliot Lee committed
116 117
};

118
struct _GimpParamColor
119 120 121 122 123 124
{
  guint8 red;
  guint8 green;
  guint8 blue;
};

125
struct _GimpParamRegion
126 127 128 129 130 131 132
{
  gint32 x;
  gint32 y;
  gint32 width;
  gint32 height;
};

133
union _GimpParamData
134
{
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
  gint32            d_int32;
  gint16            d_int16;
  gint8             d_int8;
  gdouble           d_float;
  gchar            *d_string;
  gint32           *d_int32array;
  gint16           *d_int16array;
  gint8            *d_int8array;
  gdouble          *d_floatarray;
  gchar           **d_stringarray;
  GimpParamColor    d_color;
  GimpParamRegion   d_region;
  gint32            d_display;
  gint32            d_image;
  gint32            d_layer;
150
  gint32            d_layer_mask;
151 152 153 154 155 156
  gint32            d_channel;
  gint32            d_drawable;
  gint32            d_selection;
  gint32            d_boundary;
  gint32            d_path;
  GimpParasite      d_parasite;
157
  gint32            d_tattoo;
158
  gint32            d_status;
159 160
};

161
struct _GimpParam
Elliot Lee's avatar
Elliot Lee committed
162
{
163 164
  GimpPDBArgType type;
  GimpParamData  data;
Elliot Lee's avatar
Elliot Lee committed
165 166 167
};


168
#ifdef G_OS_WIN32
Tor Lillqvist's avatar
Tor Lillqvist committed
169
/* Define WinMain() because plug-ins are built as GUI applications. Also
170 171 172
 * define a main() in case some plug-in still is built as a console
 * application.
 */
173
#  ifdef __GNUC__
174 175 176
#    ifndef _stdcall
#      define _stdcall __attribute__((stdcall))
#    endif
177 178
#  endif

179
#  define MAIN()			\
Tor Lillqvist's avatar
Tor Lillqvist committed
180
   static int				\
181
   win32_gimp_main (int argc, char **argv)	\
Tor Lillqvist's avatar
Tor Lillqvist committed
182
   {					\
183
     extern void set_gimp_PLUG_IN_INFO_PTR(GimpPlugInInfo *);	\
Tor Lillqvist's avatar
Tor Lillqvist committed
184 185 186 187
     set_gimp_PLUG_IN_INFO_PTR(&PLUG_IN_INFO);	\
     return gimp_main (argc, argv);	\
   }					\
					\
188
   struct HINSTANCE__;			\
189
   int _stdcall				\
190 191
   WinMain (struct HINSTANCE__ *hInstance, \
	    struct HINSTANCE__ *hPrevInstance,	\
192
	    char *lpszCmdLine,		\
193
	    int   nCmdShow)		\
194
   {					\
Tor Lillqvist's avatar
Tor Lillqvist committed
195
     return win32_gimp_main (__argc, __argv);	\
196 197 198 199 200
   }					\
					\
   int					\
   main (int argc, char *argv[])	\
   {					\
Tor Lillqvist's avatar
Tor Lillqvist committed
201
     return win32_gimp_main (argc, argv);	\
202 203
   }
#else
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
204
#ifndef __EMX__
205 206 207 208 209 210
#  define MAIN()			\
   int					\
   main (int argc, char *argv[])	\
   {					\
     return gimp_main (argc, argv);	\
   }
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
211 212 213 214 215 216 217 218 219
#else
#  define MAIN()				\
   int						\
   main (int argc, char *argv[])		\
   {						\
     set_gimp_PLUG_IN_INFO(&PLUG_IN_INFO);	\
     return gimp_main (argc, argv);		\
   }
#endif
220
#endif
Elliot Lee's avatar
Elliot Lee committed
221 222 223 224 225


/* The main procedure that should be called with the
 *  'argc' and 'argv' that are passed to "main".
 */
226 227
gint        gimp_main                (gint      argc,
				      gchar    *argv[]);
Elliot Lee's avatar
Elliot Lee committed
228 229 230 231

/* Forcefully causes the gimp library to exit and
 *  close down its connection to main gimp application.
 */
232
void G_GNUC_NORETURN gimp_quit       (void);
Elliot Lee's avatar
Elliot Lee committed
233

Marc Lehmann's avatar
Marc Lehmann committed
234 235
/* Returns the default gdisplay (given at plug-in config time).
 */
236
gint32      gimp_default_display     (void);
Marc Lehmann's avatar
Marc Lehmann committed
237

Elliot Lee's avatar
Elliot Lee committed
238 239 240

/* Install a procedure in the procedure database.
 */
241 242 243 244 245 246 247 248 249 250 251 252 253
void        gimp_install_procedure   (gchar        *name,
				      gchar        *blurb,
				      gchar        *help,
				      gchar        *author,
				      gchar        *copyright,
				      gchar        *date,
				      gchar        *menu_path,
				      gchar        *image_types,
				      gint          type,
				      gint          nparams,
				      gint          nreturn_vals,
				      GimpParamDef *params,
				      GimpParamDef *return_vals);
Elliot Lee's avatar
Elliot Lee committed
254 255 256

/* Install a temporary procedure in the procedure database.
 */
257 258 259 260 261 262 263 264 265 266 267 268 269 270
void        gimp_install_temp_proc   (gchar        *name,
				      gchar        *blurb,
				      gchar        *help,
				      gchar        *author,
				      gchar        *copyright,
				      gchar        *date,
				      gchar        *menu_path,
				      gchar        *image_types,
				      gint          type,
				      gint          nparams,
				      gint          nreturn_vals,
				      GimpParamDef *params,
				      GimpParamDef *return_vals,
				      GimpRunProc   run_proc);
Elliot Lee's avatar
Elliot Lee committed
271 272 273

/* Uninstall a temporary procedure
 */
274
void        gimp_uninstall_temp_proc (gchar        *name);
Elliot Lee's avatar
Elliot Lee committed
275 276 277

/* Run a procedure in the procedure database. The parameters are
 *  specified via the variable length argument list. The return
278
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
279
 */
280 281 282
GimpParam * gimp_run_procedure     (gchar     *name,
				    gint      *nreturn_vals,
				    ...);
Elliot Lee's avatar
Elliot Lee committed
283 284

/* Run a procedure in the procedure database. The parameters are
285 286
 *  specified as an array of GimpParam.  The return
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
287
 */
288 289 290 291
GimpParam * gimp_run_procedure2    (gchar     *name,
				    gint      *nreturn_vals,
				    gint       nparams,
				    GimpParam *params);
Elliot Lee's avatar
Elliot Lee committed
292 293 294 295 296

/* Destroy the an array of parameters. This is useful for
 *  destroying the return values returned by a call to
 *  'gimp_run_procedure'.
 */
297 298
void        gimp_destroy_params    (GimpParam    *params,
				    gint          nparams);
Elliot Lee's avatar
Elliot Lee committed
299

300
/* Destroy the an array of GimpParamDef's. This is useful for
301 302 303
 *  destroying the return values returned by a call to
 *  'gimp_query_procedure'.
 */
304 305
void        gimp_destroy_paramdefs (GimpParamDef *paramdefs,
				    gint          nparams);
Elliot Lee's avatar
Elliot Lee committed
306

307 308 309 310 311 312
gdouble     gimp_gamma             (void);
gboolean    gimp_install_cmap      (void);
gboolean    gimp_use_xshm          (void);
guchar    * gimp_color_cube        (void);
gint        gimp_min_colors        (void);
void        gimp_request_wakeups   (void);
Elliot Lee's avatar
Elliot Lee committed
313

314
gchar     * gimp_get_progname      (void);
Elliot Lee's avatar
Elliot Lee committed
315 316 317 318 319 320 321


#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __GIMP_H__ */