mirror of https://github.com/SixLabors/ImageSharp
9 changed files with 452 additions and 1 deletions
@ -0,0 +1,75 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heif; |
|||
|
|||
/// <summary>
|
|||
/// Describes the nominal ambient environment intended for viewing a HEIF image.
|
|||
/// </summary>
|
|||
public readonly struct HeifAmbientViewingEnvironment : IEquatable<HeifAmbientViewingEnvironment> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="HeifAmbientViewingEnvironment"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="illuminance">The environmental illuminance in lux.</param>
|
|||
/// <param name="ambientLight">
|
|||
/// The CIE 1931 chromaticity coordinates of the ambient light in the nominal viewing environment.
|
|||
/// </param>
|
|||
public HeifAmbientViewingEnvironment(double illuminance, CieXyChromaticityCoordinates ambientLight) |
|||
{ |
|||
this.Illuminance = illuminance; |
|||
this.AmbientLight = ambientLight; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the environmental illuminance in lux.
|
|||
/// </summary>
|
|||
public double Illuminance { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the CIE 1931 chromaticity coordinates of the ambient light in the nominal viewing environment.
|
|||
/// </summary>
|
|||
public CieXyChromaticityCoordinates AmbientLight { get; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two ambient viewing environments for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first ambient viewing environment.</param>
|
|||
/// <param name="right">The second ambient viewing environment.</param>
|
|||
/// <returns><see langword="true"/> when the illuminance and ambient-light coordinates are equal.</returns>
|
|||
public static bool operator ==(HeifAmbientViewingEnvironment left, HeifAmbientViewingEnvironment right) |
|||
=> left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Compares two ambient viewing environments for inequality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first ambient viewing environment.</param>
|
|||
/// <param name="right">The second ambient viewing environment.</param>
|
|||
/// <returns><see langword="true"/> when the illuminance or ambient-light coordinates differ.</returns>
|
|||
public static bool operator !=(HeifAmbientViewingEnvironment left, HeifAmbientViewingEnvironment right) |
|||
=> !left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified object is an ambient viewing environment with the same values.
|
|||
/// </summary>
|
|||
/// <param name="obj">The object to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when <paramref name="obj"/> contains the same environment values.</returns>
|
|||
public override bool Equals(object? obj) |
|||
=> obj is HeifAmbientViewingEnvironment other && this.Equals(other); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified ambient viewing environment has the same values as this value.
|
|||
/// </summary>
|
|||
/// <param name="other">The ambient viewing environment to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when the illuminance and ambient-light coordinates are equal.</returns>
|
|||
public bool Equals(HeifAmbientViewingEnvironment other) |
|||
=> this.Illuminance.Equals(other.Illuminance) && this.AmbientLight.Equals(other.AmbientLight); |
|||
|
|||
/// <summary>
|
|||
/// Returns a hash code for this ambient viewing environment.
|
|||
/// </summary>
|
|||
/// <returns>A hash code derived from the illuminance and ambient-light coordinates.</returns>
|
|||
public override int GetHashCode() => HashCode.Combine(this.Illuminance, this.AmbientLight); |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heif; |
|||
|
|||
/// <summary>
|
|||
/// Describes the nominal diffuse-white luminance of a HEIF image.
|
|||
/// </summary>
|
|||
public readonly struct HeifNominalDiffuseWhite : IEquatable<HeifNominalDiffuseWhite> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="HeifNominalDiffuseWhite"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="luminance">
|
|||
/// The nominal diffuse-white luminance in candelas per square metre, or <see langword="null"/> to use the
|
|||
/// standard default.
|
|||
/// </param>
|
|||
public HeifNominalDiffuseWhite(double? luminance) => this.Luminance = luminance; |
|||
|
|||
/// <summary>
|
|||
/// Gets the nominal diffuse-white luminance in candelas per square metre, or <see langword="null"/> when the
|
|||
/// image requests the standard default.
|
|||
/// </summary>
|
|||
public double? Luminance { get; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two nominal diffuse-white descriptions for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first nominal diffuse-white description.</param>
|
|||
/// <param name="right">The second nominal diffuse-white description.</param>
|
|||
/// <returns><see langword="true"/> when both descriptions specify the same luminance behavior.</returns>
|
|||
public static bool operator ==(HeifNominalDiffuseWhite left, HeifNominalDiffuseWhite right) |
|||
=> left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Compares two nominal diffuse-white descriptions for inequality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first nominal diffuse-white description.</param>
|
|||
/// <param name="right">The second nominal diffuse-white description.</param>
|
|||
/// <returns><see langword="true"/> when the descriptions specify different luminance behavior.</returns>
|
|||
public static bool operator !=(HeifNominalDiffuseWhite left, HeifNominalDiffuseWhite right) |
|||
=> !left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified object is a nominal diffuse-white description with the same value.
|
|||
/// </summary>
|
|||
/// <param name="obj">The object to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when <paramref name="obj"/> specifies the same luminance behavior.</returns>
|
|||
public override bool Equals(object? obj) |
|||
=> obj is HeifNominalDiffuseWhite other && this.Equals(other); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified nominal diffuse-white description has the same value as this value.
|
|||
/// </summary>
|
|||
/// <param name="other">The nominal diffuse-white description to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when both descriptions specify the same luminance behavior.</returns>
|
|||
public bool Equals(HeifNominalDiffuseWhite other) => this.Luminance.Equals(other.Luminance); |
|||
|
|||
/// <summary>
|
|||
/// Returns a hash code for this nominal diffuse-white description.
|
|||
/// </summary>
|
|||
/// <returns>A hash code derived from the luminance behavior.</returns>
|
|||
public override int GetHashCode() => this.Luminance.GetHashCode(); |
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Heif; |
|||
|
|||
/// <summary>
|
|||
/// Describes the display surround and periphery in which a HEIF image was mastered.
|
|||
/// </summary>
|
|||
public readonly struct HeifReferenceViewingEnvironment : IEquatable<HeifReferenceViewingEnvironment> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="HeifReferenceViewingEnvironment"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="surroundLuminance">The luminance of the area immediately surrounding the display.</param>
|
|||
/// <param name="surroundLight">The CIE 1931 chromaticity coordinates of the surround light.</param>
|
|||
/// <param name="peripheryLuminance">The luminance of the environment outside the display surround.</param>
|
|||
/// <param name="peripheryLight">The CIE 1931 chromaticity coordinates of the periphery light.</param>
|
|||
public HeifReferenceViewingEnvironment( |
|||
double surroundLuminance, |
|||
CieXyChromaticityCoordinates surroundLight, |
|||
double peripheryLuminance, |
|||
CieXyChromaticityCoordinates peripheryLight) |
|||
{ |
|||
this.SurroundLuminance = surroundLuminance; |
|||
this.SurroundLight = surroundLight; |
|||
this.PeripheryLuminance = peripheryLuminance; |
|||
this.PeripheryLight = peripheryLight; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the luminance of the area immediately surrounding the display in candelas per square metre.
|
|||
/// </summary>
|
|||
public double SurroundLuminance { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the CIE 1931 chromaticity coordinates of the surround light.
|
|||
/// </summary>
|
|||
public CieXyChromaticityCoordinates SurroundLight { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the luminance of the environment outside the display surround in candelas per square metre.
|
|||
/// </summary>
|
|||
public double PeripheryLuminance { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the CIE 1931 chromaticity coordinates of the periphery light.
|
|||
/// </summary>
|
|||
public CieXyChromaticityCoordinates PeripheryLight { get; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two reference viewing environments for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first reference viewing environment.</param>
|
|||
/// <param name="right">The second reference viewing environment.</param>
|
|||
/// <returns><see langword="true"/> when every surround and periphery value is equal.</returns>
|
|||
public static bool operator ==(HeifReferenceViewingEnvironment left, HeifReferenceViewingEnvironment right) |
|||
=> left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Compares two reference viewing environments for inequality.
|
|||
/// </summary>
|
|||
/// <param name="left">The first reference viewing environment.</param>
|
|||
/// <param name="right">The second reference viewing environment.</param>
|
|||
/// <returns><see langword="true"/> when any surround or periphery value differs.</returns>
|
|||
public static bool operator !=(HeifReferenceViewingEnvironment left, HeifReferenceViewingEnvironment right) |
|||
=> !left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified object is a reference viewing environment with the same values.
|
|||
/// </summary>
|
|||
/// <param name="obj">The object to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when <paramref name="obj"/> contains the same environment values.</returns>
|
|||
public override bool Equals(object? obj) |
|||
=> obj is HeifReferenceViewingEnvironment other && this.Equals(other); |
|||
|
|||
/// <summary>
|
|||
/// Determines whether the specified reference viewing environment has the same values as this value.
|
|||
/// </summary>
|
|||
/// <param name="other">The reference viewing environment to compare with this value.</param>
|
|||
/// <returns><see langword="true"/> when every surround and periphery value is equal.</returns>
|
|||
public bool Equals(HeifReferenceViewingEnvironment other) |
|||
=> this.SurroundLuminance.Equals(other.SurroundLuminance) |
|||
&& this.SurroundLight.Equals(other.SurroundLight) |
|||
&& this.PeripheryLuminance.Equals(other.PeripheryLuminance) |
|||
&& this.PeripheryLight.Equals(other.PeripheryLight); |
|||
|
|||
/// <summary>
|
|||
/// Returns a hash code for this reference viewing environment.
|
|||
/// </summary>
|
|||
/// <returns>A hash code derived from the surround and periphery values.</returns>
|
|||
public override int GetHashCode() |
|||
=> HashCode.Combine( |
|||
this.SurroundLuminance, |
|||
this.SurroundLight, |
|||
this.PeripheryLuminance, |
|||
this.PeripheryLight); |
|||
} |
|||
Loading…
Reference in new issue