Skip to content

Commit

Permalink
[Fixes bug #747607] Make the Color Range slider work for Pencil & Ink…
Browse files Browse the repository at this point in the history
… Sketch

Since the BrightnessContrastEffect.Calculate effect is somewhat
expensive, it is not computed on every call to Render (only when
the table_calculated member is false). This meant that any adjustments
to the brightness data after the call to Calculate() had no effect on
the rendered image, since table_calculated remained the same.

Solution: set table_calculated to false whenever any properties
of the BrightnessContrastData class are modified
  • Loading branch information
cameronwhite committed Sep 13, 2011
1 parent 479dcef commit c3ff46b
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public override Gdk.Key AdjustmentMenuKey {
public BrightnessContrastEffect ()
{
EffectData = new BrightnessContrastData ();
EffectData.PropertyChanged += HandleEffectDataPropertyChanged;
}

/// <summary>
/// If any of the effect data was changed, we need to recalculate the rgb table before rendering
/// </summary>
void HandleEffectDataPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
table_calculated = false;
}

public override bool LaunchConfiguration ()
Expand Down Expand Up @@ -137,9 +146,29 @@ private void Calculate ()

public class BrightnessContrastData : EffectData
{
public int Brightness = 0;
public int Contrast = 0;

private int brightness = 0;
private int contrast = 0;

public int Brightness {
get { return brightness; }
set {
if (value != brightness) {
brightness = value;
FirePropertyChanged ("Brightness");
}
}
}

public int Contrast {
get { return contrast; }
set {
if (value != contrast) {
contrast = value;
FirePropertyChanged ("Contrast");
}
}
}

[Skip]
public override bool IsDefault {
get { return Brightness == 0 && Contrast == 0; }
Expand Down

0 comments on commit c3ff46b

Please sign in to comment.