mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-07-15 16:17:57 +08:00
Use collection expressions
This commit is contained in:
parent
524b235502
commit
d19e6ad510
@ -169,7 +169,7 @@
|
|||||||
if (A < Amin)
|
if (A < Amin)
|
||||||
{
|
{
|
||||||
Amin = A;
|
Amin = A;
|
||||||
MBR = new[] { R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y };
|
MBR = [R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@
|
|||||||
for (var i = 0; i < decoded.Count; i += NumberOfColorComponents)
|
for (var i = 0; i < decoded.Count; i += NumberOfColorComponents)
|
||||||
{
|
{
|
||||||
int key = 0;
|
int key = 0;
|
||||||
double[] comps = new double[NumberOfColorComponents];
|
var comps = new double[NumberOfColorComponents];
|
||||||
for (int n = 0; n < NumberOfColorComponents; n++)
|
for (int n = 0; n < NumberOfColorComponents; n++)
|
||||||
{
|
{
|
||||||
byte b = decoded[i + n];
|
byte b = decoded[i + n];
|
||||||
@ -832,7 +832,7 @@
|
|||||||
internal override double[] Process(params double[] values)
|
internal override double[] Process(params double[] values)
|
||||||
{
|
{
|
||||||
var (R, _, _) = colorSpaceTransformer.TransformToRGB((values[0], values[0], values[0]));
|
var (R, _, _) = colorSpaceTransformer.TransformToRGB((values[0], values[0], values[0]));
|
||||||
return new double[] { R };
|
return [R];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@ -1114,7 +1114,7 @@
|
|||||||
double Z = WhitePoint[2] * g(N);
|
double Z = WhitePoint[2] * g(N);
|
||||||
|
|
||||||
var (R, G, B) = colorSpaceTransformer.TransformToRGB((X, Y, Z));
|
var (R, G, B) = colorSpaceTransformer.TransformToRGB((X, Y, Z));
|
||||||
return new double[] { R, G, B };
|
return [R, G, B];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
@ -9,24 +9,24 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineGridIndex = new Dictionary<int, int[]>
|
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineGridIndex = new Dictionary<int, int[]>
|
||||||
{
|
{
|
||||||
{ 1, new []{ 0 } },
|
{ 1, [0] },
|
||||||
{ 2, new []{ 0 } },
|
{ 2, [0] },
|
||||||
{ 3, new []{ 4 } },
|
{ 3, [4] },
|
||||||
{ 4, new []{ 0, 4 } },
|
{ 4, [0, 4] },
|
||||||
{ 5, new []{ 2, 6 } },
|
{ 5, [2, 6] },
|
||||||
{ 6, new[] { 0, 2, 4, 6 } },
|
{ 6, [0, 2, 4, 6] },
|
||||||
{ 7, new[] { 1, 3, 5, 7 } }
|
{ 7, [1, 3, 5, 7] }
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineColumnIndex = new Dictionary<int, int[]>
|
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineColumnIndex = new Dictionary<int, int[]>
|
||||||
{
|
{
|
||||||
{ 1, new []{ 0 } },
|
{ 1, [0] },
|
||||||
{ 2, new []{ 4 } },
|
{ 2, [4] },
|
||||||
{ 3, new []{ 0, 4 } },
|
{ 3, [0, 4] },
|
||||||
{ 4, new []{ 2, 6 } },
|
{ 4, [2, 6] },
|
||||||
{ 5, new []{ 0, 2, 4, 6 } },
|
{ 5, [0, 2, 4, 6] },
|
||||||
{ 6, new []{ 1, 3, 5, 7 } },
|
{ 6, [1, 3, 5, 7] },
|
||||||
{ 7, new []{ 0, 1, 2, 3, 4, 5, 6, 7 } }
|
{ 7, [0, 1, 2, 3, 4, 5, 6, 7] }
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// optional - Default value: the identity matrix [1 0 0 1 0 0]
|
// 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;
|
DictionaryToken patternExtGState = null;
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
{
|
{
|
||||||
public static Shading Create(IToken shading, IPdfTokenScanner scanner, IResourceStore resourceStore, ILookupFilterProvider filterProvider)
|
public static Shading Create(IToken shading, IPdfTokenScanner scanner, IResourceStore resourceStore, ILookupFilterProvider filterProvider)
|
||||||
{
|
{
|
||||||
DictionaryToken shadingDictionary = null;
|
DictionaryToken? shadingDictionary = null;
|
||||||
StreamToken shadingStream = null;
|
StreamToken? shadingStream = null;
|
||||||
|
|
||||||
if (shading is StreamToken fs)
|
if (shading is StreamToken fs)
|
||||||
{
|
{
|
||||||
@ -28,8 +28,7 @@
|
|||||||
shadingDictionary = fd;
|
shadingDictionary = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadingType shadingType;
|
if (shadingDictionary.TryGet<NumericToken>(NameToken.ShadingType, scanner, out ShadingType shadingTypeToken))
|
||||||
if (shadingDictionary.TryGet<NumericToken>(NameToken.ShadingType, scanner, out var shadingTypeToken))
|
|
||||||
{
|
{
|
||||||
// Shading types 4 to 7 shall be defined by a stream containing descriptive data characterizing
|
// Shading types 4 to 7 shall be defined by a stream containing descriptive data characterizing
|
||||||
// the shading's gradient fill.
|
// the shading's gradient fill.
|
||||||
@ -140,7 +139,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Optional - Default value: [0.0 1.0 0.0 1.0].
|
// 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;
|
TransformationMatrix matrix;
|
||||||
@ -151,7 +150,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Optional - Default value: the identity matrix [1 0 0 1 0 0]
|
// 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))
|
if (!shadingDictionary.ContainsKey(NameToken.Function))
|
||||||
@ -185,7 +184,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set default values
|
// set default values
|
||||||
domain = new double[] { 0, 1 };
|
domain = [0, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shadingDictionary.ContainsKey(NameToken.Function))
|
if (!shadingDictionary.ContainsKey(NameToken.Function))
|
||||||
@ -207,7 +206,7 @@
|
|||||||
private static RadialShading CreateRadialShading(DictionaryToken shadingDictionary, ColorSpaceDetails colorSpace,
|
private static RadialShading CreateRadialShading(DictionaryToken shadingDictionary, ColorSpaceDetails colorSpace,
|
||||||
double[] background, PdfRectangle? bbox, bool antiAlias, IPdfTokenScanner scanner, ILookupFilterProvider filterProvider)
|
double[] background, PdfRectangle? bbox, bool antiAlias, IPdfTokenScanner scanner, ILookupFilterProvider filterProvider)
|
||||||
{
|
{
|
||||||
double[] coords = null;
|
double[]? coords = null;
|
||||||
if (shadingDictionary.TryGet<ArrayToken>(NameToken.Coords, scanner, out var coordsToken))
|
if (shadingDictionary.TryGet<ArrayToken>(NameToken.Coords, scanner, out var coordsToken))
|
||||||
{
|
{
|
||||||
coords = coordsToken.Data.OfType<NumericToken>().Select(v => v.Double).ToArray();
|
coords = coordsToken.Data.OfType<NumericToken>().Select(v => v.Double).ToArray();
|
||||||
@ -225,7 +224,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set default values
|
// set default values
|
||||||
domain = new double[] { 0, 1 };
|
domain = [0, 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shadingDictionary.ContainsKey(NameToken.Function))
|
if (!shadingDictionary.ContainsKey(NameToken.Function))
|
||||||
@ -235,7 +234,7 @@
|
|||||||
|
|
||||||
PdfFunction[] functions = GetFunctions(shadingDictionary.Data[NameToken.Function], scanner, filterProvider);
|
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<ArrayToken>(NameToken.Extend, scanner, out var extendToken))
|
if (shadingDictionary.TryGet<ArrayToken>(NameToken.Extend, scanner, out var extendToken))
|
||||||
{
|
{
|
||||||
extend = extendToken.Data.OfType<BooleanToken>().Select(v => v.Data).ToArray();
|
extend = extendToken.Data.OfType<BooleanToken>().Select(v => v.Data).ToArray();
|
||||||
@ -287,7 +286,7 @@
|
|||||||
throw new ArgumentNullException($"{NameToken.Decode} is required for shading type '{ShadingType.FreeFormGouraud}'.");
|
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))
|
if (shadingStream.StreamDictionary.ContainsKey(NameToken.Function))
|
||||||
{
|
{
|
||||||
functions = GetFunctions(shadingStream.StreamDictionary.Data[NameToken.Function], scanner, filterProvider);
|
functions = GetFunctions(shadingStream.StreamDictionary.Data[NameToken.Function], scanner, filterProvider);
|
||||||
|
Loading…
Reference in New Issue
Block a user