From ce125669c33c5a1bd61178e0eb1843a27dbb6df2 Mon Sep 17 00:00:00 2001 From: Yufei Huang Date: Tue, 5 May 2015 10:54:36 +0800 Subject: [PATCH] Make YCbCr.(Y/Cb/Cr) and Hsv.(H/S/V) a plan field to make color manipulations a bit faster Former-commit-id: cc64a3b7498c57f3ac5e2b0ab5e59626b6e95e9c Former-commit-id: d199172432d36258d518faf531aa214c28543bc8 Former-commit-id: b8e0ea3874620340a0c7c7a3e85630dc45e7e23d --- src/ImageProcessor/Colors/Hsv.cs | 13 ++++++------- src/ImageProcessor/Colors/YCbCr.cs | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ImageProcessor/Colors/Hsv.cs b/src/ImageProcessor/Colors/Hsv.cs index e76d1657cd..d85dd35207 100644 --- a/src/ImageProcessor/Colors/Hsv.cs +++ b/src/ImageProcessor/Colors/Hsv.cs @@ -45,28 +45,27 @@ namespace ImageProcessor /// Gets the H hue component. /// A value ranging between 0 and 360. /// - public float H { get; } + public readonly float H; /// /// Gets the S saturation component. /// A value ranging between 0 and 100. /// - public float S { get; } - - + public readonly float S; + /// /// Gets the V value (brightness) component. /// A value ranging between 0 and 100. /// - public float V { get; } + public readonly float V; /// /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool IsEmpty => Math.Abs(this.H) < Epsilon - && Math.Abs(this.S) < Epsilon - && Math.Abs(this.V) < Epsilon; + && Math.Abs(this.S) < Epsilon + && Math.Abs(this.V) < Epsilon; /// /// Compares two objects. The result specifies whether the values diff --git a/src/ImageProcessor/Colors/YCbCr.cs b/src/ImageProcessor/Colors/YCbCr.cs index 0c4a1b67bd..f7d7f05b22 100644 --- a/src/ImageProcessor/Colors/YCbCr.cs +++ b/src/ImageProcessor/Colors/YCbCr.cs @@ -49,27 +49,27 @@ namespace ImageProcessor /// Gets the Y luminance component. /// A value ranging between 0 and 255. /// - public float Y { get; } + public readonly float Y; /// /// Gets the Cb chroma component. /// A value ranging between 0 and 255. /// - public float Cb { get; } + public readonly float Cb; /// /// Gets the Cr chroma component. /// A value ranging between 0 and 255. /// - public float Cr { get; } + public readonly float Cr; /// /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool IsEmpty => Math.Abs(this.Y) < Epsilon - && Math.Abs(this.Cb) < Epsilon - && Math.Abs(this.Cr) < Epsilon; + && Math.Abs(this.Cb) < Epsilon + && Math.Abs(this.Cr) < Epsilon; /// /// Compares two objects. The result specifies whether the values