mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 389 additions and 52 deletions
@ -0,0 +1,38 @@ |
|||||
|
// <copyright file="Adobe.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
// ReSharper disable InconsistentNaming
|
||||
|
namespace ImageSharp.Formats.Jpeg.Port.Components |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Provides information about the Adobe marker segment
|
||||
|
/// </summary>
|
||||
|
internal struct Adobe |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The DCT Encode Version
|
||||
|
/// </summary>
|
||||
|
public short DCTEncodeVersion; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 0x0 : (none)
|
||||
|
/// Bit 15 : Encoded with Blend=1 downsampling
|
||||
|
/// </summary>
|
||||
|
public short APP14Flags0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 0x0 : (none)
|
||||
|
/// </summary>
|
||||
|
public short APP14Flags1; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Determines the colorspace transform
|
||||
|
/// 00 : Unknown (RGB or CMYK)
|
||||
|
/// 01 : YCbCr
|
||||
|
/// 02 : YCCK
|
||||
|
/// </summary>
|
||||
|
public byte ColorTransform; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
// <copyright file="Component.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Formats.Jpeg.Port.Components |
||||
|
{ |
||||
|
using System; |
||||
|
|
||||
|
using ImageSharp.Memory; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a component block
|
||||
|
/// </summary>
|
||||
|
internal struct Component : IDisposable |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the output
|
||||
|
/// </summary>
|
||||
|
public Buffer<byte> Output; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the horizontal scaling factor
|
||||
|
/// </summary>
|
||||
|
public int ScaleX; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the vertical scaling factor
|
||||
|
/// </summary>
|
||||
|
public int ScaleY; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the number of blocks per line
|
||||
|
/// </summary>
|
||||
|
public int BlocksPerLine; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the number of blocks per column
|
||||
|
/// </summary>
|
||||
|
public int BlocksPerColumn; |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
this.Output?.Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
// <copyright file="Components.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Formats.Jpeg.Port.Components |
||||
|
{ |
||||
|
using System; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Contains all the decoded component blocks
|
||||
|
/// </summary>
|
||||
|
internal class ComponentBlocks : IDisposable |
||||
|
{ |
||||
|
private bool isDisposed; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the component blocks
|
||||
|
/// </summary>
|
||||
|
public Component[] Components { get; set; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
this.Dispose(true); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
|
/// </summary>
|
||||
|
/// <param name="disposing">Whether to dispose of managed objects</param>
|
||||
|
protected virtual void Dispose(bool disposing) |
||||
|
{ |
||||
|
if (!this.isDisposed) |
||||
|
{ |
||||
|
if (disposing) |
||||
|
{ |
||||
|
if (this.Components != null) |
||||
|
{ |
||||
|
for (int i = 0; i < this.Components.Length; i++) |
||||
|
{ |
||||
|
this.Components[i].Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Set large fields to null.
|
||||
|
this.Components = null; |
||||
|
this.isDisposed = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
// <copyright file="JFif.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Formats.Jpeg.Port.Components |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Provides information about the JFIF marker segment
|
||||
|
/// </summary>
|
||||
|
internal struct JFif |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The major version
|
||||
|
/// </summary>
|
||||
|
public byte MajorVersion; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The minor version
|
||||
|
/// </summary>
|
||||
|
public byte MinorVersion; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Units for the following pixel density fields
|
||||
|
/// 00 : No units; width:height pixel aspect ratio = Ydensity:Xdensity
|
||||
|
/// 01 : Pixels per inch (2.54 cm)
|
||||
|
/// 02 : Pixels per centimeter
|
||||
|
/// </summary>
|
||||
|
public byte DensityUnits; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Horizontal pixel density. Must not be zero.
|
||||
|
/// </summary>
|
||||
|
public short XDensity; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Vertical pixel density. Must not be zero.
|
||||
|
/// </summary>
|
||||
|
public short YDensity; |
||||
|
|
||||
|
// TODO: Thumbnail?
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue