mirror of https://github.com/SixLabors/ImageSharp
11 changed files with 120 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(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:3df296a3fd58930899d308558b128db760879cb776afba8f2d6511aba3934dd0 |
|||
size 6957 |
|||
Loading…
Reference in new issue