Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public BmpDecoderCore(Configuration configuration, IBmpDecoderOptions options)
/// <summary>
/// Gets the dimensions of the image.
/// </summary>
public Size Dimensions => new Size(this.infoHeader.Width, this.infoHeader.Height);
public Size Dimensions => new(this.infoHeader.Width, this.infoHeader.Height);

/// <inheritdoc />
public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken)
Expand Down Expand Up @@ -389,7 +389,7 @@ private void ReadRle24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, b
if (rowHasUndefinedPixels)
{
// Slow path with undefined pixels.
var yMulWidth = y * width;
int yMulWidth = y * width;
int rowStartIdx = yMulWidth * 3;
for (int x = 0; x < width; x++)
{
Expand Down
12 changes: 12 additions & 0 deletions src/ImageSharp/Formats/Jpeg/Components/ComponentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{
internal enum ComponentType
{
Huffman = 0,

Arithmetic = 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

using SixLabors.ImageSharp.Memory;

namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
{
internal class ArithmeticDecodingComponent : JpegComponent
{
public ArithmeticDecodingComponent(MemoryAllocator memoryAllocator, JpegFrame frame, byte id, int horizontalFactor, int verticalFactor, byte quantizationTableIndex, int index)
: base(memoryAllocator, frame, id, horizontalFactor, verticalFactor, quantizationTableIndex, index)
{
}

/// <summary>
/// Gets or sets the dc context.
/// </summary>
public int DcContext { get; set; }

/// <summary>
/// Gets or sets the dc statistics.
/// </summary>
public ArithmeticStatistics DcStatistics { get; set; }

/// <summary>
/// Gets or sets the ac statistics.
/// </summary>
public ArithmeticStatistics AcStatistics { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
{
internal class ArithmeticDecodingTable
{
public ArithmeticDecodingTable(byte tableClass, byte identifier)
{
this.TableClass = tableClass;
this.Identifier = identifier;
}

public byte TableClass { get; }

public byte Identifier { get; }

public byte ConditioningTableValue { get; private set; }

public int DcL { get; private set; }

public int DcU { get; private set; }

public int AcKx { get; private set; }

public void Configure(byte conditioningTableValue)
{
this.ConditioningTableValue = conditioningTableValue;
if (this.TableClass == 0)
{
this.DcL = conditioningTableValue & 0x0F;
this.DcU = conditioningTableValue >> 4;
this.AcKx = 0;
}
else
{
this.DcL = 0;
this.DcU = 0;
this.AcKx = conditioningTableValue;
}
}
}
}
Loading