diff --git a/src/UglyToad.PdfPig/Geometry/GeometryExtensions.cs b/src/UglyToad.PdfPig/Geometry/GeometryExtensions.cs
index f3308d4c..cbec7502 100644
--- a/src/UglyToad.PdfPig/Geometry/GeometryExtensions.cs
+++ b/src/UglyToad.PdfPig/Geometry/GeometryExtensions.cs
@@ -169,7 +169,7 @@
if (A < Amin)
{
Amin = A;
- MBR = new[] { R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y };
+ MBR = [R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y];
}
}
diff --git a/src/UglyToad.PdfPig/Graphics/Colors/ColorSpaceDetails.cs b/src/UglyToad.PdfPig/Graphics/Colors/ColorSpaceDetails.cs
index fc767c24..75fb4d7d 100644
--- a/src/UglyToad.PdfPig/Graphics/Colors/ColorSpaceDetails.cs
+++ b/src/UglyToad.PdfPig/Graphics/Colors/ColorSpaceDetails.cs
@@ -538,7 +538,7 @@
for (var i = 0; i < decoded.Count; i += NumberOfColorComponents)
{
int key = 0;
- double[] comps = new double[NumberOfColorComponents];
+ var comps = new double[NumberOfColorComponents];
for (int n = 0; n < NumberOfColorComponents; n++)
{
byte b = decoded[i + n];
@@ -832,7 +832,7 @@
internal override double[] Process(params double[] values)
{
var (R, _, _) = colorSpaceTransformer.TransformToRGB((values[0], values[0], values[0]));
- return new double[] { R };
+ return [R];
}
///
@@ -1114,7 +1114,7 @@
double Z = WhitePoint[2] * g(N);
var (R, G, B) = colorSpaceTransformer.TransformToRGB((X, Y, Z));
- return new double[] { R, G, B };
+ return [R, G, B];
}
///
diff --git a/src/UglyToad.PdfPig/Images/Png/Adam7.cs b/src/UglyToad.PdfPig/Images/Png/Adam7.cs
index 49e46b07..0d4e5d45 100644
--- a/src/UglyToad.PdfPig/Images/Png/Adam7.cs
+++ b/src/UglyToad.PdfPig/Images/Png/Adam7.cs
@@ -9,24 +9,24 @@
///
private static readonly IReadOnlyDictionary PassToScanlineGridIndex = new Dictionary
{
- { 1, new []{ 0 } },
- { 2, new []{ 0 } },
- { 3, new []{ 4 } },
- { 4, new []{ 0, 4 } },
- { 5, new []{ 2, 6 } },
- { 6, new[] { 0, 2, 4, 6 } },
- { 7, new[] { 1, 3, 5, 7 } }
+ { 1, [0] },
+ { 2, [0] },
+ { 3, [4] },
+ { 4, [0, 4] },
+ { 5, [2, 6] },
+ { 6, [0, 2, 4, 6] },
+ { 7, [1, 3, 5, 7] }
};
private static readonly IReadOnlyDictionary PassToScanlineColumnIndex = new Dictionary
{
- { 1, new []{ 0 } },
- { 2, new []{ 4 } },
- { 3, new []{ 0, 4 } },
- { 4, new []{ 2, 6 } },
- { 5, new []{ 0, 2, 4, 6 } },
- { 6, new []{ 1, 3, 5, 7 } },
- { 7, new []{ 0, 1, 2, 3, 4, 5, 6, 7 } }
+ { 1, [0] },
+ { 2, [4] },
+ { 3, [0, 4] },
+ { 4, [2, 6] },
+ { 5, [0, 2, 4, 6] },
+ { 6, [1, 3, 5, 7] },
+ { 7, [0, 1, 2, 3, 4, 5, 6, 7] }
};
/*
diff --git a/src/UglyToad.PdfPig/Util/PatternParser.cs b/src/UglyToad.PdfPig/Util/PatternParser.cs
index 516da5e1..30d49de4 100644
--- a/src/UglyToad.PdfPig/Util/PatternParser.cs
+++ b/src/UglyToad.PdfPig/Util/PatternParser.cs
@@ -47,7 +47,7 @@
else
{
// optional - Default value: the identity matrix [1 0 0 1 0 0]
- matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 });
+ matrix = TransformationMatrix.FromArray([1, 0, 0, 1, 0, 0]);
}
DictionaryToken patternExtGState = null;
diff --git a/src/UglyToad.PdfPig/Util/ShadingParser.cs b/src/UglyToad.PdfPig/Util/ShadingParser.cs
index 5ffc5f0a..14803c7d 100644
--- a/src/UglyToad.PdfPig/Util/ShadingParser.cs
+++ b/src/UglyToad.PdfPig/Util/ShadingParser.cs
@@ -15,8 +15,8 @@
{
public static Shading Create(IToken shading, IPdfTokenScanner scanner, IResourceStore resourceStore, ILookupFilterProvider filterProvider)
{
- DictionaryToken shadingDictionary = null;
- StreamToken shadingStream = null;
+ DictionaryToken? shadingDictionary = null;
+ StreamToken? shadingStream = null;
if (shading is StreamToken fs)
{
@@ -28,8 +28,7 @@
shadingDictionary = fd;
}
- ShadingType shadingType;
- if (shadingDictionary.TryGet(NameToken.ShadingType, scanner, out var shadingTypeToken))
+ if (shadingDictionary.TryGet(NameToken.ShadingType, scanner, out ShadingType shadingTypeToken))
{
// Shading types 4 to 7 shall be defined by a stream containing descriptive data characterizing
// the shading's gradient fill.
@@ -140,7 +139,7 @@
else
{
// Optional - Default value: [0.0 1.0 0.0 1.0].
- domain = new double[] { 0.0, 1.0, 0.0, 1.0 };
+ domain = [0.0, 1.0, 0.0, 1.0];
}
TransformationMatrix matrix;
@@ -151,7 +150,7 @@
else
{
// Optional - Default value: the identity matrix [1 0 0 1 0 0]
- matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 });
+ matrix = TransformationMatrix.FromArray([1, 0, 0, 1, 0, 0]);
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@@ -185,7 +184,7 @@
else
{
// set default values
- domain = new double[] { 0, 1 };
+ domain = [0, 1];
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@@ -207,7 +206,7 @@
private static RadialShading CreateRadialShading(DictionaryToken shadingDictionary, ColorSpaceDetails colorSpace,
double[] background, PdfRectangle? bbox, bool antiAlias, IPdfTokenScanner scanner, ILookupFilterProvider filterProvider)
{
- double[] coords = null;
+ double[]? coords = null;
if (shadingDictionary.TryGet(NameToken.Coords, scanner, out var coordsToken))
{
coords = coordsToken.Data.OfType().Select(v => v.Double).ToArray();
@@ -225,7 +224,7 @@
else
{
// set default values
- domain = new double[] { 0, 1 };
+ domain = [0, 1];
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@@ -235,7 +234,7 @@
PdfFunction[] functions = GetFunctions(shadingDictionary.Data[NameToken.Function], scanner, filterProvider);
- bool[] extend = new bool[] { false, false }; // Default values
+ bool[] extend = [false, false]; // Default values
if (shadingDictionary.TryGet(NameToken.Extend, scanner, out var extendToken))
{
extend = extendToken.Data.OfType().Select(v => v.Data).ToArray();
@@ -287,7 +286,7 @@
throw new ArgumentNullException($"{NameToken.Decode} is required for shading type '{ShadingType.FreeFormGouraud}'.");
}
- PdfFunction[] functions = null; // Optional
+ PdfFunction[]? functions = null; // Optional
if (shadingStream.StreamDictionary.ContainsKey(NameToken.Function))
{
functions = GetFunctions(shadingStream.StreamDictionary.Data[NameToken.Function], scanner, filterProvider);