static gboolean gimp_operation_posterize_process (GeglOperation *operation, void *in_buf, void *out_buf, glong samples, const GeglRectangle *roi, gint level) { GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (point->config); gfloat *src = in_buf; gfloat *dest = out_buf; gfloat levels; if (! config) return FALSE; levels = config->levels - 1.0; while (samples--) { dest[RED] = RINT (src[RED] * levels) / levels; dest[GREEN] = RINT (src[GREEN] * levels) / levels; dest[BLUE] = RINT (src[BLUE] * levels) / levels; dest[ALPHA] = src[ALPHA]; src += 4; dest += 4; } return TRUE; }
static void gimp_posterize_tool_config_notify (GObject *object, GParamSpec *pspec, GimpPosterizeTool *posterize_tool) { GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (object); if (! posterize_tool->levels_data) return; gtk_adjustment_set_value (posterize_tool->levels_data, config->levels); gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool)); }
static void gimp_posterize_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpPosterizeConfig *self = GIMP_POSTERIZE_CONFIG (object); switch (property_id) { case PROP_LEVELS: self->levels = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }