Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator
private readonly TrcCalculator calculator;

public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs)
=> this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs);
=> this.calculator = new TrcCalculator([grayTrc], !toPcs);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value);
Expand Down
2 changes: 2 additions & 0 deletions src/ImageSharp/Common/Helpers/SimdUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ private static void DebugVerifySpanInput(ReadOnlySpan<float> source, Span<byte>

private struct ByteTuple4
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public byte V0;
public byte V1;
public byte V2;
public byte V3;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}
}
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Ani/AniDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, Cance
cancellationToken.ThrowIfCancellationRequested();

Image<TPixel> resource = DecodeFrame<TPixel>(format, frameOptions, frameStream, cancellationToken);
this.Dimensions = new(Math.Max(this.Dimensions.Width, resource.Width), Math.Max(this.Dimensions.Height, resource.Height));
this.Dimensions = new Size(Math.Max(this.Dimensions.Width, resource.Width), Math.Max(this.Dimensions.Height, resource.Height));

return resource;
});
Expand Down Expand Up @@ -165,7 +165,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok
cancellationToken.ThrowIfCancellationRequested();

ImageInfo info = IdentifyFrame(format, frameOptions, frameStream, cancellationToken);
this.Dimensions = new(Math.Max(this.Dimensions.Width, info.Width), Math.Max(this.Dimensions.Height, info.Height));
this.Dimensions = new Size(Math.Max(this.Dimensions.Width, info.Width), Math.Max(this.Dimensions.Height, info.Height));

return info;
});
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Bmp/BmpFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ private BmpFormat()
public IEnumerable<string> FileExtensions => BmpConstants.FileExtensions;

/// <inheritdoc/>
public BmpMetadata CreateDefaultFormatMetadata() => new BmpMetadata();
public BmpMetadata CreateDefaultFormatMetadata() => new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ZipExrCompressor(Stream output, MemoryAllocator allocator, uint bytesPerB
{
this.compressionLevel = compressionLevel;
this.buffer = allocator.Allocate<byte>((int)bytesPerBlock);
this.memoryStream = new();
this.memoryStream = new MemoryStream();
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Exr/ExrMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public FormatConnectingMetadata ToFormatConnectingMetadata()
? EncodingType.Lossy
: EncodingType.Lossless;

return new()
return new FormatConnectingMetadata
{
EncodingType = type,
PixelTypeInfo = this.GetPixelTypeInfo()
Expand Down Expand Up @@ -136,7 +136,7 @@ or PixelColorType.BGR | PixelColorType.Alpha
}
};

return new()
return new ExrMetadata
{
PixelType = bitsPerComponent <= 16 ? ExrPixelType.Half : ExrPixelType.Float,
ImageDataType = imageDataType,
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Icon/IconDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, Cance
decodedEntries[decodedCount++] = (entryIndex, decoded, compression);

// The embedded header is authoritative because a zero directory dimension can represent 256 pixels or a larger Vista-era PNG.
this.Dimensions = new(Math.Max(this.Dimensions.Width, decoded.Width), Math.Max(this.Dimensions.Height, decoded.Height));
this.Dimensions = new Size(Math.Max(this.Dimensions.Width, decoded.Width), Math.Max(this.Dimensions.Height, decoded.Height));
});
}

Expand Down Expand Up @@ -233,7 +233,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok
frames[frameCount++] = frameMetadata;

// Identification uses the same embedded-header dimensions as decoding, without allocating pixel buffers.
this.Dimensions = new(Math.Max(this.Dimensions.Width, frameInfo.Width), Math.Max(this.Dimensions.Height, frameInfo.Height));
this.Dimensions = new Size(Math.Max(this.Dimensions.Width, frameInfo.Width), Math.Max(this.Dimensions.Height, frameInfo.Height));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/ImageDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ protected bool TryConvertIccProfile<TPixel>(ImageFrame<TPixel> frame)
// and Wrap(Memory<T>[]) creates a Consumed MemoryGroup that does not own the buffers (Dispose just
// invalidates the view). This means no pixel data is cloned and disposing the temporary image will
// not dispose or leak the frame's pixel buffer.
MemoryGroup<TPixel> memorySource = MemoryGroup<TPixel>.Wrap(m.ToArray());
MemoryGroup<TPixel> memorySource = MemoryGroup<TPixel>.Wrap([.. m]);

using Image<TPixel> image = new(frame.Configuration, memorySource, frame.Width, frame.Height, metadata);
converter.Convert(image);
Expand Down
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/ImageFormatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public class ImageFormatManager
/// <summary>
/// The list of supported <see cref="IImageFormat"/>s.
/// </summary>
private readonly HashSet<IImageFormat> imageFormats = new();
private readonly HashSet<IImageFormat> imageFormats = [];

/// <summary>
/// The list of supported <see cref="IImageFormatDetector"/>s.
/// </summary>
private ConcurrentBag<IImageFormatDetector> imageFormatDetectors = new();
private ConcurrentBag<IImageFormatDetector> imageFormatDetectors = [];

/// <summary>
/// Initializes a new instance of the <see cref="ImageFormatManager" /> class.
Expand Down Expand Up @@ -161,7 +161,7 @@ public void SetDecoder(IImageFormat imageFormat, IImageDecoder decoder)
/// <summary>
/// Removes all the registered image format detectors.
/// </summary>
public void ClearImageFormatDetectors() => this.imageFormatDetectors = new ConcurrentBag<IImageFormatDetector>();
public void ClearImageFormatDetectors() => this.imageFormatDetectors = [];

/// <summary>
/// Adds a new detector for detecting mime types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,49 +119,49 @@ private static JpegColorConverterBase[] CreateConverters()
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<YCbCrOperator> GetYCbCrConverter(int precision)
=> new JpegColorConverter<YCbCrOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/>s for the YccK colorspace.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<YccKOperator> GetYccKConverter(int precision)
=> new JpegColorConverter<YccKOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/>s for the CMYK colorspace.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<CmykOperator> GetCmykConverter(int precision)
=> new JpegColorConverter<CmykOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/>s for the gray scale colorspace.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<GrayScaleOperator> GetGrayScaleConverter(int precision)
=> new JpegColorConverter<GrayScaleOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/>s for the RGB colorspace.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<RgbOperator> GetRgbConverter(int precision)
=> new JpegColorConverter<RgbOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/> for non-inverted TIFF CMYK.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<TiffCmykOperator> GetTiffCmykConverter(int precision)
=> new JpegColorConverter<TiffCmykOperator>(precision);
=> new(precision);

/// <summary>
/// Returns the <see cref="JpegColorConverterBase"/> for non-inverted TIFF YccK.
/// </summary>
/// <param name="precision">The precision in bits.</param>
private static JpegColorConverter<TiffYccKOperator> GetTiffYccKConverter(int precision)
=> new JpegColorConverter<TiffYccKOperator>(precision);
=> new(precision);

/// <summary>
/// A stack-only struct to reference the input buffers using <see cref="ReadOnlySpan{T}"/>-s.
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ private void ProcessApp13Marker(BufferedReadStream stream, int remaining)
if (resourceDataSize > 0 && blockDataSpan.Length >= dataStartIdx + resourceDataSize)
{
this.hasIptc = true;
this.iptcData = blockDataSpan.Slice(dataStartIdx, resourceDataSize).ToArray();
this.iptcData = [.. blockDataSpan.Slice(dataStartIdx, resourceDataSize)];
break;
}

Expand Down
Loading
Loading