FIRGBA16 Structure

FreeImage.NET

FIRGBA16 Structure
The FIRGBA16 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 FIRGBA16 : IComparable, IComparable<FIRGBA16>, 
	IEquatable<FIRGBA16>

The FIRGBA16 type exposes the following members.

Constructors
  NameDescription
Public methodFIRGBA16
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(FIRGBA16)
Compares this instance with a specified FIRGBA16 object.
Public methodEquals(Object)
Tests whether the specified object is a FIRGBA16 structure and is equivalent to this FIRGBA16 structure.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(FIRGBA16)
Tests whether the specified FIRGBA16 structure is equivalent to this FIRGBA16 structure.
Public methodGetHashCode
Returns a hash code for this FIRGBA16 structure.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Converts the numeric value of the FIRGBA16 object to its equivalent string representation.
(Overrides ValueTypeToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Tests whether two specified FIRGBA16 structures are equivalent.
Public operatorStatic member(Color to FIRGBA16)
Converts the value of a Color structure to a FIRGBA16 structure.
Public operatorStatic member(FIRGBA16 to Color)
Converts the value of a FIRGBA16 structure to a Color structure.
Public operatorStatic memberInequality
Tests whether two specified FIRGBA16 structures are different.
Top
Fields
  NameDescription
Public fieldalpha
The alpha color component.
Public fieldblue
The blue color component.
Public fieldgreen
The green color component.
Public fieldred
The red color component.
Top
Remarks

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

For easy integration of the underlying structure into the .NET framework, the FIRGBA16 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 FIRGBA16 structure and my be used in all situations which require an FIRGBA16 type.

Each color component alpha, red, green or blue of FIRGBA16 is translated into it's corresponding color component A, R, G or B of Color by an 8 bit right shift and vice versa.

Conversion from System.Drawing.Color to FIRGBA16

FIRGBA16.component = Color.component << 8

Conversion from FIRGBA16 to System.Drawing.Color

Color.component = FIRGBA16.component >> 8

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

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