FIRGB16 Structure

FreeImage.NET

FIRGB16 Structure
The FIRGB16 structure describes a color consisting of relative intensities of red, green, blue and alpha value. Each single color component consumes 16 bits and so, takes values in the range from 0 to 65535.

Namespace: FreeImageAPI
Assembly: FreeImageNET (in FreeImageNET.dll) Version: 3.17.0.4 (3.17.0)
Syntax
C#
[SerializableAttribute]
public struct FIRGB16 : IComparable, IComparable<FIRGB16>, 
	IEquatable<FIRGB16>

The FIRGB16 type exposes the following members.

Constructors
  NameDescription
Public methodFIRGB16
Initializes a new instance based on the specified Color.
Top
Properties
  NameDescription
Public propertyColor
Gets or sets the Color of the structure.
Top
Methods
  NameDescription
Public methodCompareTo(Object)
Compares this instance with a specified Object.
Public methodCompareTo(FIRGB16)
Compares this instance with a specified FIRGB16 object.
Public methodEquals(Object)
Tests whether the specified object is a FIRGB16 structure and is equivalent to this FIRGB16 structure.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(FIRGB16)
Tests whether the specified FIRGB16 structure is equivalent to this FIRGB16 structure.
Public methodGetHashCode
Returns a hash code for this FIRGB16 structure.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Converts the numeric value of the FIRGB16 object to its equivalent string representation.
(Overrides ValueTypeToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Tests whether two specified FIRGB16 structures are equivalent.
Public operatorStatic member(Color to FIRGB16)
Converts the value of a Color structure to a FIRGB16 structure.
Public operatorStatic member(FIRGB16 to Color)
Converts the value of a FIRGB16 structure to a Color structure.
Public operatorStatic memberInequality
Tests whether two specified FIRGB16 structures are different.
Top
Fields
  NameDescription
Public fieldblue
The blue color component.
Public fieldgreen
The green color component.
Public fieldred
The red color component.
Top
Remarks

The FIRGB16 structure provides access to an underlying FreeImage FIRGB16 structure. To determine the red, green or blue component of a color, use the red, green or blue fields, respectively.

For easy integration of the underlying structure into the .NET framework, the FIRGB16 structure implements implicit conversion operators to convert the represented color to and from the Color type. This makes the Color type a real replacement for the FIRGB16 structure and my be used in all situations which require an FIRGB16 type.

Each color component red, green or blue of FIRGB16 is translated into it's corresponding color component R, G or B of Color by right shifting 8 bits and shifting left 8 bits for the reverse conversion. When converting from Color into FIRGB16, the color's alpha value is ignored and assumed to be 255 when converting from FIRGB16 into Color, creating a fully opaque color.

Conversion from System.Drawing.Color to FIRGB16

FIRGB16.component = Color.component << 8

Conversion from FIRGB16 to System.Drawing.Color

Color.component = FIRGB16.component >> 8

The same conversion is also applied when the Color property or the FIRGB16(Color) constructor is invoked.

Examples
The following code example demonstrates the various conversions between the FIRGB16 structure and the Color structure.
FIRGB16 firgb16;
// Initialize the structure using a native .NET Color structure.
firgb16 = new FIRGBA16(Color.Indigo);
// Initialize the structure using the implicit operator.
firgb16 = Color.DarkSeaGreen;
// Convert the FIRGB16 instance into a native .NET Color
// using its implicit operator.
Color color = firgb16;
// Using the structure's Color property for converting it
// into a native .NET Color.
Color another = firgb16.Color;
See Also