diff --git a/src/ImageSharp/Formats/Gif/GifColorTableMode.cs b/src/ImageSharp/Formats/Gif/GifColorTableMode.cs
deleted file mode 100644
index 0f65f46022..0000000000
--- a/src/ImageSharp/Formats/Gif/GifColorTableMode.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Six Labors.
-// Licensed under the Six Labors Split License.
-
-namespace SixLabors.ImageSharp.Formats.Gif;
-
-///
-/// Provides enumeration for the available color table modes.
-///
-public enum GifColorTableMode
-{
- ///
- /// A single color table is calculated from the first frame and reused for subsequent frames.
- ///
- Global,
-
- ///
- /// A unique color table is calculated for each frame.
- ///
- Local
-}
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index d64792eba7..a67ee8f982 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
@@ -696,14 +696,14 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
&& this.logicalScreenDescriptor.GlobalColorTableSize > 0)
{
GifFrameMetadata gifMeta = metadata.GetGifMetadata();
- gifMeta.ColorTableMode = GifColorTableMode.Global;
+ gifMeta.ColorTableMode = FrameColorTableMode.Global;
}
if (this.imageDescriptor.LocalColorTableFlag
&& this.imageDescriptor.LocalColorTableSize > 0)
{
GifFrameMetadata gifMeta = metadata.GetGifMetadata();
- gifMeta.ColorTableMode = GifColorTableMode.Local;
+ gifMeta.ColorTableMode = FrameColorTableMode.Local;
Color[] colorTable = new Color[this.imageDescriptor.LocalColorTableSize];
ReadOnlySpan rgbTable = MemoryMarshal.Cast(this.currentLocalColorTable!.GetSpan()[..this.currentLocalColorTableSize]);
@@ -766,8 +766,8 @@ internal sealed class GifDecoderCore : IImageDecoderInternals
this.metadata = meta;
this.gifMetadata = meta.GetGifMetadata();
this.gifMetadata.ColorTableMode = this.logicalScreenDescriptor.GlobalColorTableFlag
- ? GifColorTableMode.Global
- : GifColorTableMode.Local;
+ ? FrameColorTableMode.Global
+ : FrameColorTableMode.Local;
if (this.logicalScreenDescriptor.GlobalColorTableFlag)
{
diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs
index ab05548ac5..6cb8f9d8ce 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs
@@ -11,7 +11,7 @@ public sealed class GifEncoder : QuantizingImageEncoder
///
/// Gets the color table mode: Global or local.
///
- public GifColorTableMode? ColorTableMode { get; init; }
+ public FrameColorTableMode? ColorTableMode { get; init; }
///
protected override void Encode(Image image, Stream stream, CancellationToken cancellationToken)
diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
index 95429e6065..70afe12e10 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
@@ -49,7 +49,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
///
/// The color table mode: Global or local.
///
- private GifColorTableMode? colorTableMode;
+ private FrameColorTableMode? colorTableMode;
///
/// The pixel sampling strategy for global quantization.
@@ -87,7 +87,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
GifMetadata gifMetadata = GetGifMetadata(image);
this.colorTableMode ??= gifMetadata.ColorTableMode;
- bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;
+ bool useGlobalTable = this.colorTableMode == FrameColorTableMode.Global;
// Quantize the first image frame returning a palette.
IndexedImageFrame? quantized = null;
@@ -99,7 +99,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
if (this.quantizer is null)
{
// Is this a gif with color information. If so use that, otherwise use octree.
- if (gifMetadata.ColorTableMode == GifColorTableMode.Global && gifMetadata.GlobalColorTable?.Length > 0)
+ if (gifMetadata.ColorTableMode == FrameColorTableMode.Global && gifMetadata.GlobalColorTable?.Length > 0)
{
// We avoid dithering by default to preserve the original colors.
int transparencyIndex = GetTransparentIndex(quantized, frameMetadata);
@@ -221,7 +221,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
metadata = GifFrameMetadata.FromAnimatedMetadata(ani);
}
- if (metadata?.ColorTableMode == GifColorTableMode.Global && transparencyIndex > -1)
+ if (metadata?.ColorTableMode == FrameColorTableMode.Global && transparencyIndex > -1)
{
metadata.HasTransparency = true;
metadata.TransparencyIndex = ClampIndex(transparencyIndex);
@@ -258,7 +258,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
ImageFrame currentFrame = image.Frames[i];
ImageFrame? nextFrame = i < image.Frames.Count - 1 ? image.Frames[i + 1] : null;
GifFrameMetadata gifMetadata = GetGifFrameMetadata(currentFrame, globalTransparencyIndex);
- bool useLocal = this.colorTableMode == GifColorTableMode.Local || (gifMetadata.ColorTableMode == GifColorTableMode.Local);
+ bool useLocal = this.colorTableMode == FrameColorTableMode.Local || (gifMetadata.ColorTableMode == FrameColorTableMode.Local);
if (!useLocal && !hasPaletteQuantizer && i > 0)
{
@@ -301,7 +301,7 @@ internal sealed class GifEncoderCore : IImageEncoderInternals
Buffer2D indices = ((IPixelSource)quantized).PixelBuffer;
Rectangle interest = indices.FullRectangle();
- bool useLocal = this.colorTableMode == GifColorTableMode.Local || (metadata.ColorTableMode == GifColorTableMode.Local);
+ bool useLocal = this.colorTableMode == FrameColorTableMode.Local || (metadata.ColorTableMode == FrameColorTableMode.Local);
int bitDepth = ColorNumerics.GetBitsNeededForColorDepth(quantized.Palette.Length);
this.WriteImageDescriptor(interest, useLocal, bitDepth, stream);
diff --git a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs
index 6598def2a5..3f8563706d 100644
--- a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs
+++ b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs
@@ -40,7 +40,7 @@ public class GifFrameMetadata : IDeepCloneable
///
/// Gets or sets the color table mode.
///
- public GifColorTableMode ColorTableMode { get; set; }
+ public FrameColorTableMode ColorTableMode { get; set; }
///
/// Gets or sets the local color table, if any.
@@ -101,7 +101,7 @@ public class GifFrameMetadata : IDeepCloneable
return new()
{
LocalColorTable = metadata.ColorTable,
- ColorTableMode = metadata.ColorTableMode == FrameColorTableMode.Global ? GifColorTableMode.Global : GifColorTableMode.Local,
+ ColorTableMode = metadata.ColorTableMode,
FrameDelay = (int)Math.Round(metadata.Duration.TotalMilliseconds / 10),
DisposalMethod = GetMode(metadata.DisposalMode),
HasTransparency = hasTransparency,
diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs
index 7c83de9305..43935504b1 100644
--- a/src/ImageSharp/Formats/Gif/GifMetadata.cs
+++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Formats.Gif;
///
/// Provides Gif specific metadata information for the image.
///
-public class GifMetadata : IDeepCloneable
+public class GifMetadata : IFormatMetadata
{
///
/// Initializes a new instance of the class.
@@ -49,7 +49,7 @@ public class GifMetadata : IDeepCloneable
///
/// Gets or sets the color table mode.
///
- public GifColorTableMode ColorTableMode { get; set; }
+ public FrameColorTableMode ColorTableMode { get; set; }
///
/// Gets or sets the global color table, if any.
@@ -69,9 +69,6 @@ public class GifMetadata : IDeepCloneable
///
public IList Comments { get; set; } = [];
- ///
- public IDeepCloneable DeepClone() => new GifMetadata(this);
-
internal static GifMetadata FromAnimatedMetadata(AnimatedImageMetadata metadata)
{
int index = 0;
@@ -92,9 +89,64 @@ public class GifMetadata : IDeepCloneable
return new()
{
GlobalColorTable = metadata.ColorTable,
- ColorTableMode = metadata.ColorTableMode == FrameColorTableMode.Global ? GifColorTableMode.Global : GifColorTableMode.Local,
+ ColorTableMode = metadata.ColorTableMode,
+ RepeatCount = metadata.RepeatCount,
+ BackgroundColorIndex = (byte)Numerics.Clamp(index, 0, 255),
+ };
+ }
+
+ ///
+ public static GifMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata)
+ {
+ int index = 0;
+ Color background = metadata.BackgroundColor;
+ if (metadata.ColorTable.HasValue)
+ {
+ ReadOnlySpan colorTable = metadata.ColorTable.Value.Span;
+ for (int i = 0; i < colorTable.Length; i++)
+ {
+ if (background == colorTable[i])
+ {
+ index = i;
+ break;
+ }
+ }
+ }
+
+ return new()
+ {
+ GlobalColorTable = metadata.ColorTable,
+ ColorTableMode = metadata.ColorTableMode,
RepeatCount = metadata.RepeatCount,
BackgroundColorIndex = (byte)Numerics.Clamp(index, 0, 255),
};
}
+
+ ///
+ public FormatConnectingMetadata ToFormatConnectingMetadata()
+ {
+ Color color = this.GlobalColorTable.HasValue && this.GlobalColorTable.Value.Span.Length > this.BackgroundColorIndex
+ ? this.GlobalColorTable.Value.Span[this.BackgroundColorIndex]
+ : Color.Transparent;
+
+ return new()
+ {
+ AnimateRootFrame = true,
+ BackgroundColor = color,
+ ColorTable = this.GlobalColorTable,
+ ColorTableMode = this.ColorTableMode,
+ PixelTypeInfo = new PixelTypeInfo(24)
+ {
+ ColorType = PixelColorType.Indexed,
+ ComponentInfo = PixelComponentInfo.Create(3, 24, 8, 8, 8),
+ },
+ RepeatCount = this.RepeatCount,
+ };
+ }
+
+ ///
+ public IDeepCloneable DeepClone() => ((IDeepCloneable)this).DeepClone();
+
+ ///
+ GifMetadata IDeepCloneable.DeepClone() => new(this);
}
diff --git a/src/ImageSharp/Formats/Gif/MetadataExtensions.cs b/src/ImageSharp/Formats/Gif/MetadataExtensions.cs
index ad06462e77..d4650403cb 100644
--- a/src/ImageSharp/Formats/Gif/MetadataExtensions.cs
+++ b/src/ImageSharp/Formats/Gif/MetadataExtensions.cs
@@ -70,7 +70,7 @@ public static partial class MetadataExtensions
return new()
{
ColorTable = source.GlobalColorTable,
- ColorTableMode = source.ColorTableMode == GifColorTableMode.Global ? FrameColorTableMode.Global : FrameColorTableMode.Local,
+ ColorTableMode = source.ColorTableMode,
RepeatCount = source.RepeatCount,
BackgroundColor = background,
};
@@ -83,12 +83,12 @@ public static partial class MetadataExtensions
bool blendSource = source.DisposalMethod == GifDisposalMethod.RestoreToBackground || (source.LocalColorTable?.Length == 256 && !source.HasTransparency);
// If the color table is global and frame has no transparency. Consider it 'Source' also.
- blendSource |= source.ColorTableMode == GifColorTableMode.Global && !source.HasTransparency;
+ blendSource |= source.ColorTableMode == FrameColorTableMode.Global && !source.HasTransparency;
return new()
{
ColorTable = source.LocalColorTable,
- ColorTableMode = source.ColorTableMode == GifColorTableMode.Global ? FrameColorTableMode.Global : FrameColorTableMode.Local,
+ ColorTableMode = source.ColorTableMode,
Duration = TimeSpan.FromMilliseconds(source.FrameDelay * 10),
DisposalMode = GetMode(source.DisposalMethod),
BlendMode = blendSource ? FrameBlendMode.Source : FrameBlendMode.Over,
diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
index 6e8224f01e..36ce136f47 100644
--- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
@@ -1680,14 +1680,14 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
{
return info.ColorType switch
{
- PixelColorType.Grayscale => PngColorType.Grayscale,
+ PixelColorType.Luminance => PngColorType.Grayscale,
_ => PngColorType.Rgb,
};
}
return info.ColorType switch
{
- PixelColorType.Grayscale | PixelColorType.Alpha or PixelColorType.Alpha => PngColorType.GrayscaleWithAlpha,
+ PixelColorType.Luminance | PixelColorType.Alpha or PixelColorType.Alpha => PngColorType.GrayscaleWithAlpha,
_ => PngColorType.RgbWithAlpha,
};
}
diff --git a/src/ImageSharp/PixelFormats/PixelColorType.cs b/src/ImageSharp/PixelFormats/PixelColorType.cs
index 52d4df73a0..afbe6a4d3e 100644
--- a/src/ImageSharp/PixelFormats/PixelColorType.cs
+++ b/src/ImageSharp/PixelFormats/PixelColorType.cs
@@ -35,34 +35,39 @@ public enum PixelColorType
Alpha = 1 << 3,
///
- /// Indicates that the color is in grayscale.
+ /// Represents the Exponent component used in formats like R9G9B9E5.
///
- Grayscale = 1 << 4,
+ Exponent = 1 << 4,
///
- /// Indicates that the color is in RGB (Red, Green, Blue) format.
+ /// Indicates that the color is in luminance (grayscale) format.
///
- RGB = Red | Green | Blue | (1 << 5),
+ Luminance = 1 << 5,
///
- /// Indicates that the color is in BGR (Blue, Green, Red) format.
+ /// Indicates that the color is indexed using a palette.
+ ///
+ Indexed = 1 << 6,
+
+ ///
+ /// Indicates that the color is in RGB (Red, Green, Blue) format.
///
- BGR = Blue | Green | Red | (1 << 6),
+ RGB = Red | Green | Blue | (1 << 7),
///
- /// Represents the Luminance component in YCbCr.
+ /// Indicates that the color is in BGR (Blue, Green, Red) format.
///
- Luminance = 1 << 7,
+ BGR = Blue | Green | Red | (1 << 8),
///
/// Represents the Chrominance Blue component in YCbCr.
///
- ChrominanceBlue = 1 << 8,
+ ChrominanceBlue = 1 << 9,
///
/// Represents the Chrominance Red component in YCbCr.
///
- ChrominanceRed = 1 << 9,
+ ChrominanceRed = 1 << 10,
///
/// Indicates that the color is in YCbCr (Luminance, Chrominance Blue, Chrominance Red) format.
@@ -72,22 +77,22 @@ public enum PixelColorType
///
/// Represents the Cyan component in CMYK.
///
- Cyan = 1 << 10,
+ Cyan = 1 << 11,
///
/// Represents the Magenta component in CMYK.
///
- Magenta = 1 << 11,
+ Magenta = 1 << 12,
///
/// Represents the Yellow component in CMYK.
///
- Yellow = 1 << 12,
+ Yellow = 1 << 13,
///
/// Represents the Key (black) component in CMYK and YCCK.
///
- Key = 1 << 13,
+ Key = 1 << 14,
///
/// Indicates that the color is in CMYK (Cyan, Magenta, Yellow, Key) format.
@@ -99,13 +104,8 @@ public enum PixelColorType
///
YCCK = Luminance | ChrominanceBlue | ChrominanceRed | Key,
- ///
- /// Indicates that the color is indexed using a palette.
- ///
- Indexed = 1 << 14,
-
///
/// Indicates that the color is of a type not specified in this enum.
///
- Other = 1 << 15
+ Other = 1 << 16
}
diff --git a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs
index 64b233f357..1444b344b6 100644
--- a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs
+++ b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs
@@ -53,7 +53,7 @@ public readonly struct PixelComponentInfo
/// The component precision and index cannot exceed the component range.
public static PixelComponentInfo Create(int count, int bitsPerPixel, params int[] precision)
{
- if (precision.Length != count || precision.Length > 16)
+ if (precision.Length < count || precision.Length > 16)
{
throw new ArgumentOutOfRangeException(nameof(count), $"Count {count} must match the length of precision array and cannot exceed 16.");
}
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
index 2b5241b0bc..64a22060c0 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
@@ -71,7 +71,7 @@ public partial struct L16 : IPixel, IPackedVector
public static PixelTypeInfo GetPixelTypeInfo()
=> PixelTypeInfo.Create(
PixelComponentInfo.Create(1, 16),
- PixelColorType.Grayscale,
+ PixelColorType.Luminance,
PixelAlphaRepresentation.None);
///
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
index 5d733bdbb3..cf8646cfa0 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
@@ -73,7 +73,7 @@ public partial struct L8 : IPixel, IPackedVector
public static PixelTypeInfo GetPixelTypeInfo()
=> PixelTypeInfo.Create(
PixelComponentInfo.Create(1, 8),
- PixelColorType.Grayscale,
+ PixelColorType.Luminance,
PixelAlphaRepresentation.None);
///
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
index 69ca662187..026d0c299d 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
@@ -100,7 +100,7 @@ public partial struct La16 : IPixel, IPackedVector
public static PixelTypeInfo GetPixelTypeInfo()
=> PixelTypeInfo.Create(
PixelComponentInfo.Create(2, 8, 8),
- PixelColorType.Grayscale | PixelColorType.Alpha,
+ PixelColorType.Luminance | PixelColorType.Alpha,
PixelAlphaRepresentation.Unassociated);
///
diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
index 1886ef39a1..0ddcf16a1f 100644
--- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
+++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
@@ -97,7 +97,7 @@ public partial struct La32 : IPixel, IPackedVector
public static PixelTypeInfo GetPixelTypeInfo()
=> PixelTypeInfo.Create(
PixelComponentInfo.Create(2, 16, 16),
- PixelColorType.Grayscale | PixelColorType.Alpha,
+ PixelColorType.Luminance | PixelColorType.Alpha,
PixelAlphaRepresentation.Unassociated);
///
diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
index a7e16f7737..767141f56a 100644
--- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
+using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Webp;
@@ -113,7 +114,7 @@ public class GifEncoderTests
using Image image = provider.GetImage();
GifEncoder encoder = new()
{
- ColorTableMode = GifColorTableMode.Global,
+ ColorTableMode = FrameColorTableMode.Global,
Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null })
};
@@ -122,7 +123,7 @@ public class GifEncoderTests
encoder = new()
{
- ColorTableMode = GifColorTableMode.Local,
+ ColorTableMode = FrameColorTableMode.Local,
Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }),
};
@@ -148,7 +149,7 @@ public class GifEncoderTests
GifEncoder encoder = new()
{
- ColorTableMode = GifColorTableMode.Global,
+ ColorTableMode = FrameColorTableMode.Global,
PixelSamplingStrategy = new DefaultPixelSamplingStrategy(maxPixels, scanRatio)
};
@@ -175,10 +176,10 @@ public class GifEncoderTests
Image image = Image.Load(inStream);
GifMetadata metaData = image.Metadata.GetGifMetadata();
GifFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetGifMetadata();
- GifColorTableMode colorMode = metaData.ColorTableMode;
+ FrameColorTableMode colorMode = metaData.ColorTableMode;
int maxColors;
- if (colorMode == GifColorTableMode.Global)
+ if (colorMode == FrameColorTableMode.Global)
{
maxColors = metaData.GlobalColorTable.Value.Length;
}
@@ -204,7 +205,7 @@ public class GifEncoderTests
// Gifiddle and Cyotek GifInfo say this image has 64 colors.
colorMode = cloneMetadata.ColorTableMode;
- if (colorMode == GifColorTableMode.Global)
+ if (colorMode == FrameColorTableMode.Global)
{
maxColors = metaData.GlobalColorTable.Value.Length;
}
@@ -220,7 +221,7 @@ public class GifEncoderTests
GifFrameMetadata iMeta = image.Frames[i].Metadata.GetGifMetadata();
GifFrameMetadata cMeta = clone.Frames[i].Metadata.GetGifMetadata();
- if (iMeta.ColorTableMode == GifColorTableMode.Local)
+ if (iMeta.ColorTableMode == FrameColorTableMode.Local)
{
Assert.Equal(iMeta.LocalColorTable.Value.Length, cMeta.LocalColorTable.Value.Length);
}
diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs
index fb4445cdac..c7babe9322 100644
--- a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs
@@ -33,7 +33,7 @@ public class GifMetadataTests
GifMetadata meta = new()
{
RepeatCount = 1,
- ColorTableMode = GifColorTableMode.Global,
+ ColorTableMode = FrameColorTableMode.Global,
GlobalColorTable = new[] { Color.Black, Color.White },
Comments = new List { "Foo" }
};
@@ -41,7 +41,7 @@ public class GifMetadataTests
GifMetadata clone = (GifMetadata)meta.DeepClone();
clone.RepeatCount = 2;
- clone.ColorTableMode = GifColorTableMode.Local;
+ clone.ColorTableMode = FrameColorTableMode.Local;
clone.GlobalColorTable = new[] { Color.Black };
Assert.False(meta.RepeatCount.Equals(clone.RepeatCount));
@@ -183,11 +183,11 @@ public class GifMetadataTests
}
[Theory]
- [InlineData(TestImages.Gif.Cheers, 93, GifColorTableMode.Global, 256, 4, GifDisposalMethod.NotDispose)]
+ [InlineData(TestImages.Gif.Cheers, 93, FrameColorTableMode.Global, 256, 4, GifDisposalMethod.NotDispose)]
public void Identify_Frames(
string imagePath,
int framesCount,
- GifColorTableMode colorTableMode,
+ FrameColorTableMode colorTableMode,
int globalColorTableLength,
int frameDelay,
GifDisposalMethod disposalMethod)
@@ -206,7 +206,7 @@ public class GifMetadataTests
Assert.Equal(colorTableMode, gifFrameMetadata.ColorTableMode);
- if (colorTableMode == GifColorTableMode.Global)
+ if (colorTableMode == FrameColorTableMode.Global)
{
Assert.Equal(globalColorTableLength, gifMetadata.GlobalColorTable.Value.Length);
}
diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs
index a42dcc4812..572c5b2ebd 100644
--- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs
+++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
+using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.PixelFormats;
@@ -315,7 +316,7 @@ public abstract partial class ImageFrameCollectionTests
Assert.Equal(aData.DisposalMethod, bData.DisposalMethod);
Assert.Equal(aData.FrameDelay, bData.FrameDelay);
- if (aData.ColorTableMode == GifColorTableMode.Local && bData.ColorTableMode == GifColorTableMode.Local)
+ if (aData.ColorTableMode == FrameColorTableMode.Local && bData.ColorTableMode == FrameColorTableMode.Local)
{
Assert.Equal(aData.LocalColorTable.Value.Length, bData.LocalColorTable.Value.Length);
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs
index 2ddf1accb6..7f0a4217c1 100644
--- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs
@@ -161,7 +161,7 @@ public class L16Tests
PixelTypeInfo info = L16.GetPixelTypeInfo();
Assert.Equal(Unsafe.SizeOf() * 8, info.BitsPerPixel);
Assert.Equal(PixelAlphaRepresentation.None, info.AlphaRepresentation);
- Assert.Equal(PixelColorType.Grayscale, info.ColorType);
+ Assert.Equal(PixelColorType.Luminance, info.ColorType);
PixelComponentInfo componentInfo = info.ComponentInfo.Value;
Assert.Equal(1, componentInfo.ComponentCount);
diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
index 40c746cf21..1ca865ef41 100644
--- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
@@ -245,7 +245,7 @@ public class L8Tests
PixelTypeInfo info = L8.GetPixelTypeInfo();
Assert.Equal(Unsafe.SizeOf() * 8, info.BitsPerPixel);
Assert.Equal(PixelAlphaRepresentation.None, info.AlphaRepresentation);
- Assert.Equal(PixelColorType.Grayscale, info.ColorType);
+ Assert.Equal(PixelColorType.Luminance, info.ColorType);
PixelComponentInfo componentInfo = info.ComponentInfo.Value;
Assert.Equal(1, componentInfo.ComponentCount);
diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
index a18b31f6ba..f6cbfc4426 100644
--- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
@@ -248,7 +248,7 @@ public class La16Tests
PixelTypeInfo info = La16.GetPixelTypeInfo();
Assert.Equal(Unsafe.SizeOf() * 8, info.BitsPerPixel);
Assert.Equal(PixelAlphaRepresentation.Unassociated, info.AlphaRepresentation);
- Assert.Equal(PixelColorType.Grayscale | PixelColorType.Alpha, info.ColorType);
+ Assert.Equal(PixelColorType.Luminance | PixelColorType.Alpha, info.ColorType);
PixelComponentInfo componentInfo = info.ComponentInfo.Value;
Assert.Equal(2, componentInfo.ComponentCount);
diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs
index 3c702419d3..fd5556d3bc 100644
--- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs
@@ -167,7 +167,7 @@ public class La32Tests
PixelTypeInfo info = La32.GetPixelTypeInfo();
Assert.Equal(Unsafe.SizeOf() * 8, info.BitsPerPixel);
Assert.Equal(PixelAlphaRepresentation.Unassociated, info.AlphaRepresentation);
- Assert.Equal(PixelColorType.Grayscale | PixelColorType.Alpha, info.ColorType);
+ Assert.Equal(PixelColorType.Luminance | PixelColorType.Alpha, info.ColorType);
PixelComponentInfo componentInfo = info.ComponentInfo.Value;
Assert.Equal(2, componentInfo.ComponentCount);
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelColorTypeTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelColorTypeTests.cs
index 09e84d53be..c427130054 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelColorTypeTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelColorTypeTests.cs
@@ -36,10 +36,24 @@ public class PixelColorTypeTests
}
[Fact]
- public void PixelColorType_GrayscaleFlag_ShouldBeSet()
+ public void PixelColorType_Exponent_ShouldBeSet()
{
- const PixelColorType colorType = PixelColorType.Grayscale;
- Assert.True(colorType.HasFlag(PixelColorType.Grayscale));
+ const PixelColorType colorType = PixelColorType.Exponent;
+ Assert.True(colorType.HasFlag(PixelColorType.Exponent));
+ }
+
+ [Fact]
+ public void PixelColorType_LuminanceFlag_ShouldBeSet()
+ {
+ const PixelColorType colorType = PixelColorType.Luminance;
+ Assert.True(colorType.HasFlag(PixelColorType.Luminance));
+ }
+
+ [Fact]
+ public void PixelColorType_Indexed_ShouldBeSet()
+ {
+ const PixelColorType colorType = PixelColorType.Indexed;
+ Assert.True(colorType.HasFlag(PixelColorType.Indexed));
}
[Fact]
@@ -62,13 +76,6 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.RGB));
}
- [Fact]
- public void PixelColorType_LuminanceFlag_ShouldBeSet()
- {
- const PixelColorType colorType = PixelColorType.Luminance;
- Assert.True(colorType.HasFlag(PixelColorType.Luminance));
- }
-
[Fact]
public void PixelColorType_ChrominanceBlueFlag_ShouldBeSet()
{
@@ -140,13 +147,6 @@ public class PixelColorTypeTests
Assert.True(colorType.HasFlag(PixelColorType.Key));
}
- [Fact]
- public void PixelColorType_Indexed_ShouldBeSet()
- {
- const PixelColorType colorType = PixelColorType.Indexed;
- Assert.True(colorType.HasFlag(PixelColorType.Indexed));
- }
-
[Fact]
public void PixelColorType_Other_ShouldBeSet()
{
@@ -165,15 +165,16 @@ public class PixelColorTypeTests
public void PixelColorType_RGB_ShouldNotContainOtherFlags()
{
const PixelColorType colorType = PixelColorType.RGB;
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Alpha));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
Assert.False(colorType.HasFlag(PixelColorType.Luminance));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceBlue));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceRed));
Assert.False(colorType.HasFlag(PixelColorType.Cyan));
Assert.False(colorType.HasFlag(PixelColorType.Magenta));
Assert.False(colorType.HasFlag(PixelColorType.Yellow));
Assert.False(colorType.HasFlag(PixelColorType.Key));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Other));
}
@@ -181,15 +182,16 @@ public class PixelColorTypeTests
public void PixelColorType_BGR_ShouldNotContainOtherFlags()
{
const PixelColorType colorType = PixelColorType.BGR;
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Alpha));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
Assert.False(colorType.HasFlag(PixelColorType.Luminance));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceBlue));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceRed));
Assert.False(colorType.HasFlag(PixelColorType.Cyan));
Assert.False(colorType.HasFlag(PixelColorType.Magenta));
Assert.False(colorType.HasFlag(PixelColorType.Yellow));
Assert.False(colorType.HasFlag(PixelColorType.Key));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Other));
}
@@ -201,12 +203,12 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Green));
Assert.False(colorType.HasFlag(PixelColorType.Blue));
Assert.False(colorType.HasFlag(PixelColorType.Alpha));
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Cyan));
Assert.False(colorType.HasFlag(PixelColorType.Magenta));
Assert.False(colorType.HasFlag(PixelColorType.Yellow));
Assert.False(colorType.HasFlag(PixelColorType.Key));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Other));
}
@@ -218,11 +220,11 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Green));
Assert.False(colorType.HasFlag(PixelColorType.Blue));
Assert.False(colorType.HasFlag(PixelColorType.Alpha));
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
Assert.False(colorType.HasFlag(PixelColorType.Luminance));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceBlue));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceRed));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Other));
}
@@ -234,11 +236,11 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Green));
Assert.False(colorType.HasFlag(PixelColorType.Blue));
Assert.False(colorType.HasFlag(PixelColorType.Alpha));
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Cyan));
Assert.False(colorType.HasFlag(PixelColorType.Magenta));
Assert.False(colorType.HasFlag(PixelColorType.Yellow));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.Other));
}
@@ -250,10 +252,10 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Green));
Assert.False(colorType.HasFlag(PixelColorType.Blue));
Assert.False(colorType.HasFlag(PixelColorType.Alpha));
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
+ Assert.False(colorType.HasFlag(PixelColorType.Luminance));
Assert.False(colorType.HasFlag(PixelColorType.RGB));
Assert.False(colorType.HasFlag(PixelColorType.BGR));
- Assert.False(colorType.HasFlag(PixelColorType.Luminance));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceBlue));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceRed));
Assert.False(colorType.HasFlag(PixelColorType.YCbCr));
@@ -274,10 +276,11 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Green));
Assert.False(colorType.HasFlag(PixelColorType.Blue));
Assert.False(colorType.HasFlag(PixelColorType.Alpha));
- Assert.False(colorType.HasFlag(PixelColorType.Grayscale));
+ Assert.False(colorType.HasFlag(PixelColorType.Exponent));
+ Assert.False(colorType.HasFlag(PixelColorType.Luminance));
+ Assert.False(colorType.HasFlag(PixelColorType.Indexed));
Assert.False(colorType.HasFlag(PixelColorType.RGB));
Assert.False(colorType.HasFlag(PixelColorType.BGR));
- Assert.False(colorType.HasFlag(PixelColorType.Luminance));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceBlue));
Assert.False(colorType.HasFlag(PixelColorType.ChrominanceRed));
Assert.False(colorType.HasFlag(PixelColorType.YCbCr));
@@ -287,6 +290,5 @@ public class PixelColorTypeTests
Assert.False(colorType.HasFlag(PixelColorType.Key));
Assert.False(colorType.HasFlag(PixelColorType.CMYK));
Assert.False(colorType.HasFlag(PixelColorType.YCCK));
- Assert.False(colorType.HasFlag(PixelColorType.Indexed));
}
}