Browse Source

Merge branch 'master' into js/convolution-experiments

js/color-alpha-handling
James Jackson-South 5 years ago
committed by GitHub
parent
commit
a468152887
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
  2. 33
      tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs

4
src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs

@ -72,11 +72,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
public void Invoke(int y, Span<Vector4> span)
{
Span<TPixel> rowSpan = this.source.GetPixelRowSpan(y).Slice(this.startX, span.Length);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, rowSpan, span);
PixelOperations<TPixel>.Instance.ToVector4(this.configuration, rowSpan, span, PixelConversionModifiers.Scale);
ColorNumerics.Transform(span, ref Unsafe.AsRef(this.matrix));
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, span, rowSpan);
PixelOperations<TPixel>.Instance.FromVector4Destructive(this.configuration, span, rowSpan, PixelConversionModifiers.Scale);
}
}
}

33
tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Filters;
using Xunit;
@ -26,5 +27,33 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects
Assert.Equal(1.5F, processor.Amount);
}
[Fact]
public void Brightness_scaled_vector()
{
var rgbImage = new Image<Rgb24>(Configuration.Default, 100, 100, new Rgb24(0, 0, 0));
rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2)));
Assert.Equal(new Rgb24(0, 0, 0), rgbImage[0, 0]);
rgbImage = new Image<Rgb24>(Configuration.Default, 100, 100, new Rgb24(10, 10, 10));
rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2)));
Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]);
var halfSingleImage = new Image<HalfSingle>(Configuration.Default, 100, 100, new HalfSingle(-1));
halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2)));
Assert.Equal(new HalfSingle(-1), halfSingleImage[0, 0]);
halfSingleImage = new Image<HalfSingle>(Configuration.Default, 100, 100, new HalfSingle(-0.5f));
halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2)));
Assert.Equal(new HalfSingle(0), halfSingleImage[0, 0]);
}
}
}
}

Loading…
Cancel
Save