mirror of https://github.com/SixLabors/ImageSharp
18 changed files with 908 additions and 5 deletions
@ -0,0 +1,41 @@ |
|||
// <copyright file="IccScreeningFlag.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// Screening flags. Can be combined with a logical OR.
|
|||
/// </summary>
|
|||
[Flags] |
|||
internal enum IccScreeningFlag : int |
|||
{ |
|||
/// <summary>
|
|||
/// No flags (equivalent to NotDefaultScreens and UnitLinesPerCm)
|
|||
/// </summary>
|
|||
None = 0, |
|||
|
|||
/// <summary>
|
|||
/// Use printer default screens
|
|||
/// </summary>
|
|||
DefaultScreens = 1 << 0, |
|||
|
|||
/// <summary>
|
|||
/// Don't use printer default screens
|
|||
/// </summary>
|
|||
NotDefaultScreens = 0, |
|||
|
|||
/// <summary>
|
|||
/// Frequency units in Lines/Inch
|
|||
/// </summary>
|
|||
UnitLinesPerInch = 1 << 1, |
|||
|
|||
/// <summary>
|
|||
/// Frequency units in Lines/cm
|
|||
/// </summary>
|
|||
UnitLinesPerCm = 0, |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
// <copyright file="IccScreeningSpotType.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
/// <summary>
|
|||
/// Enumerates the screening spot types
|
|||
/// </summary>
|
|||
internal enum IccScreeningSpotType : int |
|||
{ |
|||
/// <summary>
|
|||
/// Unknown spot type
|
|||
/// </summary>
|
|||
Unknown = 0, |
|||
|
|||
/// <summary>
|
|||
/// Default printer spot type
|
|||
/// </summary>
|
|||
PrinterDefault = 1, |
|||
|
|||
/// <summary>
|
|||
/// Round stop type
|
|||
/// </summary>
|
|||
Round = 2, |
|||
|
|||
/// <summary>
|
|||
/// Diamond spot type
|
|||
/// </summary>
|
|||
Diamond = 3, |
|||
|
|||
/// <summary>
|
|||
/// Ellipse spot type
|
|||
/// </summary>
|
|||
Ellipse = 4, |
|||
|
|||
/// <summary>
|
|||
/// Line spot type
|
|||
/// </summary>
|
|||
Line = 5, |
|||
|
|||
/// <summary>
|
|||
/// Square spot type
|
|||
/// </summary>
|
|||
Square = 6, |
|||
|
|||
/// <summary>
|
|||
/// Cross spot type
|
|||
/// </summary>
|
|||
Cross = 7, |
|||
} |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
// <copyright file="IccCrdInfoTagDataEntry.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// This type contains the PostScript product name to which this profile
|
|||
/// corresponds and the names of the companion CRDs
|
|||
/// </summary>
|
|||
internal sealed class IccCrdInfoTagDataEntry : IccTagDataEntry, IEquatable<IccCrdInfoTagDataEntry> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccCrdInfoTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="postScriptProductName">the PostScript product name</param>
|
|||
/// <param name="renderingIntent0Crd">the rendering intent 0 CRD name</param>
|
|||
/// <param name="renderingIntent1Crd">the rendering intent 1 CRD name</param>
|
|||
/// <param name="renderingIntent2Crd">the rendering intent 2 CRD name</param>
|
|||
/// <param name="renderingIntent3Crd">the rendering intent 3 CRD name</param>
|
|||
public IccCrdInfoTagDataEntry( |
|||
string postScriptProductName, |
|||
string renderingIntent0Crd, |
|||
string renderingIntent1Crd, |
|||
string renderingIntent2Crd, |
|||
string renderingIntent3Crd) |
|||
: this( |
|||
postScriptProductName, |
|||
renderingIntent0Crd, |
|||
renderingIntent1Crd, |
|||
renderingIntent2Crd, |
|||
renderingIntent3Crd, |
|||
IccProfileTag.Unknown) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccCrdInfoTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="postScriptProductName">the PostScript product name</param>
|
|||
/// <param name="renderingIntent0Crd">the rendering intent 0 CRD name</param>
|
|||
/// <param name="renderingIntent1Crd">the rendering intent 1 CRD name</param>
|
|||
/// <param name="renderingIntent2Crd">the rendering intent 2 CRD name</param>
|
|||
/// <param name="renderingIntent3Crd">the rendering intent 3 CRD name</param>
|
|||
/// <param name="tagSignature">Tag Signature</param>
|
|||
public IccCrdInfoTagDataEntry( |
|||
string postScriptProductName, |
|||
string renderingIntent0Crd, |
|||
string renderingIntent1Crd, |
|||
string renderingIntent2Crd, |
|||
string renderingIntent3Crd, |
|||
IccProfileTag tagSignature) |
|||
: base(IccTypeSignature.CrdInfo, tagSignature) |
|||
{ |
|||
this.PostScriptProductName = postScriptProductName; |
|||
this.RenderingIntent0Crd = renderingIntent0Crd; |
|||
this.RenderingIntent1Crd = renderingIntent1Crd; |
|||
this.RenderingIntent2Crd = renderingIntent2Crd; |
|||
this.RenderingIntent3Crd = renderingIntent3Crd; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the PostScript product name
|
|||
/// </summary>
|
|||
public string PostScriptProductName { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rendering intent 0 CRD name
|
|||
/// </summary>
|
|||
public string RenderingIntent0Crd { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rendering intent 1 CRD name
|
|||
/// </summary>
|
|||
public string RenderingIntent1Crd { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rendering intent 2 CRD name
|
|||
/// </summary>
|
|||
public string RenderingIntent2Crd { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rendering intent 3 CRD name
|
|||
/// </summary>
|
|||
public string RenderingIntent3Crd { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(IccTagDataEntry other) |
|||
{ |
|||
if (base.Equals(other) && other is IccCrdInfoTagDataEntry entry) |
|||
{ |
|||
return this.PostScriptProductName == entry.PostScriptProductName |
|||
&& this.RenderingIntent0Crd == entry.RenderingIntent0Crd |
|||
&& this.RenderingIntent1Crd == entry.RenderingIntent1Crd |
|||
&& this.RenderingIntent2Crd == entry.RenderingIntent2Crd |
|||
&& this.RenderingIntent3Crd == entry.RenderingIntent3Crd; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(IccCrdInfoTagDataEntry other) |
|||
{ |
|||
return this.Equals((IccTagDataEntry)other); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// <copyright file="IccScreeningTagDataEntry.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
using System.Linq; |
|||
|
|||
/// <summary>
|
|||
/// This type describes various screening parameters including
|
|||
/// screen frequency, screening angle, and spot shape.
|
|||
/// </summary>
|
|||
internal sealed class IccScreeningTagDataEntry : IccTagDataEntry, IEquatable<IccScreeningTagDataEntry> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccScreeningTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="flags">Screening flags</param>
|
|||
/// <param name="channels">Channel information</param>
|
|||
public IccScreeningTagDataEntry(IccScreeningFlag flags, IccScreeningChannel[] channels) |
|||
: this(flags, channels, IccProfileTag.Unknown) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccScreeningTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="flags">Screening flags</param>
|
|||
/// <param name="channels">Channel information</param>
|
|||
/// <param name="tagSignature">Tag Signature</param>
|
|||
public IccScreeningTagDataEntry(IccScreeningFlag flags, IccScreeningChannel[] channels, IccProfileTag tagSignature) |
|||
: base(IccTypeSignature.Screening, tagSignature) |
|||
{ |
|||
Guard.NotNull(channels, nameof(channels)); |
|||
|
|||
this.Flags = flags; |
|||
this.Channels = channels; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the screening flags
|
|||
/// </summary>
|
|||
public IccScreeningFlag Flags { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the channel information
|
|||
/// </summary>
|
|||
public IccScreeningChannel[] Channels { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(IccTagDataEntry other) |
|||
{ |
|||
if (base.Equals(other) && other is IccScreeningTagDataEntry entry) |
|||
{ |
|||
return this.Flags == entry.Flags |
|||
&& this.Channels.SequenceEqual(entry.Channels); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(IccScreeningTagDataEntry other) |
|||
{ |
|||
return this.Equals((IccTagDataEntry)other); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
// <copyright file="IccUcrBgTagDataEntry.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
using System.Linq; |
|||
|
|||
/// <summary>
|
|||
/// This type contains curves representing the under color removal and black generation
|
|||
/// and a text string which is a general description of the method used for the UCR and BG.
|
|||
/// </summary>
|
|||
internal sealed class IccUcrBgTagDataEntry : IccTagDataEntry, IEquatable<IccUcrBgTagDataEntry> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccUcrBgTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="ucrCurve">UCR (under color removal) curve values</param>
|
|||
/// <param name="bgCurve">BG (black generation) curve values</param>
|
|||
/// <param name="description">Description of the used UCR and BG method</param>
|
|||
public IccUcrBgTagDataEntry(ushort[] ucrCurve, ushort[] bgCurve, string description) |
|||
: this(ucrCurve, bgCurve, description, IccProfileTag.Unknown) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccUcrBgTagDataEntry"/> class.
|
|||
/// </summary>
|
|||
/// <param name="ucrCurve">UCR (under color removal) curve values</param>
|
|||
/// <param name="bgCurve">BG (black generation) curve values</param>
|
|||
/// <param name="description">Description of the used UCR and BG method</param>
|
|||
/// <param name="tagSignature">Tag Signature</param>
|
|||
public IccUcrBgTagDataEntry(ushort[] ucrCurve, ushort[] bgCurve, string description, IccProfileTag tagSignature) |
|||
: base(IccTypeSignature.UcrBg, tagSignature) |
|||
{ |
|||
Guard.NotNull(ucrCurve, nameof(ucrCurve)); |
|||
Guard.NotNull(bgCurve, nameof(bgCurve)); |
|||
Guard.NotNull(description, nameof(description)); |
|||
|
|||
this.UcrCurve = ucrCurve; |
|||
this.BgCurve = bgCurve; |
|||
this.Description = description; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the UCR (under color removal) curve values
|
|||
/// </summary>
|
|||
public ushort[] UcrCurve { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the BG (black generation) curve values
|
|||
/// </summary>
|
|||
public ushort[] BgCurve { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a description of the used UCR and BG method
|
|||
/// </summary>
|
|||
public string Description { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(IccTagDataEntry other) |
|||
{ |
|||
if (base.Equals(other) && other is IccUcrBgTagDataEntry entry) |
|||
{ |
|||
return this.Description == entry.Description |
|||
&& this.UcrCurve.SequenceEqual(entry.UcrCurve) |
|||
&& this.BgCurve.SequenceEqual(entry.BgCurve); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(IccUcrBgTagDataEntry other) |
|||
{ |
|||
return this.Equals((IccTagDataEntry)other); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
// <copyright file="IccScreeningChannel.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// A single channel of a <see cref="IccScreeningTagDataEntry"/>
|
|||
/// </summary>
|
|||
internal struct IccScreeningChannel : IEquatable<IccScreeningChannel> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="IccScreeningChannel"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="frequency">Screen frequency</param>
|
|||
/// <param name="angle">Angle in degrees</param>
|
|||
/// <param name="spotShape">Spot shape</param>
|
|||
public IccScreeningChannel(float frequency, float angle, IccScreeningSpotType spotShape) |
|||
{ |
|||
this.Frequency = frequency; |
|||
this.Angle = angle; |
|||
this.SpotShape = spotShape; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the screen frequency
|
|||
/// </summary>
|
|||
public float Frequency { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the angle in degrees
|
|||
/// </summary>
|
|||
public float Angle { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the spot shape
|
|||
/// </summary>
|
|||
public IccScreeningSpotType SpotShape { get; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="IccScreeningChannel"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">
|
|||
/// The <see cref="IccScreeningChannel"/> on the left side of the operand.
|
|||
/// </param>
|
|||
/// <param name="right">
|
|||
/// The <see cref="IccScreeningChannel"/> on the right side of the operand.
|
|||
/// </param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
public static bool operator ==(IccScreeningChannel left, IccScreeningChannel right) |
|||
{ |
|||
return left.Equals(right); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="IccScreeningChannel"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The <see cref="IccScreeningChannel"/> on the left side of the operand.</param>
|
|||
/// <param name="right">The <see cref="IccScreeningChannel"/> on the right side of the operand.</param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
public static bool operator !=(IccScreeningChannel left, IccScreeningChannel right) |
|||
{ |
|||
return !left.Equals(right); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Equals(object other) |
|||
{ |
|||
return (other is IccScreeningChannel) && this.Equals((IccScreeningChannel)other); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public bool Equals(IccScreeningChannel other) |
|||
{ |
|||
return this.Frequency == other.Frequency |
|||
&& this.Angle == other.Angle |
|||
&& this.SpotShape == other.SpotShape; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override int GetHashCode() |
|||
{ |
|||
unchecked |
|||
{ |
|||
int hashCode = this.Frequency.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.Angle.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.SpotShape.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override string ToString() |
|||
{ |
|||
return $"{this.Frequency}Hz; {this.Angle}°; {this.SpotShape}"; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue