本文整理汇总了C++中GIMP_CONTEXT函数的典型用法代码示例。如果您正苦于以下问题:C++ GIMP_CONTEXT函数的具体用法?C++ GIMP_CONTEXT怎么用?C++ GIMP_CONTEXT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GIMP_CONTEXT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tool_manager_preset_changed
static void
tool_manager_preset_changed (GimpContext *user_context,
GimpToolPreset *preset,
GimpToolManager *tool_manager)
{
GimpToolInfo *preset_tool;
gboolean tool_change = FALSE;
if (! preset || user_context->gimp->busy)
return;
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
if (preset_tool != gimp_context_get_tool (user_context))
tool_change = TRUE;
if (! tool_change)
tool_manager_disconnect_options (user_context, preset_tool);
gimp_config_copy (GIMP_CONFIG (preset->tool_options),
GIMP_CONFIG (preset_tool->tool_options), 0);
if (tool_change)
gimp_context_set_tool (user_context, preset_tool);
else
tool_manager_connect_options (user_context, preset_tool);
gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options),
user_context,
gimp_tool_preset_get_prop_mask (preset));
}
示例2: tool_manager_connect_options
static void
tool_manager_connect_options (GimpContext *user_context,
GimpToolInfo *tool_info)
{
if (tool_info->context_props)
{
GimpCoreConfig *config = user_context->gimp->config;
GimpContextPropMask global_props = 0;
/* FG and BG are always shared between all tools */
global_props |= GIMP_CONTEXT_FOREGROUND_MASK;
global_props |= GIMP_CONTEXT_BACKGROUND_MASK;
if (config->global_brush)
global_props |= GIMP_CONTEXT_BRUSH_MASK;
if (config->global_dynamics)
global_props |= GIMP_CONTEXT_DYNAMICS_MASK;
if (config->global_pattern)
global_props |= GIMP_CONTEXT_PATTERN_MASK;
if (config->global_palette)
global_props |= GIMP_CONTEXT_PALETTE_MASK;
if (config->global_gradient)
global_props |= GIMP_CONTEXT_GRADIENT_MASK;
if (config->global_font)
global_props |= GIMP_CONTEXT_FONT_MASK;
gimp_context_copy_properties (GIMP_CONTEXT (tool_info->tool_options),
user_context,
tool_info->context_props & ~global_props);
gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options),
user_context);
}
}
示例3: gimp_paint_options_get_gradient_color
gboolean
gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
GimpImage *image,
gdouble grad_point,
gdouble pixel_dist,
GimpRGB *color)
{
GimpDynamics *dynamics;
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (color != NULL, FALSE);
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
if (gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_COLOR))
{
GimpGradientOptions *gradient_options = paint_options->gradient_options;
GimpGradient *gradient;
gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options));
gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options),
NULL, grad_point,
gradient_options->gradient_reverse,
color);
return TRUE;
}
return FALSE;
}
示例4: gimp_pdb_context_constructed
static void
gimp_pdb_context_constructed (GObject *object)
{
GimpInterpolationType interpolation;
gint threshold;
GParamSpec *pspec;
G_OBJECT_CLASS (parent_class)->constructed (object);
/* get default interpolation from gimprc */
interpolation = GIMP_CONTEXT (object)->gimp->config->interpolation_type;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
"interpolation");
if (pspec)
G_PARAM_SPEC_ENUM (pspec)->default_value = interpolation;
g_object_set (object, "interpolation", interpolation, NULL);
/* get default threshold from gimprc */
threshold = GIMP_CONTEXT (object)->gimp->config->default_threshold;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
"sample-threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value = threshold / 255.0;
g_object_set (object, "sample-threshold", threshold / 255.0, NULL);
}
示例5: gimp_edit_fill
void
gimp_edit_fill (GimpImage *image,
GimpDrawable *drawable,
GimpFillOptions *options,
const gchar *undo_desc)
{
GeglBuffer *buffer;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_FILL_OPTIONS (options));
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
return; /* nothing to do, but the fill succeeded */
buffer = gimp_fill_options_create_buffer (options, drawable,
GEGL_RECTANGLE (0, 0,
width, height));
if (! undo_desc)
undo_desc = gimp_fill_options_get_undo_desc (options);
gimp_drawable_apply_buffer (drawable, buffer,
GEGL_RECTANGLE (0, 0, width, height),
TRUE, undo_desc,
gimp_context_get_opacity (GIMP_CONTEXT (options)),
gimp_context_get_paint_mode (GIMP_CONTEXT (options)),
NULL, x, y);
g_object_unref (buffer);
gimp_drawable_update (drawable, x, y, width, height);
}
示例6: tool_manager_preset_changed
static void
tool_manager_preset_changed (GimpContext *user_context,
GimpToolPreset *preset,
GimpToolManager *tool_manager)
{
GimpToolInfo *preset_tool;
gchar *options_name;
gboolean tool_change = FALSE;
if (! preset || user_context->gimp->busy)
return;
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
if (preset_tool != gimp_context_get_tool (user_context))
tool_change = TRUE;
/* save the name, we don't want to overwrite it */
options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options));
gimp_config_copy (GIMP_CONFIG (preset->tool_options),
GIMP_CONFIG (preset_tool->tool_options), 0);
/* restore the saved name */
gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name);
if (tool_change)
gimp_context_set_tool (user_context, preset_tool);
gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options),
user_context,
gimp_tool_preset_get_prop_mask (preset));
if (GIMP_IS_PAINT_OPTIONS (preset->tool_options))
{
GimpToolOptions *src;
GimpToolOptions *dest;
GimpContextPropMask prop_mask = 0;
src = preset->tool_options;
dest = tool_manager->active_tool->tool_info->tool_options;
/* copy various data objects' additional tool options again
* manually, they might have been overwritten by e.g. the "link
* brush stuff to brush defaults" logic in gimptooloptions.c
*/
if (preset->use_brush)
prop_mask |= GIMP_CONTEXT_PROP_MASK_BRUSH;
if (preset->use_dynamics)
prop_mask |= GIMP_CONTEXT_PROP_MASK_DYNAMICS;
if (preset->use_gradient)
prop_mask |= GIMP_CONTEXT_PROP_MASK_GRADIENT;
gimp_paint_options_copy_props (GIMP_PAINT_OPTIONS (src),
GIMP_PAINT_OPTIONS (dest),
prop_mask);
}
}
示例7: gimp_device_info_constructed
static void
gimp_device_info_constructed (GObject *object)
{
GimpDeviceInfo *info = GIMP_DEVICE_INFO (object);
Gimp *gimp;
G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert ((info->device == NULL && info->display == NULL) ||
(GDK_IS_DEVICE (info->device) && GDK_IS_DISPLAY (info->display)));
gimp = GIMP_CONTEXT (object)->gimp;
if (info->device)
{
g_object_set_data (G_OBJECT (info->device), GIMP_DEVICE_INFO_DATA_KEY,
info);
gimp_object_set_name (GIMP_OBJECT (info), info->device->name);
info->mode = info->device->mode;
info->n_axes = info->device->num_axes;
info->n_keys = info->device->num_keys;
}
gimp_context_define_properties (GIMP_CONTEXT (object),
GIMP_DEVICE_INFO_CONTEXT_MASK,
FALSE);
gimp_context_copy_properties (gimp_get_user_context (gimp),
GIMP_CONTEXT (object),
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_serialize_properties (GIMP_CONTEXT (object),
GIMP_DEVICE_INFO_CONTEXT_MASK);
/* FIXME: this is ugly and needs to be done via "notify" once
* the contexts' properties are dynamic.
*/
g_signal_connect (object, "foreground-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
g_signal_connect (object, "background-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
g_signal_connect (object, "tool-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
g_signal_connect (object, "brush-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
g_signal_connect (object, "pattern-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
g_signal_connect (object, "gradient-changed",
G_CALLBACK (gimp_device_info_changed),
NULL);
}
示例8: gimp_crop_tool_execute
static gboolean
gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint x,
gint y,
gint w,
gint h)
{
GimpTool *tool = GIMP_TOOL (rectangle);
GimpCropOptions *options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (tool->display);
gimp_tool_pop_status (tool, tool->display);
/* if rectangle exists, crop it */
if (w > 0 && h > 0)
{
if (options->layer_only)
{
GimpLayer *layer = gimp_image_get_active_layer (image);
gint off_x, off_y;
if (! layer)
{
gimp_tool_message_literal (tool, tool->display,
_("There is no active layer to crop."));
return FALSE;
}
if (gimp_item_is_content_locked (GIMP_ITEM (layer)))
{
gimp_tool_message_literal (tool, tool->display,
_("The active layer's pixels are locked."));
return FALSE;
}
gimp_item_get_offset (GIMP_ITEM (layer), &off_x, &off_y);
off_x -= x;
off_y -= y;
gimp_item_resize (GIMP_ITEM (layer), GIMP_CONTEXT (options),
w, h, off_x, off_y);
}
else
{
gimp_image_crop (image, GIMP_CONTEXT (options),
x, y, w + x, h + y,
TRUE);
}
gimp_image_flush (image);
return TRUE;
}
return TRUE;
}
示例9: gimp_devices_restore
void
gimp_devices_restore (Gimp *gimp)
{
GimpDeviceManager *manager;
GimpContext *user_context;
GimpDeviceInfo *current_device;
GList *list;
gchar *filename;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
manager = gimp_devices_get_manager (gimp);
g_return_if_fail (GIMP_IS_DEVICE_MANAGER (manager));
user_context = gimp_get_user_context (gimp);
for (list = GIMP_LIST (manager)->list;
list;
list = g_list_next (list))
{
GimpDeviceInfo *device_info = list->data;
gimp_context_copy_properties (user_context, GIMP_CONTEXT (device_info),
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_device_info_set_default_tool (device_info);
}
filename = gimp_personal_rc_file ("devicerc");
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
if (! gimp_config_deserialize_file (GIMP_CONFIG (manager),
filename,
gimp,
&error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);
/* don't bail out here */
}
g_free (filename);
current_device = gimp_device_manager_get_current_device (manager);
gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context);
}
示例10: gimp_pdb_context_new
GimpContext *
gimp_pdb_context_new (Gimp *gimp,
GimpContext *parent,
gboolean set_parent)
{
GimpPDBContext *context;
GList *list;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL);
context = g_object_new (GIMP_TYPE_PDB_CONTEXT,
"gimp", gimp,
"name", "PDB Context",
NULL);
gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0);
if (set_parent)
{
gimp_context_define_properties (GIMP_CONTEXT (context),
GIMP_CONTEXT_ALL_PROPS_MASK, FALSE);
gimp_context_set_parent (GIMP_CONTEXT (context), parent);
for (list = gimp_get_paint_info_iter (gimp);
list;
list = g_list_next (list))
{
GimpPaintInfo *info = list->data;
gimp_container_add (context->paint_options_list,
GIMP_OBJECT (info->paint_options));
}
}
else
{
for (list = GIMP_LIST (GIMP_PDB_CONTEXT (parent)->paint_options_list)->list;
list;
list = g_list_next (list))
{
GimpPaintOptions *options = gimp_config_duplicate (list->data);
gimp_container_add (context->paint_options_list,
GIMP_OBJECT (options));
g_object_unref (options);
}
}
return GIMP_CONTEXT (context);
}
示例11: gimp_drawable_bucket_fill
void
gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpFillOptions *options,
gboolean fill_transparent,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
gdouble seed_x,
gdouble seed_y)
{
GimpImage *image;
GeglBuffer *buffer;
gdouble mask_x;
gdouble mask_y;
gint width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_FILL_OPTIONS (options));
image = gimp_item_get_image (GIMP_ITEM (drawable));
gimp_set_busy (image->gimp);
buffer = gimp_drawable_get_bucket_fill_buffer (drawable, options,
fill_transparent, fill_criterion,
threshold, sample_merged,
diagonal_neighbors,
seed_x, seed_y, NULL,
&mask_x, &mask_y, &width, &height);
if (buffer)
{
/* Apply it to the image */
gimp_drawable_apply_buffer (drawable, buffer,
GEGL_RECTANGLE (0, 0, width, height),
TRUE, C_("undo-type", "Bucket Fill"),
gimp_context_get_opacity (GIMP_CONTEXT (options)),
gimp_context_get_paint_mode (GIMP_CONTEXT (options)),
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_LAYER_COLOR_SPACE_AUTO,
gimp_layer_mode_get_paint_composite_mode (
gimp_context_get_paint_mode (GIMP_CONTEXT (options))),
NULL, (gint) mask_x, mask_y);
g_object_unref (buffer);
gimp_drawable_update (drawable, mask_x, mask_y, width, height);
}
gimp_unset_busy (image->gimp);
}
示例12: tool_manager_connect_options
static void
tool_manager_connect_options (GimpToolManager *tool_manager,
GimpContext *user_context,
GimpToolInfo *tool_info)
{
if (tool_info->context_props)
{
GimpCoreConfig *config = user_context->gimp->config;
GimpContextPropMask global_props = 0;
/* FG and BG are always shared between all tools */
global_props |= GIMP_CONTEXT_PROP_MASK_FOREGROUND;
global_props |= GIMP_CONTEXT_PROP_MASK_BACKGROUND;
if (config->global_brush)
global_props |= GIMP_CONTEXT_PROP_MASK_BRUSH;
if (config->global_dynamics)
global_props |= GIMP_CONTEXT_PROP_MASK_DYNAMICS;
if (config->global_pattern)
global_props |= GIMP_CONTEXT_PROP_MASK_PATTERN;
if (config->global_palette)
global_props |= GIMP_CONTEXT_PROP_MASK_PALETTE;
if (config->global_gradient)
global_props |= GIMP_CONTEXT_PROP_MASK_GRADIENT;
if (config->global_font)
global_props |= GIMP_CONTEXT_PROP_MASK_FONT;
gimp_context_copy_properties (GIMP_CONTEXT (tool_info->tool_options),
user_context,
tool_info->context_props & ~global_props);
gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options),
user_context);
if (GIMP_IS_PAINT_OPTIONS (tool_info->tool_options))
{
if (config->global_brush)
gimp_paint_options_copy_brush_props (tool_manager->shared_paint_options,
GIMP_PAINT_OPTIONS (tool_info->tool_options));
if (config->global_dynamics)
gimp_paint_options_copy_dynamics_props (tool_manager->shared_paint_options,
GIMP_PAINT_OPTIONS (tool_info->tool_options));
if (config->global_gradient)
gimp_paint_options_copy_gradient_props (tool_manager->shared_paint_options,
GIMP_PAINT_OPTIONS (tool_info->tool_options));
}
}
}
示例13: gimp_paint_options_get_brush_mode
GimpBrushApplicationMode
gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options)
{
GimpDynamics *dynamics;
GimpDynamicsOutput *force_output;
gboolean dynamic_force = FALSE;
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), GIMP_BRUSH_SOFT);
if (paint_options->hard)
return GIMP_BRUSH_HARD;
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
if (force_output)
dynamic_force = gimp_dynamics_output_is_enabled (force_output);
if (dynamic_force || (paint_options->brush_force > 0.0))
return GIMP_BRUSH_PRESSURE;
return GIMP_BRUSH_SOFT;
}
示例14: tool_presets_save_cmd_callback
void
tool_presets_save_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
GimpToolPreset *preset;
GimpToolInfo *tool_info;
context = gimp_container_view_get_context (editor->view);
preset = gimp_context_get_tool_preset (context);
tool_info = gimp_context_get_tool (gimp_get_user_context (context->gimp));
if (tool_info && preset)
{
GimpToolInfo *preset_tool;
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
if (tool_info != preset_tool)
{
gimp_message (context->gimp,
G_OBJECT (editor), GIMP_MESSAGE_WARNING,
_("Can't save '%s' tool options to an "
"existing '%s' tool preset."),
tool_info->blurb,
preset_tool->blurb);
return;
}
gimp_config_sync (G_OBJECT (tool_info->tool_options),
G_OBJECT (preset->tool_options), 0);
}
}
示例15: gimp_paint_options_set_default_brush_hardness
void
gimp_paint_options_set_default_brush_hardness (GimpPaintOptions *paint_options,
GimpBrush *brush)
{
g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options));
g_return_if_fail (brush == NULL || GIMP_IS_BRUSH (brush));
if (! brush)
brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *generated_brush = GIMP_BRUSH_GENERATED (brush);
g_object_set (paint_options,
"brush-hardness", (gdouble) gimp_brush_generated_get_hardness (generated_brush),
NULL);
}
else
{
g_object_set (paint_options,
"brush-hardness", DEFAULT_BRUSH_HARDNESS,
NULL);
}
}