mirror of https://github.com/SixLabors/ImageSharp
11 changed files with 117 additions and 61 deletions
@ -0,0 +1,36 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="DoubleExtensions.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// Encapsulates a series of time saving extension methods to the <see cref="T:System.Double" /> class.
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Extensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Double"/> class.
|
||||
|
/// </summary>
|
||||
|
public static class DoubleExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Converts an <see cref="T:System.Double"/> value into a valid <see cref="T:System.Byte"/>.
|
||||
|
/// <remarks>
|
||||
|
/// If the value given is less than 0 or greater than 255, the value will be constrained into
|
||||
|
/// those restricted ranges.
|
||||
|
/// </remarks>
|
||||
|
/// </summary>
|
||||
|
/// <param name="d">
|
||||
|
/// The <see cref="T:System.Double"/> to convert.
|
||||
|
/// </param>
|
||||
|
/// <returns>
|
||||
|
/// The <see cref="T:System.Byte"/>.
|
||||
|
/// </returns>
|
||||
|
public static byte ToByte(this double d) |
||||
|
{ |
||||
|
return (byte)((d > byte.MaxValue) ? byte.MaxValue : ((d < byte.MinValue) ? byte.MinValue : d)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="IntegerExtensions.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// Encapsulates a series of time saving extension methods to the <see cref="T:System.Int32" /> class.
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Extensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Int32"/> class.
|
||||
|
/// </summary>
|
||||
|
public static class IntegerExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Converts an <see cref="T:System.Int32"/> value into a valid <see cref="T:System.Byte"/>.
|
||||
|
/// <remarks>
|
||||
|
/// If the value given is less than 0 or greater than 255, the value will be constrained into
|
||||
|
/// those restricted ranges.
|
||||
|
/// </remarks>
|
||||
|
/// </summary>
|
||||
|
/// <param name="integer">
|
||||
|
/// The <see cref="T:System.Int32"/> to convert.
|
||||
|
/// </param>
|
||||
|
/// <returns>
|
||||
|
/// The <see cref="T:System.Byte"/>.
|
||||
|
/// </returns>
|
||||
|
public static byte ToByte(this int integer) |
||||
|
{ |
||||
|
return ((double)integer).ToByte(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 6.8 KiB |
Loading…
Reference in new issue