GObject * gimp_curves_config_new_explicit (gint32 channel, const gdouble *samples, gint n_samples) { GimpCurvesConfig *config; GimpCurve *curve; gint i; g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE && channel <= GIMP_HISTOGRAM_ALPHA, NULL); g_return_val_if_fail (samples != NULL, NULL); g_return_val_if_fail (n_samples >= 2 && n_samples <= 4096, NULL); config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); curve = config->curve[channel]; gimp_data_freeze (GIMP_DATA (curve)); gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE); gimp_curve_set_n_samples (curve, n_samples); for (i = 0; i < n_samples; i++) gimp_curve_set_curve (curve, (gdouble) i / (gdouble) (n_samples - 1), (gdouble) samples[i]); gimp_data_thaw (GIMP_DATA (curve)); return G_OBJECT (config); }
void gimp_drawable_curves_explicit (GimpDrawable *drawable, GimpProgress *progress, gint32 channel, const guint8 *points, gint n_points) { GimpCurvesConfig *config; GimpCurve *curve; gint i; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (! gimp_drawable_is_indexed (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE && channel <= GIMP_HISTOGRAM_ALPHA); if (channel == GIMP_HISTOGRAM_ALPHA) g_return_if_fail (gimp_drawable_has_alpha (drawable)); if (gimp_drawable_is_gray (drawable)) g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA); config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); curve = config->curve[channel]; gimp_data_freeze (GIMP_DATA (curve)); gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE); for (i = 0; i < 256; i++) gimp_curve_set_curve (curve, (gdouble) i / 255.0, (gdouble) points[i] / 255.0); gimp_data_thaw (GIMP_DATA (curve)); gimp_drawable_curves (drawable, progress, config); g_object_unref (config); }