Skip to content
Browse files

AutoLevel needs to calculate levels based on the whole image, not jus…

…t 1 line.
  • Loading branch information...
1 parent 3d8217b commit d013238cb8a6ef03c7d33c25cfb8c15c6f9db4d7 @jpobst jpobst committed Dec 30, 2012
Showing with 16 additions and 6 deletions.
  1. +8 −0 Pinta.ImageManipulation/BaseEffect.cs
  2. +8 −6 Pinta.ImageManipulation/Effects/AutoLevelEffect.cs
View
8 Pinta.ImageManipulation/BaseEffect.cs
@@ -124,6 +124,8 @@ protected virtual void RenderLoop (ISurface src, ISurface dst, Rectangle roi, Ca
src.BeginUpdate ();
dst.BeginUpdate ();
+ OnBeginRender (src, dst, roi);
+
if (Settings.SingleThreaded || roi.Height <= 1) {
for (var y = roi.Y; y <= roi.Bottom; ++y) {
if (token.IsCancellationRequested)
@@ -151,6 +153,8 @@ protected unsafe virtual void RenderLoop (ISurface surface, Rectangle roi, Cance
surface.BeginUpdate ();
dst_wrap.BeginUpdate ();
+ OnBeginRender (surface, dst_wrap, roi);
+
if (Settings.SingleThreaded || roi.Height <= 1) {
for (var y = roi.Y; y <= roi.Bottom; ++y) {
if (token.IsCancellationRequested)
@@ -211,5 +215,9 @@ protected virtual ColorBgra Render (ColorBgra color)
{
return color;
}
+
+ protected virtual void OnBeginRender (ISurface src, ISurface dst, Rectangle roi)
+ {
+ }
}
}
View
14 Pinta.ImageManipulation/Effects/AutoLevelEffect.cs
@@ -9,6 +9,7 @@
using System;
using Pinta.ImageManipulation.UnaryPixelOperations;
+using System.Threading;
namespace Pinta.ImageManipulation.Effects
{
@@ -24,15 +25,16 @@ public AutoLevelEffect ()
}
#region Algorithm Code Ported From PDN
- protected override void RenderLine (ISurface src, ISurface dest, Rectangle roi)
+ protected override void OnBeginRender (ISurface src, ISurface dst, Rectangle roi)
{
- if (op == null) {
- var histogram = new HistogramRgb ();
- histogram.UpdateHistogram (src, src.Bounds);
+ var histogram = new HistogramRgb ();
+ histogram.UpdateHistogram (src, src.Bounds);
- op = histogram.MakeLevelsAuto ();
- }
+ op = histogram.MakeLevelsAuto ();
+ }
+ protected override void RenderLine (ISurface src, ISurface dest, Rectangle roi)
+ {
if (op.isValid)
op.Apply (src, dest, roi);
}

0 comments on commit d013238

Please sign in to comment.
Something went wrong with that request. Please try again.