Browse Source

Renamed pixel dimensions for JpegFrame

pull/1694/head
Dmitry Pentin 5 years ago
parent
commit
6f6ee7337d
  1. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs
  2. 8
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegFrame.cs
  3. 10
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs

@ -109,10 +109,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
public void Init() public void Init()
{ {
this.WidthInBlocks = (int)MathF.Ceiling( this.WidthInBlocks = (int)MathF.Ceiling(
MathF.Ceiling(this.Frame.SamplesPerLine / 8F) * this.HorizontalSamplingFactor / this.Frame.MaxHorizontalFactor); MathF.Ceiling(this.Frame.PixelWidth / 8F) * this.HorizontalSamplingFactor / this.Frame.MaxHorizontalFactor);
this.HeightInBlocks = (int)MathF.Ceiling( this.HeightInBlocks = (int)MathF.Ceiling(
MathF.Ceiling(this.Frame.Scanlines / 8F) * this.VerticalSamplingFactor / this.Frame.MaxVerticalFactor); MathF.Ceiling(this.Frame.PixelHeight / 8F) * this.VerticalSamplingFactor / this.Frame.MaxVerticalFactor);
int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor;
int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor; int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor;

8
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegFrame.cs

@ -28,12 +28,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// <summary> /// <summary>
/// Gets or sets the number of scanlines within the frame. /// Gets or sets the number of scanlines within the frame.
/// </summary> /// </summary>
public int Scanlines { get; set; } public int PixelHeight { get; set; }
/// <summary> /// <summary>
/// Gets or sets the number of samples per scanline. /// Gets or sets the number of samples per scanline.
/// </summary> /// </summary>
public int SamplesPerLine { get; set; } public int PixelWidth { get; set; }
/// <summary> /// <summary>
/// Gets or sets the number of components within a frame. In progressive frames this value can range from only 1 to 4. /// Gets or sets the number of components within a frame. In progressive frames this value can range from only 1 to 4.
@ -95,8 +95,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// </summary> /// </summary>
public void InitComponents() public void InitComponents()
{ {
this.McusPerLine = (int)MathF.Ceiling(this.SamplesPerLine / 8F / this.MaxHorizontalFactor); this.McusPerLine = (int)MathF.Ceiling(this.PixelWidth / 8F / this.MaxHorizontalFactor);
this.McusPerColumn = (int)MathF.Ceiling(this.Scanlines / 8F / this.MaxVerticalFactor); this.McusPerColumn = (int)MathF.Ceiling(this.PixelHeight / 8F / this.MaxVerticalFactor);
for (int i = 0; i < this.ComponentCount; i++) for (int i = 0; i < this.ComponentCount; i++)
{ {

10
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -852,17 +852,17 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
Extended = frameMarker.Marker == JpegConstants.Markers.SOF1, Extended = frameMarker.Marker == JpegConstants.Markers.SOF1,
Progressive = frameMarker.Marker == JpegConstants.Markers.SOF2, Progressive = frameMarker.Marker == JpegConstants.Markers.SOF2,
Precision = this.temp[0], Precision = this.temp[0],
Scanlines = (this.temp[1] << 8) | this.temp[2], PixelHeight = (this.temp[1] << 8) | this.temp[2],
SamplesPerLine = (this.temp[3] << 8) | this.temp[4], PixelWidth = (this.temp[3] << 8) | this.temp[4],
ComponentCount = this.temp[5] ComponentCount = this.temp[5]
}; };
if (this.Frame.SamplesPerLine == 0 || this.Frame.Scanlines == 0) if (this.Frame.PixelWidth == 0 || this.Frame.PixelHeight == 0)
{ {
JpegThrowHelper.ThrowInvalidImageDimensions(this.Frame.SamplesPerLine, this.Frame.Scanlines); JpegThrowHelper.ThrowInvalidImageDimensions(this.Frame.PixelWidth, this.Frame.PixelHeight);
} }
this.ImageSizeInPixels = new Size(this.Frame.SamplesPerLine, this.Frame.Scanlines); this.ImageSizeInPixels = new Size(this.Frame.PixelWidth, this.Frame.PixelHeight);
this.ComponentCount = this.Frame.ComponentCount; this.ComponentCount = this.Frame.ComponentCount;
if (!metadataOnly) if (!metadataOnly)

Loading…
Cancel
Save