From 5238c6d9e6b6c4c0be2256af52dd545dec5a4490 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: 68972e8996c91cc0a2f477aa18cb2be8401e1ccb Former-commit-id: 858f463b331210bbdea7548447c0ad7a2fa2a658 Former-commit-id: 2faf9054b4f9cdb9acfe22019db9026024f1571d --- 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