From d68519d1332717d4b11f7fb6d4f4326ac007ea5e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 10 Dec 2019 22:53:41 +1100 Subject: [PATCH] Alpha8 => A8 --- src/ImageSharp/Advanced/AotCompilerTools.cs | 2 +- .../PixelImplementations/{Alpha8.cs => A8.cs} | 44 ++++++++--------- .../BinaryErrorDiffusionProcessor{TPixel}.cs | 2 +- .../BinaryOrderedDitherProcessor{TPixel}.cs | 2 +- .../BinaryThresholdProcessor{TPixel}.cs | 2 +- .../Formats/Png/PngDecoderTests.cs | 6 +-- .../{Alpha8Tests.cs => A8Tests.cs} | 48 +++++++++---------- .../Transforms/TransformsHelpersTest.cs | 2 +- tests/ImageSharp.Tests/TestImages.cs | 4 +- .../TestUtilities/PixelTypes.cs | 2 +- .../TestUtilities/TestUtils.cs | 4 +- .../Tests/TestImageProviderTests.cs | 2 +- .../Tests/TestUtilityExtensionsTests.cs | 4 +- 13 files changed, 62 insertions(+), 62 deletions(-) rename src/ImageSharp/PixelFormats/PixelImplementations/{Alpha8.cs => A8.cs} (75%) rename tests/ImageSharp.Tests/PixelFormats/{Alpha8Tests.cs => A8Tests.cs} (61%) diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs index 5d172d93f7..63a44f7854 100644 --- a/src/ImageSharp/Advanced/AotCompilerTools.cs +++ b/src/ImageSharp/Advanced/AotCompilerTools.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Advanced /// private static void SeedEverything() { - Seed(); + Seed(); Seed(); Seed(); Seed(); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs similarity index 75% rename from src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/A8.cs index cd864b5455..bc6fd54fe8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -8,56 +8,56 @@ using System.Runtime.CompilerServices; namespace SixLabors.ImageSharp.PixelFormats { /// - /// Packed pixel type containing a single 8 bit normalized W values. + /// Packed pixel type containing a single 8 bit normalized alpha value. /// /// Ranges from [0, 0, 0, 0] to [0, 0, 0, 1] in vector form. /// /// - public struct Alpha8 : IPixel, IPackedVector + public struct A8 : IPixel, IPackedVector { /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The alpha component. - public Alpha8(byte alpha) => this.PackedValue = alpha; + public A8(byte alpha) => this.PackedValue = alpha; /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The alpha component. - public Alpha8(float alpha) => this.PackedValue = Pack(alpha); + public A8(float alpha) => this.PackedValue = Pack(alpha); /// public byte PackedValue { get; set; } /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// /// - /// The on the left side of the operand. + /// The on the left side of the operand. /// /// - /// The on the right side of the operand. + /// The on the right side of the operand. /// /// /// True if the parameter is equal to the parameter; otherwise, false. /// [MethodImpl(InliningOptions.ShortMethod)] - public static bool operator ==(Alpha8 left, Alpha8 right) => left.Equals(right); + public static bool operator ==(A8 left, A8 right) => left.Equals(right); /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is not equal to the parameter; otherwise, false. /// [MethodImpl(InliningOptions.ShortMethod)] - public static bool operator !=(Alpha8 left, Alpha8 right) => !left.Equals(right); + public static bool operator !=(A8 left, A8 right) => !left.Equals(right); /// - public PixelOperations CreatePixelOperations() => new PixelOperations(); + public PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -128,21 +128,21 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// The object to compare. /// True if the object is equal to the packed vector. - public override bool Equals(object obj) => obj is Alpha8 other && this.Equals(other); + public override bool Equals(object obj) => obj is A8 other && this.Equals(other); /// - /// Compares another Alpha8 packed vector with the packed vector. + /// Compares another A8 packed vector with the packed vector. /// - /// The Alpha8 packed vector to compare. + /// The A8 packed vector to compare. /// True if the packed vectors are equal. [MethodImpl(InliningOptions.ShortMethod)] - public bool Equals(Alpha8 other) => this.PackedValue.Equals(other.PackedValue); + public bool Equals(A8 other) => this.PackedValue.Equals(other.PackedValue); /// /// Gets a string representation of the packed vector. /// /// A string representation of the packed vector. - public override string ToString() => $"Alpha8({this.PackedValue})"; + public override string ToString() => $"A8({this.PackedValue})"; /// [MethodImpl(InliningOptions.ShortMethod)] @@ -156,4 +156,4 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] private static byte Pack(float alpha) => (byte)Math.Round(alpha.Clamp(0, 1F) * 255F); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs index 0124575488..c59e77b10c 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization IErrorDiffuser diffuser = this.definition.Diffuser; byte threshold = (byte)MathF.Round(this.definition.Threshold * 255F); - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs index e0aae0279f..d750c9f077 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization TPixel upperColor = this.definition.UpperColor.ToPixel(); TPixel lowerColor = this.definition.LowerColor.ToPixel(); - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index 7208fc3cd5..20a22fba3f 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization int startX = interest.X; int endX = interest.Right; - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index bdd84038e3..5ec621fa41 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png TestImages.Png.VimImage2, TestImages.Png.Rgb24BppTrans, - TestImages.Png.GrayAlpha8Bit, + TestImages.Png.GrayA8Bit, TestImages.Png.Gray1BitTrans, TestImages.Png.Bad.ZlibOverflow, TestImages.Png.Bad.ZlibOverflow2, @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png TestImages.Png.GrayAlpha1BitInterlaced, TestImages.Png.GrayAlpha2BitInterlaced, TestImages.Png.Gray4BitInterlaced, - TestImages.Png.GrayAlpha8BitInterlaced + TestImages.Png.GrayA8BitInterlaced }; public static readonly string[] TestImagesIssue1014 = @@ -180,7 +180,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png } [Theory] - [WithFile(TestImages.Png.GrayAlpha8BitInterlaced, PixelTypes)] + [WithFile(TestImages.Png.GrayA8BitInterlaced, PixelTypes)] public void Decoder_CanDecodeGrey8bitWithAlpha(TestImageProvider provider) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs similarity index 61% rename from tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs rename to tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index b6e87626b6..6b542badff 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -7,42 +7,42 @@ using Xunit; namespace SixLabors.ImageSharp.Tests.PixelFormats { - public class Alpha8Tests + public class A8Tests { [Fact] - public void Alpha8_Constructor() + public void A8_Constructor() { // Test the limits. - Assert.Equal(byte.MinValue, new Alpha8(0F).PackedValue); - Assert.Equal(byte.MaxValue, new Alpha8(1F).PackedValue); + Assert.Equal(byte.MinValue, new A8(0F).PackedValue); + Assert.Equal(byte.MaxValue, new A8(1F).PackedValue); // Test clamping. - Assert.Equal(byte.MinValue, new Alpha8(-1234F).PackedValue); - Assert.Equal(byte.MaxValue, new Alpha8(1234F).PackedValue); + Assert.Equal(byte.MinValue, new A8(-1234F).PackedValue); + Assert.Equal(byte.MaxValue, new A8(1234F).PackedValue); // Test ordering - Assert.Equal(124, new Alpha8(124F / byte.MaxValue).PackedValue); - Assert.Equal(26, new Alpha8(0.1F).PackedValue); + Assert.Equal(124, new A8(124F / byte.MaxValue).PackedValue); + Assert.Equal(26, new A8(0.1F).PackedValue); } [Fact] - public void Alpha8_Equality() + public void A8_Equality() { - var left = new Alpha8(16); - var right = new Alpha8(32); + var left = new A8(16); + var right = new A8(32); - Assert.True(left == new Alpha8(16)); + Assert.True(left == new A8(16)); Assert.True(left != right); - Assert.Equal(left, (object)new Alpha8(16)); + Assert.Equal(left, (object)new A8(16)); } [Fact] - public void Alpha8_FromScaledVector4() + public void A8_FromScaledVector4() { // Arrange - Alpha8 alpha = default; + A8 alpha = default; int expected = 128; - Vector4 scaled = new Alpha8(.5F).ToScaledVector4(); + Vector4 scaled = new A8(.5F).ToScaledVector4(); // Act alpha.FromScaledVector4(scaled); @@ -53,10 +53,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } [Fact] - public void Alpha8_ToScaledVector4() + public void A8_ToScaledVector4() { // Arrange - var alpha = new Alpha8(.5F); + var alpha = new A8(.5F); // Act Vector4 actual = alpha.ToScaledVector4(); @@ -69,10 +69,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } [Fact] - public void Alpha8_ToVector4() + public void A8_ToVector4() { // Arrange - var alpha = new Alpha8(.5F); + var alpha = new A8(.5F); // Act var actual = alpha.ToVector4(); @@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } [Fact] - public void Alpha8_ToRgba32() + public void A8_ToRgba32() { - var input = new Alpha8(128); + var input = new A8(128); var expected = new Rgba32(0, 0, 0, 128); Rgba32 actual = default; @@ -96,10 +96,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats } [Fact] - public void Alpha8_FromBgra5551() + public void A8_FromBgra5551() { // arrange - var alpha = default(Alpha8); + var alpha = default(A8); byte expected = byte.MaxValue; // act diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs index 3ac9af960b..19226b3071 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms { int xy = 1; - using (var img = new Image(xy, xy)) + using (var img = new Image(xy, xy)) { var profile = new ExifProfile(); img.Metadata.ExifProfile = profile; diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 8f1eca4829..8a29169a57 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -28,8 +28,8 @@ namespace SixLabors.ImageSharp.Tests public const string Bpp1 = "Png/bpp1.png"; public const string Gray4Bpp = "Png/gray_4bpp.png"; public const string Gray16Bit = "Png/gray-16.png"; - public const string GrayAlpha8Bit = "Png/gray-alpha-8.png"; - public const string GrayAlpha8BitInterlaced = "Png/rollsroyce.png"; + public const string GrayA8Bit = "Png/gray-alpha-8.png"; + public const string GrayA8BitInterlaced = "Png/rollsroyce.png"; public const string GrayAlpha1BitInterlaced = "Png/iftbbn0g01.png"; public const string GrayAlpha2BitInterlaced = "Png/iftbbn0g02.png"; public const string Gray4BitInterlaced = "Png/iftbbn0g04.png"; diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 78431f31aa..3a8b5765e0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests { Undefined = 0, - Alpha8 = 1 << 0, + A8 = 1 << 0, Argb32 = 1 << 1, diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index b56ce05171..a6ca008995 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -39,8 +39,8 @@ namespace SixLabors.ImageSharp.Tests ClrTypes2PixelTypes[defaultPixelFormatType] = PixelTypes.Rgba32; // Add PixelFormat types - string nameSpace = typeof(Alpha8).FullName; - nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Alpha8).Name.Length - 1); + string nameSpace = typeof(A8).FullName; + nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(A8).Name.Length - 1); foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.Rgba32)) { string typeName = $"{nameSpace}.{pt}"; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 738465a6ed..416f4034f4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Tests [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32, PixelTypes.Rgba32)] - [WithBlankImages(1, 1, PixelTypes.Alpha8, PixelTypes.Alpha8)] + [WithBlankImages(1, 1, PixelTypes.A8, PixelTypes.A8)] [WithBlankImages(1, 1, PixelTypes.Argb32, PixelTypes.Argb32)] public void PixelType_PropertyValueIsCorrect(TestImageProvider provider, PixelTypes expected) where TPixel : struct, IPixel => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 301d0cebe6..64b217a028 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -99,13 +99,13 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ExpandAllTypes_1() { - PixelTypes pixelTypes = PixelTypes.Alpha8 | PixelTypes.Bgr565 | PixelTypes.HalfVector2 | PixelTypes.Rgba32; + PixelTypes pixelTypes = PixelTypes.A8 | PixelTypes.Bgr565 | PixelTypes.HalfVector2 | PixelTypes.Rgba32; IEnumerable> expanded = pixelTypes.ExpandAllTypes(); Assert.Equal(4, expanded.Count()); - AssertContainsPixelType(PixelTypes.Alpha8, expanded); + AssertContainsPixelType(PixelTypes.A8, expanded); AssertContainsPixelType(PixelTypes.Bgr565, expanded); AssertContainsPixelType(PixelTypes.HalfVector2, expanded); AssertContainsPixelType(PixelTypes.Rgba32, expanded);