using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace FreeImageAPI { /// /// The FI4BIT structure represents the half of a . /// It's valuerange is between 0 and 15. /// [DebuggerDisplay("{value}"), Serializable] public struct FI4BIT { /// /// Represents the largest possible value of . This field is constant. /// public const byte MaxValue = 0x0F; /// /// Represents the smallest possible value of . This field is constant. /// public const byte MinValue = 0x00; /// /// The value of the structure. /// private byte value; /// /// Initializes a new instance based on the specified value. /// /// The value to initialize with. private FI4BIT(byte value) { this.value = (byte)(value & MaxValue); } /// /// Converts the value of a structure to a structure. /// /// A structure. /// A new instance of initialized to . public static implicit operator byte(FI4BIT value) { return value.value; } /// /// Converts the value of a structure to a structure. /// /// A structure. /// A new instance of initialized to . public static implicit operator FI4BIT(byte value) { return new FI4BIT(value); } /// /// Converts the numeric value of the object /// to its equivalent string representation. /// /// The string representation of the value of this instance. public override string ToString() { return value.ToString(); } } }