/**
* big-ellipse.c
* A very basic GIMP plugin, attached to images, that draws a really
* big ellipse when called.
*
* Copyright (c) 2013 Samuel A. Rebelsky. All rights reserved.
*
* This file is part of The Glimmer Guide to GIMP Plugins (aka GGGP).
*
* GGGP is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GGGP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GGGP. If not, see .
*/
// +---------+---------------------------------------------------------
// | Headers |
// +---------+
#include
#include
// +--------+----------------------------------------------------------
// | Macros |
// +--------+
/**
* Print a string (somewhere). Right now, this prints to stderr, which
* means it only works when the program is run from the terminal.
*/
#define REPORT(str) fprintf (stderr, "*** %s ***\n", str)
/**
* Print an integer.
*/
#define REPORT_INT(i) fprintf (stderr, "*** %s: %d ***\n", #i, i)
// +--------------------------+----------------------------------------
// | Function Predeclarations |
// +--------------------------+
static void ellipse_query (void);
static void ellipse_run (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals);
// +-------------+-----------------------------------------------------
// | Boilerplate |
// +-------------+
/**
* The four key functions. This structure *must* be called PLUG_IN_INFO.
*/
GimpPlugInInfo PLUG_IN_INFO =
{
NULL,
NULL,
ellipse_query,
ellipse_run
};
/**
* Indicate that we're ready to begin the main part of the code.
*/
MAIN ()
// +-------------------------+-----------------------------------------
// | Standard GIMP Functions |
// +-------------------------+
static void
ellipse_init (void)
{
} // ellipse_init
static void
ellipse_quit (void)
{
} // ellipse_quit
static void
ellipse_query (void)
{
// Build the description of the parameters that the function expects.
// Each parameter has a type, a name, and a description
// All plug-ins must take a run-mode. Plug-ins associated with an
// image
static GimpParamDef args[] =
{
{ GIMP_PDB_INT32, "run-mode", "Run mode" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input layer or other drawable" }
}; // args
// Tell the GIMP about our plugin.
gimp_install_procedure (
"gggp/image/big-ellipse", // Name
"Select a big ellipse", // Blurb
"Selects an ellipse the size of the image", // Help
"Samuel A. Rebelsky", // Author
"Copyright (c) Samuel A. Rebelsky. All rights reserved.",
// Copyright
"2013", // Year
"/GGGP/BigE", // Path
NULL, // Image types
GIMP_PLUGIN, // Type
3, // Number of params
0, // Number of return vals
args, // Param descriptions
NULL // Return descriptions
);
} // ellipse_query
static void
ellipse_run (const gchar *name,
gint nparams,
const GimpParam *params,
gint *nreturn_vals,
GimpParam **return_vals)
{
// Get the width and the heigth of the image
int image = params[1].data.d_image;
int width = gimp_image_width (image);
int height = gimp_image_height (image);
REPORT_INT (image);
REPORT_INT (width);
REPORT_INT (height);
gimp_ellipse_select (image, 0, 0, width, height,
GIMP_CHANNEL_OP_REPLACE, 1, 1, 5.0);
gimp_edit_stroke (params[2].data.d_drawable);
// Set up return
*nreturn_vals = 0;
*return_vals = NULL;
} // ellipse_run