1711 lines
81 KiB
C
1711 lines
81 KiB
C
/* PIKA - Photo and Image Kooker Application
|
|
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
|
|
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
|
|
*
|
|
* Original copyright, applying to most contents (license remains unchanged):
|
|
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl. */
|
|
|
|
#include "config.h"
|
|
|
|
#include "stamp-pdbgen.h"
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
#include "libpikabase/pikabase.h"
|
|
|
|
#include "pdb-types.h"
|
|
|
|
#include "config/pikacoreconfig.h"
|
|
#include "core/pika.h"
|
|
#include "core/pikachannel-select.h"
|
|
#include "core/pikadrawable-fill.h"
|
|
#include "core/pikadrawable-foreground-extract.h"
|
|
#include "core/pikadrawable-offset.h"
|
|
#include "core/pikadrawable-preview.h"
|
|
#include "core/pikadrawable-shadow.h"
|
|
#include "core/pikadrawable.h"
|
|
#include "core/pikaimage.h"
|
|
#include "core/pikaparamspecs.h"
|
|
#include "core/pikatempbuf.h"
|
|
#include "gegl/pika-babl-compat.h"
|
|
#include "gegl/pika-babl.h"
|
|
#include "plug-in/pikaplugin-cleanup.h"
|
|
#include "plug-in/pikaplugin.h"
|
|
#include "plug-in/pikapluginmanager.h"
|
|
|
|
#include "pikapdb.h"
|
|
#include "pikapdb-utils.h"
|
|
#include "pikapdbcontext.h"
|
|
#include "pikaprocedure.h"
|
|
#include "internal-procs.h"
|
|
|
|
#include "pika-intl.h"
|
|
|
|
|
|
static PikaValueArray *
|
|
drawable_get_format_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gchar *format = NULL;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
/* this only transfers the encoding, losing the space, see the
|
|
* code in libpika/pikadrawable.c which reconstructs the actual
|
|
* format in the plug-in process
|
|
*/
|
|
format = g_strdup (babl_format_get_encoding (pika_drawable_get_format (drawable)));
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_take_string (pika_value_array_index (return_vals, 1), format);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_get_thumbnail_format_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gchar *format = NULL;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
format = g_strdup (babl_format_get_encoding (pika_drawable_get_preview_format (drawable)));
|
|
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_take_string (pika_value_array_index (return_vals, 1), format);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_type_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint type = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
type = pika_babl_format_get_image_type (pika_drawable_get_format (drawable));
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_enum (pika_value_array_index (return_vals, 1), type);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_type_with_alpha_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint type_with_alpha = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
const Babl *format = pika_drawable_get_format_with_alpha (drawable);
|
|
|
|
type_with_alpha = pika_babl_format_get_image_type (format);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_enum (pika_value_array_index (return_vals, 1), type_with_alpha);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_has_alpha_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean has_alpha = FALSE;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
has_alpha = pika_drawable_has_alpha (drawable);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), has_alpha);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_is_rgb_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean is_rgb = FALSE;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
is_rgb = pika_drawable_is_rgb (drawable);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), is_rgb);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_is_gray_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean is_gray = FALSE;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
is_gray = pika_drawable_is_gray (drawable);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), is_gray);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_is_indexed_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean is_indexed = FALSE;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
is_indexed = pika_drawable_is_indexed (drawable);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), is_indexed);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_get_bpp_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint bpp = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
const Babl *format = pika_drawable_get_format (drawable);
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), bpp);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_get_width_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint width = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
width = pika_item_get_width (PIKA_ITEM (drawable));
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), width);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_get_height_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint height = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
height = pika_item_get_height (PIKA_ITEM (drawable));
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), height);
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_get_offsets_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint offset_x = 0;
|
|
gint offset_y = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
pika_item_get_offset (PIKA_ITEM (drawable), &offset_x, &offset_y);
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
{
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), offset_x);
|
|
g_value_set_int (pika_value_array_index (return_vals, 2), offset_y);
|
|
}
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_mask_bounds_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean non_empty = FALSE;
|
|
gint x1 = 0;
|
|
gint y1 = 0;
|
|
gint x2 = 0;
|
|
gint y2 = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL, 0, error))
|
|
non_empty = pika_item_mask_bounds (PIKA_ITEM (drawable), &x1, &y1, &x2, &y2);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
{
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), non_empty);
|
|
g_value_set_int (pika_value_array_index (return_vals, 2), x1);
|
|
g_value_set_int (pika_value_array_index (return_vals, 3), y1);
|
|
g_value_set_int (pika_value_array_index (return_vals, 4), x2);
|
|
g_value_set_int (pika_value_array_index (return_vals, 5), y2);
|
|
}
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_mask_intersect_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gboolean non_empty = FALSE;
|
|
gint x = 0;
|
|
gint y = 0;
|
|
gint width = 0;
|
|
gint height = 0;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL, 0, error))
|
|
non_empty = pika_item_mask_intersect (PIKA_ITEM (drawable),
|
|
&x, &y, &width, &height);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
{
|
|
g_value_set_boolean (pika_value_array_index (return_vals, 1), non_empty);
|
|
g_value_set_int (pika_value_array_index (return_vals, 2), x);
|
|
g_value_set_int (pika_value_array_index (return_vals, 3), y);
|
|
g_value_set_int (pika_value_array_index (return_vals, 4), width);
|
|
g_value_set_int (pika_value_array_index (return_vals, 5), height);
|
|
}
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_merge_shadow_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
gboolean undo;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
undo = g_value_get_boolean (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
|
|
PIKA_PDB_ITEM_CONTENT, error) &&
|
|
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
|
|
{
|
|
const gchar *undo_desc = _("Plug-in");
|
|
|
|
if (pika->plug_in_manager->current_plug_in)
|
|
undo_desc = pika_plug_in_get_undo_desc (pika->plug_in_manager->current_plug_in);
|
|
|
|
pika_drawable_merge_shadow_buffer (drawable, undo, undo_desc);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_free_shadow_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
|
|
if (success)
|
|
{
|
|
if (pika->plug_in_manager->current_plug_in)
|
|
pika_plug_in_cleanup_remove_shadow (pika->plug_in_manager->current_plug_in,
|
|
drawable);
|
|
|
|
pika_drawable_free_shadow_buffer (drawable);
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_update_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
gint x;
|
|
gint y;
|
|
gint width;
|
|
gint height;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
x = g_value_get_int (pika_value_array_index (args, 1));
|
|
y = g_value_get_int (pika_value_array_index (args, 2));
|
|
width = g_value_get_int (pika_value_array_index (args, 3));
|
|
height = g_value_get_int (pika_value_array_index (args, 4));
|
|
|
|
if (success)
|
|
{
|
|
pika_drawable_update (drawable, x, y, width, height);
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_fill_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
gint fill_type;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
fill_type = g_value_get_enum (pika_value_array_index (args, 1));
|
|
|
|
if (success)
|
|
{
|
|
if (pika_pdb_item_is_modifiable (PIKA_ITEM (drawable),
|
|
PIKA_PDB_ITEM_CONTENT, error) &&
|
|
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
|
|
{
|
|
pika_drawable_fill (drawable, context, (PikaFillType) fill_type);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_offset_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
gboolean wrap_around;
|
|
gint fill_type;
|
|
gint offset_x;
|
|
gint offset_y;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
wrap_around = g_value_get_boolean (pika_value_array_index (args, 1));
|
|
fill_type = g_value_get_enum (pika_value_array_index (args, 2));
|
|
offset_x = g_value_get_int (pika_value_array_index (args, 3));
|
|
offset_y = g_value_get_int (pika_value_array_index (args, 4));
|
|
|
|
if (success)
|
|
{
|
|
if (pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL,
|
|
PIKA_PDB_ITEM_CONTENT, error) &&
|
|
pika_pdb_item_is_not_group (PIKA_ITEM (drawable), error))
|
|
pika_drawable_offset (drawable, context, wrap_around, fill_type,
|
|
offset_x, offset_y);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_thumbnail_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint width;
|
|
gint height;
|
|
gint actual_width = 0;
|
|
gint actual_height = 0;
|
|
gint bpp = 0;
|
|
GBytes *thumbnail_data = NULL;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
width = g_value_get_int (pika_value_array_index (args, 1));
|
|
height = g_value_get_int (pika_value_array_index (args, 2));
|
|
|
|
if (success)
|
|
{
|
|
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
|
|
PikaTempBuf *buf;
|
|
gint dwidth, dheight;
|
|
|
|
pika_assert (PIKA_VIEWABLE_MAX_PREVIEW_SIZE >= 1024);
|
|
|
|
/* Adjust the width/height ratio */
|
|
dwidth = pika_item_get_width (PIKA_ITEM (drawable));
|
|
dheight = pika_item_get_height (PIKA_ITEM (drawable));
|
|
|
|
if (dwidth > dheight)
|
|
height = MAX (1, (width * dheight) / dwidth);
|
|
else
|
|
width = MAX (1, (height * dwidth) / dheight);
|
|
|
|
if (image->pika->config->layer_previews)
|
|
buf = pika_viewable_get_new_preview (PIKA_VIEWABLE (drawable), context,
|
|
width, height);
|
|
else
|
|
buf = pika_viewable_get_dummy_preview (PIKA_VIEWABLE (drawable),
|
|
width, height,
|
|
pika_drawable_get_preview_format (drawable));
|
|
|
|
if (buf)
|
|
{
|
|
actual_width = pika_temp_buf_get_width (buf);
|
|
actual_height = pika_temp_buf_get_height (buf);
|
|
bpp = babl_format_get_bytes_per_pixel (pika_temp_buf_get_format (buf));
|
|
thumbnail_data = g_bytes_new (pika_temp_buf_get_data (buf),
|
|
pika_temp_buf_get_data_size (buf));
|
|
|
|
pika_temp_buf_unref (buf);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
{
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), actual_width);
|
|
g_value_set_int (pika_value_array_index (return_vals, 2), actual_height);
|
|
g_value_set_int (pika_value_array_index (return_vals, 3), bpp);
|
|
g_value_take_boxed (pika_value_array_index (return_vals, 4), thumbnail_data);
|
|
}
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_sub_thumbnail_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaValueArray *return_vals;
|
|
PikaDrawable *drawable;
|
|
gint src_x;
|
|
gint src_y;
|
|
gint src_width;
|
|
gint src_height;
|
|
gint dest_width;
|
|
gint dest_height;
|
|
gint width = 0;
|
|
gint height = 0;
|
|
gint bpp = 0;
|
|
GBytes *thumbnail_data = NULL;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
src_x = g_value_get_int (pika_value_array_index (args, 1));
|
|
src_y = g_value_get_int (pika_value_array_index (args, 2));
|
|
src_width = g_value_get_int (pika_value_array_index (args, 3));
|
|
src_height = g_value_get_int (pika_value_array_index (args, 4));
|
|
dest_width = g_value_get_int (pika_value_array_index (args, 5));
|
|
dest_height = g_value_get_int (pika_value_array_index (args, 6));
|
|
|
|
if (success)
|
|
{
|
|
if ((src_x + src_width) <= pika_item_get_width (PIKA_ITEM (drawable)) &&
|
|
(src_y + src_height) <= pika_item_get_height (PIKA_ITEM (drawable)))
|
|
{
|
|
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
|
|
PikaTempBuf *buf;
|
|
|
|
if (image->pika->config->layer_previews)
|
|
buf = pika_drawable_get_sub_preview (drawable,
|
|
src_x, src_y,
|
|
src_width, src_height,
|
|
dest_width, dest_height);
|
|
else
|
|
buf = pika_viewable_get_dummy_preview (PIKA_VIEWABLE (drawable),
|
|
dest_width, dest_height,
|
|
pika_drawable_get_preview_format (drawable));
|
|
|
|
if (buf)
|
|
{
|
|
width = pika_temp_buf_get_width (buf);
|
|
height = pika_temp_buf_get_height (buf);
|
|
bpp = babl_format_get_bytes_per_pixel (pika_temp_buf_get_format (buf));
|
|
thumbnail_data = g_bytes_new (pika_temp_buf_get_data (buf),
|
|
pika_temp_buf_get_data_size (buf));
|
|
|
|
pika_temp_buf_unref (buf);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return_vals = pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
|
|
if (success)
|
|
{
|
|
g_value_set_int (pika_value_array_index (return_vals, 1), width);
|
|
g_value_set_int (pika_value_array_index (return_vals, 2), height);
|
|
g_value_set_int (pika_value_array_index (return_vals, 3), bpp);
|
|
g_value_take_boxed (pika_value_array_index (return_vals, 4), thumbnail_data);
|
|
}
|
|
|
|
return return_vals;
|
|
}
|
|
|
|
static PikaValueArray *
|
|
drawable_foreground_extract_invoker (PikaProcedure *procedure,
|
|
Pika *pika,
|
|
PikaContext *context,
|
|
PikaProgress *progress,
|
|
const PikaValueArray *args,
|
|
GError **error)
|
|
{
|
|
gboolean success = TRUE;
|
|
PikaDrawable *drawable;
|
|
gint mode;
|
|
PikaDrawable *mask;
|
|
|
|
drawable = g_value_get_object (pika_value_array_index (args, 0));
|
|
mode = g_value_get_enum (pika_value_array_index (args, 1));
|
|
mask = g_value_get_object (pika_value_array_index (args, 2));
|
|
|
|
if (success)
|
|
{
|
|
if (mode == PIKA_FOREGROUND_EXTRACT_MATTING &&
|
|
pika_pdb_item_is_attached (PIKA_ITEM (drawable), NULL, 0, error))
|
|
{
|
|
PikaPDBContext *pdb_context = PIKA_PDB_CONTEXT (context);
|
|
PikaImage *image = pika_item_get_image (PIKA_ITEM (drawable));
|
|
GeglBuffer *buffer;
|
|
|
|
buffer = pika_drawable_foreground_extract (drawable,
|
|
PIKA_MATTING_ENGINE_GLOBAL,
|
|
2,
|
|
2,
|
|
2,
|
|
pika_drawable_get_buffer (mask),
|
|
progress);
|
|
|
|
pika_channel_select_buffer (pika_image_get_mask (image),
|
|
C_("command", "Foreground Select"),
|
|
buffer,
|
|
0, /* x offset */
|
|
0, /* y offset */
|
|
PIKA_CHANNEL_OP_REPLACE,
|
|
pdb_context->feather,
|
|
pdb_context->feather_radius_x,
|
|
pdb_context->feather_radius_y);
|
|
|
|
g_object_unref (buffer);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return pika_procedure_get_return_values (procedure, success,
|
|
error ? *error : NULL);
|
|
}
|
|
|
|
void
|
|
register_drawable_procs (PikaPDB *pdb)
|
|
{
|
|
PikaProcedure *procedure;
|
|
|
|
/*
|
|
* pika-drawable-get-format
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_format_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-format");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the drawable's Babl format",
|
|
"This procedure returns the drawable's Babl format.\n"
|
|
"Note that the actual PDB procedure only transfers the format's encoding. In order to get to the real format, the libbpika C wrapper must be used.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2012");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
pika_param_spec_string ("format",
|
|
"format",
|
|
"The drawable's Babl format",
|
|
FALSE, FALSE, FALSE,
|
|
NULL,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-get-thumbnail-format
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_thumbnail_format_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-thumbnail-format");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the drawable's thumbnail Babl format",
|
|
"This procedure returns the drawable's thumbnail Babl format.\n"
|
|
"Thumbnails are always 8-bit images, see 'pika-drawable-thumbnail' and 'pika-drawable-sub-thmbnail'.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2019");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
pika_param_spec_string ("format",
|
|
"format",
|
|
"The drawable's thumbnail Babl format",
|
|
FALSE, FALSE, FALSE,
|
|
NULL,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-type
|
|
*/
|
|
procedure = pika_procedure_new (drawable_type_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-type");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the drawable's type.",
|
|
"This procedure returns the drawable's type.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_enum ("type",
|
|
"type",
|
|
"The drawable's type",
|
|
PIKA_TYPE_IMAGE_TYPE,
|
|
PIKA_RGB_IMAGE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-type-with-alpha
|
|
*/
|
|
procedure = pika_procedure_new (drawable_type_with_alpha_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-type-with-alpha");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the drawable's type with alpha.",
|
|
"This procedure returns the drawable's type as if had an alpha channel. If the type is currently Gray, for instance, the returned type would be GrayA. If the drawable already has an alpha channel, the drawable's type is simply returned.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
pika_param_spec_enum ("type-with-alpha",
|
|
"type with alpha",
|
|
"The drawable's type with alpha",
|
|
PIKA_TYPE_IMAGE_TYPE,
|
|
PIKA_RGB_IMAGE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->values[0]),
|
|
PIKA_RGB_IMAGE);
|
|
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->values[0]),
|
|
PIKA_GRAY_IMAGE);
|
|
pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->values[0]),
|
|
PIKA_INDEXED_IMAGE);
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-has-alpha
|
|
*/
|
|
procedure = pika_procedure_new (drawable_has_alpha_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-has-alpha");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns TRUE if the drawable has an alpha channel.",
|
|
"This procedure returns whether the specified drawable has an alpha channel. This can only be true for layers, and the associated type will be one of: { RGBA , GRAYA, INDEXEDA }.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("has-alpha",
|
|
"has alpha",
|
|
"Does the drawable have an alpha channel?",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-is-rgb
|
|
*/
|
|
procedure = pika_procedure_new (drawable_is_rgb_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-is-rgb");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns whether the drawable is an RGB type.",
|
|
"This procedure returns TRUE if the specified drawable is of type { RGB, RGBA }.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("is-rgb",
|
|
"is rgb",
|
|
"TRUE if the drawable is an RGB type",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-is-gray
|
|
*/
|
|
procedure = pika_procedure_new (drawable_is_gray_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-is-gray");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns whether the drawable is a grayscale type.",
|
|
"This procedure returns TRUE if the specified drawable is of type { Gray, GrayA }.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("is-gray",
|
|
"is gray",
|
|
"TRUE if the drawable is a grayscale type",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-is-indexed
|
|
*/
|
|
procedure = pika_procedure_new (drawable_is_indexed_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-is-indexed");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns whether the drawable is an indexed type.",
|
|
"This procedure returns TRUE if the specified drawable is of type { Indexed, IndexedA }.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("is-indexed",
|
|
"is indexed",
|
|
"TRUE if the drawable is an indexed type",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-get-bpp
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_bpp_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-bpp");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the bytes per pixel.",
|
|
"This procedure returns the number of bytes per pixel.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("bpp",
|
|
"bpp",
|
|
"Bytes per pixel",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-get-width
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_width_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-width");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the width of the drawable.",
|
|
"This procedure returns the specified drawable's width in pixels.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("width",
|
|
"width",
|
|
"Width of drawable",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-get-height
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_height_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-height");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the height of the drawable.",
|
|
"This procedure returns the specified drawable's height in pixels.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("height",
|
|
"height",
|
|
"Height of drawable",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-get-offsets
|
|
*/
|
|
procedure = pika_procedure_new (drawable_get_offsets_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-get-offsets");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Returns the offsets for the drawable.",
|
|
"This procedure returns the specified drawable's offsets. This only makes sense if the drawable is a layer since channels are anchored. The offsets of a channel will be returned as 0.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("offset-x",
|
|
"offset x",
|
|
"x offset of drawable",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("offset-y",
|
|
"offset y",
|
|
"y offset of drawable",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-mask-bounds
|
|
*/
|
|
procedure = pika_procedure_new (drawable_mask_bounds_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-mask-bounds");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Find the bounding box of the current selection in relation to the specified drawable.",
|
|
"This procedure returns whether there is a selection. If there is one, the upper left and lower right-hand corners of its bounding box are returned. These coordinates are specified relative to the drawable's origin, and bounded by the drawable's extents. Please note that the pixel specified by the lower right-hand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).\n"
|
|
"Note that the returned boolean does NOT correspond with the returned region being empty or not, it always returns whether the selection is non_empty. See 'pika-drawable-mask-intersect' for a boolean return value which is more useful in most cases.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("non-empty",
|
|
"non empty",
|
|
"TRUE if there is a selection",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("x1",
|
|
"x1",
|
|
"x coordinate of the upper left corner of selection bounds",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("y1",
|
|
"y1",
|
|
"y coordinate of the upper left corner of selection bounds",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("x2",
|
|
"x2",
|
|
"x coordinate of the lower right corner of selection bounds",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("y2",
|
|
"y2",
|
|
"y coordinate of the lower right corner of selection bounds",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-mask-intersect
|
|
*/
|
|
procedure = pika_procedure_new (drawable_mask_intersect_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-mask-intersect");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Find the bounding box of the current selection in relation to the specified drawable.",
|
|
"This procedure returns whether there is an intersection between the drawable and the selection. Unlike 'pika-drawable-mask-bounds', the intersection's bounds are returned as x, y, width, height.\n"
|
|
"If there is no selection this function returns TRUE and the returned bounds are the extents of the whole drawable.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2004");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boolean ("non-empty",
|
|
"non empty",
|
|
"TRUE if the returned area is not empty",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("x",
|
|
"x",
|
|
"x coordinate of the upper left corner of the intersection",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("y",
|
|
"y",
|
|
"y coordinate of the upper left corner of the intersection",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("width",
|
|
"width",
|
|
"width of the intersection",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("height",
|
|
"height",
|
|
"height of the intersection",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-merge-shadow
|
|
*/
|
|
procedure = pika_procedure_new (drawable_merge_shadow_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-merge-shadow");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Merge the shadow buffer with the specified drawable.",
|
|
"This procedure combines the contents of the drawable's shadow buffer (for temporary processing) with the specified drawable. The 'undo' parameter specifies whether to add an undo step for the operation. Requesting no undo is useful for such applications as 'auto-apply'.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_boolean ("undo",
|
|
"undo",
|
|
"Push merge to undo stack?",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-free-shadow
|
|
*/
|
|
procedure = pika_procedure_new (drawable_free_shadow_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-free-shadow");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Free the specified drawable's shadow data (if it exists).",
|
|
"This procedure is intended as a memory saving device. If any shadow memory has been allocated, it will be freed automatically when the drawable is removed from the image, or when the plug-in procedure which allocated it returns.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2008");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-update
|
|
*/
|
|
procedure = pika_procedure_new (drawable_update_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-update");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Update the specified region of the drawable.",
|
|
"This procedure updates the specified region of the drawable. The (x, y) coordinate pair is relative to the drawable's origin, not to the image origin. Therefore, the entire drawable can be updated using (0, 0, width, height).",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("x",
|
|
"x",
|
|
"x coordinate of upper left corner of update region",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("y",
|
|
"y",
|
|
"y coordinate of upper left corner of update region",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("width",
|
|
"width",
|
|
"Width of update region",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("height",
|
|
"height",
|
|
"Height of update region",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-fill
|
|
*/
|
|
procedure = pika_procedure_new (drawable_fill_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-fill");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Fill the drawable with the specified fill mode.",
|
|
"This procedure fills the drawable. If the fill mode is foreground the current foreground color is used. If the fill mode is background, the current background color is used. If the fill type is white, then white is used. Transparent fill only affects layers with an alpha channel, in which case the alpha channel is set to transparent. If the drawable has no alpha channel, it is filled to white. No fill leaves the drawable's contents undefined.\n"
|
|
"This procedure is unlike 'pika-drawable-edit-fill' or the bucket fill tool because it fills regardless of a selection. Its main purpose is to fill a newly created drawable before adding it to the image. This operation cannot be undone.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1995-1996");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_enum ("fill-type",
|
|
"fill type",
|
|
"The type of fill",
|
|
PIKA_TYPE_FILL_TYPE,
|
|
PIKA_FILL_FOREGROUND,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-offset
|
|
*/
|
|
procedure = pika_procedure_new (drawable_offset_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-offset");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Offset the drawable by the specified amounts in the X and Y directions",
|
|
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill-type' parameter.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Spencer Kimball & Peter Mattis",
|
|
"Spencer Kimball & Peter Mattis",
|
|
"1997");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable to offset",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_boolean ("wrap-around",
|
|
"wrap around",
|
|
"wrap image around or fill vacated regions",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_enum ("fill-type",
|
|
"fill type",
|
|
"fill vacated regions of drawable with background or transparent",
|
|
PIKA_TYPE_OFFSET_TYPE,
|
|
PIKA_OFFSET_BACKGROUND,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("offset-x",
|
|
"offset x",
|
|
"offset by this amount in X direction",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("offset-y",
|
|
"offset y",
|
|
"offset by this amount in Y direction",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-thumbnail
|
|
*/
|
|
procedure = pika_procedure_new (drawable_thumbnail_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-thumbnail");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Get a thumbnail of a drawable.",
|
|
"This function gets data from which a thumbnail of a drawable preview can be created. Maximum x or y dimension is 1024 pixels. The pixels are returned in RGB[A] or GRAY[A] format. The bpp return value gives the number of bytes in the image.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Andy Thomas",
|
|
"Andy Thomas",
|
|
"1999");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("width",
|
|
"width",
|
|
"The requested thumbnail width",
|
|
1, 1024, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("height",
|
|
"height",
|
|
"The requested thumbnail height",
|
|
1, 1024, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("actual-width",
|
|
"actual width",
|
|
"The previews width",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("actual-height",
|
|
"actual height",
|
|
"The previews height",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("bpp",
|
|
"bpp",
|
|
"The previews bpp",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boxed ("thumbnail-data",
|
|
"thumbnail data",
|
|
"The thumbnail data",
|
|
G_TYPE_BYTES,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-sub-thumbnail
|
|
*/
|
|
procedure = pika_procedure_new (drawable_sub_thumbnail_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-sub-thumbnail");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Get a thumbnail of a sub-area of a drawable drawable.",
|
|
"This function gets data from which a thumbnail of a drawable preview can be created. Maximum x or y dimension is 1024 pixels. The pixels are returned in RGB[A] or GRAY[A] format. The bpp return value gives the number of bytes in the image.",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
"Michael Natterer",
|
|
"2004");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("src-x",
|
|
"src x",
|
|
"The x coordinate of the area",
|
|
0, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("src-y",
|
|
"src y",
|
|
"The y coordinate of the area",
|
|
0, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("src-width",
|
|
"src width",
|
|
"The width of the area",
|
|
1, G_MAXINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("src-height",
|
|
"src height",
|
|
"The height of the area",
|
|
1, G_MAXINT32, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("dest-width",
|
|
"dest width",
|
|
"The thumbnail width",
|
|
1, 1024, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_int ("dest-height",
|
|
"dest height",
|
|
"The thumbnail height",
|
|
1, 1024, 1,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("width",
|
|
"width",
|
|
"The previews width",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("height",
|
|
"height",
|
|
"The previews height",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_int ("bpp",
|
|
"bpp",
|
|
"The previews bpp",
|
|
G_MININT32, G_MAXINT32, 0,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_return_value (procedure,
|
|
g_param_spec_boxed ("thumbnail-data",
|
|
"thumbnail data",
|
|
"The thumbnail data",
|
|
G_TYPE_BYTES,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
|
|
/*
|
|
* pika-drawable-foreground-extract
|
|
*/
|
|
procedure = pika_procedure_new (drawable_foreground_extract_invoker);
|
|
pika_object_set_static_name (PIKA_OBJECT (procedure),
|
|
"pika-drawable-foreground-extract");
|
|
pika_procedure_set_static_help (procedure,
|
|
"Extract the foreground of a drawable using a given trimap.",
|
|
"Image Segmentation by Uniform Color Clustering, see https://www.inf.fu-berlin.de/inst/pubs/tr-b-05-07.pdf",
|
|
NULL);
|
|
pika_procedure_set_static_attribution (procedure,
|
|
"Gerald Friedland <fland@inf.fu-berlin.de>, Kristian Jantz <jantz@inf.fu-berlin.de>, Sven Neumann <sven@gimp.org>",
|
|
"Gerald Friedland",
|
|
"2005");
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("drawable",
|
|
"drawable",
|
|
"The drawable",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
g_param_spec_enum ("mode",
|
|
"mode",
|
|
"The algorithm to use",
|
|
PIKA_TYPE_FOREGROUND_EXTRACT_MODE,
|
|
PIKA_FOREGROUND_EXTRACT_MATTING,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_procedure_add_argument (procedure,
|
|
pika_param_spec_drawable ("mask",
|
|
"mask",
|
|
"Tri-Map",
|
|
FALSE,
|
|
PIKA_PARAM_READWRITE));
|
|
pika_pdb_register_procedure (pdb, procedure);
|
|
g_object_unref (procedure);
|
|
}
|