Gimp
view release on metacpan or search on metacpan
lib/Gimp/Lib.xs view on Meta::CPAN
{
char *argv [10];
int argc = 0;
if (items != 0)
croak (__("arguments to main not yet supported!"));
AV *av = perl_get_av ("ARGV", FALSE);
argv [argc++] = SvPV_nolen (perl_get_sv ("0", FALSE));
if (!(av && av_len (av) < 10-1))
croak ("internal error (please report): too many arguments to main");
while (argc-1 <= av_len (av))
argv [argc] = SvPV_nolen (*av_fetch (av, argc-1, 0)),
argc++;
gimp_is_initialized = 1;
RETVAL = gimp_main (&PLUG_IN_INFO, argc, argv);
gimp_is_initialized = 0;
/*exit (0);*/ /*D*//* shit, some memory problem here, so just exit */
}
OUTPUT:
RETVAL
PROTOTYPES: ENABLE
int
initialized()
CODE:
RETVAL = gimp_is_initialized;
OUTPUT:
RETVAL
int
gimp_major_version()
CODE:
RETVAL = gimp_major_version;
OUTPUT:
RETVAL
int
gimp_minor_version()
CODE:
RETVAL = gimp_minor_version;
OUTPUT:
RETVAL
int
gimp_micro_version()
CODE:
RETVAL = gimp_micro_version;
OUTPUT:
RETVAL
void
gimp_enums_get_type_names()
INIT:
gimp_enums_init ();
gint n_type_names;
const gchar **etn;
int i;
PPCODE:
etn = gimp_enums_get_type_names (&n_type_names);
if (!etn) XSRETURN_EMPTY;
EXTEND(SP, n_type_names);
for (i = 0; i < n_type_names; i++) {
PUSHs(sv_2mortal(newSVpv(etn[i], 0)));
}
# return list of pair => value, ...
void
gimp_enums_list_type(name)
const char *name
INIT:
GType enum_type;
GEnumClass *enum_class;
GEnumValue *value;
PPCODE:
if (!(enum_type = g_type_from_name (name)))
croak (__("gimp_enums_list_type(%s) invalid name"), name);
if (!(enum_class = g_type_class_peek (enum_type)))
croak (__("gimp_enums_list_type(%s) invalid class"), name);
for (value = enum_class->values; value->value_name; value++) {
XPUSHs(sv_2mortal(newSVpv(value->value_name,0)));
XPUSHs(sv_2mortal(newSViv(value->value)));
}
# checks whether a gimp procedure exists
int
gimp_procedural_db_proc_exists(char *proc_name)
CODE:
if (!gimp_is_initialized)
croak (__("gimp_procedural_db_proc_exists(%s) called without an active connection"), proc_name);
RETVAL = gimp_procedural_db_proc_exists(proc_name);
OUTPUT:
RETVAL
# get gimp procedure info
void
gimp_procedural_db_proc_info(proc_name)
char * proc_name
PPCODE:
{
char *proc_blurb;
char *proc_help;
char *proc_author;
char *proc_copyright;
char *proc_date;
GimpPDBProcType proc_type;
int nparams;
int nreturn_vals;
GimpParamDef *params;
GimpParamDef *return_vals;
if (!gimp_is_initialized)
croak("gimp_procedural_db_proc_info called without an active connection");
if (
gimp_procedural_db_proc_info(
proc_name, &proc_blurb, &proc_help, &proc_author,
&proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
¶ms, &return_vals
) != TRUE
)
XSRETURN_EMPTY;
EXTEND(SP,8);
PUSHs(newSVpv(proc_blurb,0)); g_free(proc_blurb);
PUSHs(newSVpv(proc_help,0)); g_free(proc_help);
PUSHs(newSVpv(proc_author,0)); g_free(proc_author);
PUSHs(newSVpv(proc_copyright,0)); g_free(proc_copyright);
PUSHs(newSVpv(proc_date,0)); g_free(proc_date);
PUSHs(newSViv(proc_type));
PUSHs(newSV_paramdefs(params, nparams));
gimp_destroy_paramdefs(params, nparams);
PUSHs(newSV_paramdefs(return_vals, nreturn_vals));
gimp_destroy_paramdefs(return_vals, nreturn_vals);
}
void
gimp_procedural_db_query(name, blurb, help, author, copyright, date, proc_type)
const char *name
const char *blurb
const char *help
const char *author
const char *copyright
const char *date
const char *proc_type
INIT:
gint num_matches;
gchar **procedure_names;
int i;
PPCODE:
if (!gimp_procedural_db_query (
name, blurb, help, author, copyright, date, proc_type, &num_matches,
&procedure_names
)) croak (__("gimp_procedural_db_proc_query failed"));
if (!num_matches) XSRETURN_EMPTY;
EXTEND (SP, num_matches);
for (i = 0; i < num_matches; i++) {
PUSHs (sv_2mortal(newSVpv(procedure_names[i], 0)));
}
void
gimp_call_procedure (proc_name, ...)
utf8_str proc_name
PPCODE:
{
char croak_str[MAX_STRING] = "";
char *proc_blurb;
char *proc_help;
char *proc_author;
char *proc_copyright;
char *proc_date;
GimpPDBProcType proc_type;
int nparams;
int nreturn_vals;
GimpParam *args = 0;
GimpParam *values = 0;
int nvalues;
GimpParamDef *params;
GimpParamDef *return_vals;
int i=0, j=0;
if (!gimp_is_initialized)
croak (__("gimp_call_procedure(%s,...) called without an active connection"), proc_name);
// do this here as at BOOT causes error
gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
verbose_printf (1, "%s", proc_name);
if (
gimp_procedural_db_proc_info(
proc_name, &proc_blurb, &proc_help, &proc_author,
&proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
¶ms, &return_vals
) != TRUE
)
croak (__("gimp procedure '%s' not found"), proc_name);
try_call ("-proc");
int runmode_firstparam = nparams
&& params[0].type == GIMP_PDB_INT32
&& (!strcmp (params[0].name, "run_mode") || !strcmp (params[0].name, "run-mode"));
g_free (proc_blurb);
g_free (proc_help);
g_free (proc_author);
g_free (proc_copyright);
g_free (proc_date);
if (nparams)
args = (GimpParam *) g_new0 (GimpParam, nparams);
if (runmode_firstparam) {
/* If it's a valid value for the run mode, and # of parameters
are consistent with this, we assume the user explicitly passed the run
mode parameter */
args[0].type = params[0].type;
if (
nparams==(items-1) && (
SvIV(ST(1))==GIMP_RUN_INTERACTIVE ||
SvIV(ST(1))==GIMP_RUN_NONINTERACTIVE ||
SvIV(ST(1))==GIMP_RUN_WITH_LAST_VALS
)
) {
args->data.d_int32 = SvIV(ST(1)); // ST(0) = proc_name
lib/Gimp/Lib.xs view on Meta::CPAN
apd,
rpd,
pii_run
);
else {
gimp_plugin_domain_register ("gimp-perl", datadir "/locale");
gimp_install_procedure(
name,
blurb,
help,
author,
copyright,
date,
menu_name,
SvPv(image_types),
type,
nparams,
nreturn_vals,
apd,
rpd
);
}
g_free (rpd);
g_free (apd);
if (slash_ptr) gimp_plugin_menu_register(name, menu_location);
if (menu_location) g_free(menu_location);
void
gimp_uninstall_temp_proc(name)
utf8_str name
void
gimp_lib_quit()
CODE:
gimp_quit ();
void
gimp_extension_process(timeout)
guint timeout
void
gimp_extension_enable()
void
gimp_extension_ack()
void
gimp_set_data(id, data)
SV * id
SV * data;
CODE:
{
STRLEN dlen;
void *dta = SvPV (data, dlen);
gimp_set_data (SvPV_nolen (id), dta, dlen);
}
void
gimp_get_data(id)
SV * id;
PPCODE:
{
SV *data;
STRLEN dlen;
dlen = gimp_get_data_size (SvPV_nolen (id));
/* I count on dlen being zero if "id" doesn't exist. */
data = newSVpv ("", 0);
gimp_get_data (SvPV_nolen (id), SvGROW (data, dlen+1));
SvCUR_set (data, dlen);
*((char *)SvPV_nolen (data) + dlen) = 0;
XPUSHs (sv_2mortal (data));
}
gdouble
gimp_gamma()
gint
gimp_install_cmap()
const char *
gimp_gtkrc()
const char *
gimp_directory()
const char *
gimp_get_pdb_error()
const char *
gimp_data_directory()
SV *
gimp_personal_rc_file(basename)
char * basename
CODE:
basename = gimp_personal_rc_file (basename);
RETVAL = sv_2mortal (newSVpv (basename, 0));
g_free (basename);
OUTPUT:
RETVAL
guint
gimp_tile_width()
guint
gimp_tile_height()
void
gimp_tile_cache_size(kilobytes)
gulong kilobytes
void
gimp_tile_cache_ntiles(ntiles)
gulong ntiles
SV *
gimp_drawable_get(drawable_ID)
DRAWABLE drawable_ID
CODE:
RETVAL = new_gdrawable (drawable_ID);
lib/Gimp/Lib.xs view on Meta::CPAN
dims[0] = pr->bpp;
dims[1] = pr->rowstride / pr->bpp;
dims[2] = pr->h;
PDL->setdims (p, dims, 3);
p->datatype = PDL_B;
p->data = pr->data;
p->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED;
PDL->add_deletedata_magic(p, pixel_rgn_pdl_delete_data, 0);
if ((int)pr->w != dims[1])
p = redim_pdl (p, 1, pr->w);
RETVAL = p;
}
OUTPUT:
RETVAL
# ??? optimize these two functions so tile_*ref will only be called once on
# construction/destruction.
SV *
gimp_tile_get_data(tile)
GimpTile * tile
CODE:
need_pdl ();
croak (__("gimp_tile_get_data is not yet implemented\n"));
gimp_tile_ref (tile);
gimp_tile_unref (tile, 0);
OUTPUT:
RETVAL
void
gimp_tile_set_data(tile,data)
GimpTile * tile
SV * data
CODE:
data = data; // to suppress "unused var" warning
croak (__("gimp_tile_set_data is not yet implemented\n")); /*(void *)data;*/
gimp_tile_ref_zero (tile);
gimp_tile_unref (tile, 1);
BOOT:
#if (GLIB_MAJOR_VERSION < 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 36))
g_type_init();
#endif
g_log_set_handler(
"LibGimp",
G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
throw_exception,
NULL
);
#
# this function overrides a pdb function for speed
#
void
gimp_patterns_get_pattern_data(name)
SV * name
PPCODE:
{
GimpParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure ("gimp_patterns_get_pattern_data",
&nreturn_vals,
GIMP_PDB_STRING, SvPV_nolen (name),
GIMP_PDB_END);
if (nreturn_vals == 7
&& return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
EXTEND (SP, 5);
PUSHs (sv_2mortal (newSVpv ( return_vals[1].data.d_string, 0)));
PUSHs (sv_2mortal (newSViv ( return_vals[2].data.d_int32)));
PUSHs (sv_2mortal (newSViv ( return_vals[3].data.d_int32)));
PUSHs (sv_2mortal (newSViv ( return_vals[4].data.d_int32)));
PUSHs (sv_2mortal (newSVpvn((char *)return_vals[6].data.d_int8array, return_vals[5].data.d_int32)));
}
gimp_destroy_params (return_vals, nreturn_vals);
}
void
_gimp_progress_init (message)
utf8_str message
CODE:
gimp_progress_init (message);
DISPLAY
gimp_default_display()
const char *
gimp_display_name()
# functions using different calling conventions:
#void
#gimp_channel_get_color(channel_ID, red, green, blue)
# CHANNEL channel_ID
# guchar * red
# guchar * green
# guchar * blue
#gint32 *
#gimp_image_get_channels(image_ID, nchannels)
# IMAGE image_ID
# gint * nchannels
#guchar *
#gimp_image_get_cmap(image_ID, ncolors)
# IMAGE image_ID
# gint * ncolors
#gint32 *
#gimp_image_get_layers(image_ID, nlayers)
# IMAGE image_ID
# gint * nlayers
#gint32
#gimp_layer_new(image_ID, name, width, height, type, opacity, mode)
# gint32 image_ID
# char * name
# guint width
( run in 0.477 second using v1.01-cache-2.11-cpan-5511b514fd6 )