mirror of https://github.com/GNOME/gimp.git
app: make gimp_curves_config_new_spline,explicit() handle variable #points
Also, append _cruft to the function name because they take guint8* arrays, will add proper ones next.
This commit is contained in:
parent
a5fe6c244f
commit
f5e4f01c52
|
@ -361,7 +361,7 @@ gimp_curves_config_curve_dirty (GimpCurve *curve,
|
|||
/* public functions */
|
||||
|
||||
GObject *
|
||||
gimp_curves_config_new_spline (gint32 channel,
|
||||
gimp_curves_config_new_spline_cruft (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
{
|
||||
|
@ -371,6 +371,8 @@ gimp_curves_config_new_spline (gint32 channel,
|
|||
|
||||
g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
|
||||
channel <= GIMP_HISTOGRAM_ALPHA, NULL);
|
||||
g_return_val_if_fail (points != NULL, NULL);
|
||||
g_return_val_if_fail (n_points >= 2 && n_points <= 1024, NULL);
|
||||
|
||||
config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
|
||||
|
||||
|
@ -378,11 +380,11 @@ gimp_curves_config_new_spline (gint32 channel,
|
|||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
/* FIXME: create a curves object with the right number of points */
|
||||
/* unset the last point */
|
||||
gimp_curve_set_point (curve, curve->n_points - 1, -1, -1);
|
||||
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
||||
gimp_curve_set_n_samples (curve, n_points);
|
||||
|
||||
n_points = MIN (n_points / 2, curve->n_points);
|
||||
/* unset the last point */
|
||||
gimp_curve_set_point (curve, curve->n_points - 1, -1.0, -1.0);
|
||||
|
||||
for (i = 0; i < n_points; i++)
|
||||
gimp_curve_set_point (curve, i,
|
||||
|
@ -395,9 +397,9 @@ gimp_curves_config_new_spline (gint32 channel,
|
|||
}
|
||||
|
||||
GObject *
|
||||
gimp_curves_config_new_explicit (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points)
|
||||
gimp_curves_config_new_explicit_cruft (gint32 channel,
|
||||
const guint8 *samples,
|
||||
gint n_samples)
|
||||
{
|
||||
GimpCurvesConfig *config;
|
||||
GimpCurve *curve;
|
||||
|
@ -405,6 +407,8 @@ gimp_curves_config_new_explicit (gint32 channel,
|
|||
|
||||
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);
|
||||
|
||||
|
@ -413,11 +417,12 @@ gimp_curves_config_new_explicit (gint32 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 < 256; i++)
|
||||
for (i = 0; i < n_samples; i++)
|
||||
gimp_curve_set_curve (curve,
|
||||
(gdouble) i / 255.0,
|
||||
(gdouble) points[i] / 255.0);
|
||||
(gdouble) samples[i] / 255.0);
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
|
@ -485,6 +490,7 @@ gimp_curves_config_load_cruft (GimpCurvesConfig *config,
|
|||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
||||
gimp_curve_set_n_points (curve, GIMP_CURVE_N_CRUFT_POINTS);
|
||||
|
||||
gimp_curve_reset (curve, FALSE);
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ struct _GimpCurvesConfigClass
|
|||
|
||||
GType gimp_curves_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GObject * gimp_curves_config_new_spline (gint32 channel,
|
||||
GObject * gimp_curves_config_new_spline_cruft (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
GObject * gimp_curves_config_new_explicit (gint32 channel,
|
||||
GObject * gimp_curves_config_new_explicit_cruft (gint32 channel,
|
||||
const guint8 *points,
|
||||
gint n_points);
|
||||
|
||||
|
|
|
@ -425,9 +425,9 @@ curves_spline_invoker (GimpProcedure *procedure,
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
GObject *config = gimp_curves_config_new_spline_cruft (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
num_points / 2);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
|
@ -472,7 +472,7 @@ curves_explicit_invoker (GimpProcedure *procedure,
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_explicit (channel,
|
||||
GObject *config = gimp_curves_config_new_explicit_cruft (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ drawable_curves_explicit_invoker (GimpProcedure *procedure,
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_explicit (channel,
|
||||
GObject *config = gimp_curves_config_new_explicit_cruft (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
|
@ -275,9 +275,9 @@ drawable_curves_spline_invoker (GimpProcedure *procedure,
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
GObject *config = gimp_curves_config_new_spline_cruft (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
num_points / 2);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
|
|
|
@ -366,9 +366,9 @@ HELP
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
GObject *config = gimp_curves_config_new_spline_cruft (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
num_points / 2);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
|
@ -421,7 +421,7 @@ HELP
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_explicit (channel,
|
||||
GObject *config = gimp_curves_config_new_explicit_cruft (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ HELP
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_explicit (channel,
|
||||
GObject *config = gimp_curves_config_new_explicit_cruft (channel,
|
||||
curve,
|
||||
num_bytes);
|
||||
|
||||
|
@ -273,9 +273,9 @@ HELP
|
|||
(! gimp_drawable_is_gray (drawable) ||
|
||||
channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA))
|
||||
{
|
||||
GObject *config = gimp_curves_config_new_spline (channel,
|
||||
GObject *config = gimp_curves_config_new_spline_cruft (channel,
|
||||
control_pts,
|
||||
num_points);
|
||||
num_points / 2);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Curves"),
|
||||
|
|
Loading…
Reference in New Issue