C# Class Imager.sPixel

A pixel (dword) 32Bits wide, 8 Bits for red, green, blue and alpha values.
ファイルを表示 Open project: soywiz/cspspemu Class Usage Examples

Public Properties

Property Type Description
AllowThresholds bool
Black sPixel
ColorExtractionFactor double
Purple sPixel
White sPixel

Public Methods

Method Description
AbsDifference ( sPixel pixel ) : uint

Calculates the absolute difference between to pixels.

Clone ( ) : object

Creates a new object that is a copy of the current instance.

Equals ( object o ) : bool

Determines whether the specified System.Object is equal to this instance.

Equals ( sPixel pixel ) : bool

Determines whether the specified sPixel is equal to this instance.

FromFloat ( float red, float green, float blue, float alpha = 1f ) : sPixel
FromGrey ( byte grey, byte alpha = 255 ) : sPixel

Factory to create a sPixel instance from grey value.

FromRGBA ( byte red, byte green, byte blue, byte alpha = 255 ) : sPixel

Factory to create a sPixel instance from red, green and blue value.

FromRGBA ( int red, int green, int blue, int alpha = 255 ) : sPixel

Factory to create a sPixel instance from red, green and blue value.

GetHashCode ( ) : int

Returns a hash code for this instance.

GetObjectData ( SerializationInfo serializationInfo, StreamingContext _ ) : void

Serializes this instance.

Interpolate ( sPixel pixel1, sPixel pixel2 ) : sPixel

Interpolates two sPixel instances.

Interpolate ( sPixel pixel1, sPixel pixel2, byte quantifier1, byte quantifier2 ) : sPixel

Weighted interpolation of two sPixel instances.

Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3 ) : sPixel

Interpolates three sPixel instances.

Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, byte quantifier1, byte quantifier2, byte quantifier3 ) : sPixel

Weighted interpolation of three sPixel instances.

Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, sPixel pixel4 ) : sPixel

Interpolates four sPixel instances.

Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, sPixel pixel4, byte quantifier1, byte quantifier2, byte quantifier3, byte quantifier4 ) : sPixel

Weighted interpolation of four sPixel instances.

IsLike ( sPixel pixel ) : bool

Determines whether the specified sPixel instance is similar to this instance.

IsNotLike ( sPixel pixel ) : bool

Determines whether this instance is not like the specified sPixel instance.

ToString ( ) : string

Returns a System.String that represents this instance.

operator ( ) : bool

Test for inequality of at least one color component.

operator ( ) : sPixel

Inverts the given color.

sPixel ( Color color ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by using an instance of a the Color class.

sPixel ( SerializationInfo serializationInfo, StreamingContext _ ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by deserializing it.

sPixel ( byte grey, byte alpha = 255 ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by using a grey value.

sPixel ( byte red, byte green, byte blue, byte alpha = 255 ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by using red, green and blue component.

sPixel ( double red, double green, double blue, double alpha = 1 ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by using red, green and blue component.

sPixel ( sPixel pixel ) : System.Diagnostics.Contracts

Initializes a new instance of the sPixel struct by using an existing one.

Private Methods

Method Description
_Byte2Double ( byte value ) : double

Converts a byte color component to double floating point.

_Byte2Single ( byte value ) : float

Converts a byte color component to single floating point.

_Float2Byte ( float value ) : byte

Clips a float value within 0-255 range and returns it.

_GetAlpha ( uint rgbBytes ) : byte

Gets the value for alpha, hopefully the compiler inlines that.

_GetBlue ( uint rgbBytes ) : byte

Gets the value for blue, hopefully the compiler inlines that.

_GetGreen ( uint rgbBytes ) : byte

Gets the value for green, hopefully the compiler inlines that.

_GetRed ( uint rgbBytes ) : byte

Gets the value for red, hopefully the compiler inlines that.

sPixel ( dword rgbData ) : System.Diagnostics.Contracts

Prevents a default instance of the sPixel struct from being created.

Method Details

AbsDifference() public method

Calculates the absolute difference between to pixels.
public AbsDifference ( sPixel pixel ) : uint
pixel sPixel The pixel to differ to.
return uint

Clone() public method

Creates a new object that is a copy of the current instance.
public Clone ( ) : object
return object

Equals() public method

Determines whether the specified System.Object is equal to this instance.
public Equals ( object o ) : bool
o object The to compare with this instance.
return bool

Equals() public method

Determines whether the specified sPixel is equal to this instance.
public Equals ( sPixel pixel ) : bool
pixel sPixel The to compare with this instance.
return bool

FromFloat() public static method

public static FromFloat ( float red, float green, float blue, float alpha = 1f ) : sPixel
red float
green float
blue float
alpha float
return sPixel

FromGrey() public static method

Factory to create a sPixel instance from grey value.
public static FromGrey ( byte grey, byte alpha = 255 ) : sPixel
grey byte The grey value.
alpha byte The alpha value.
return sPixel

FromRGBA() public static method

Factory to create a sPixel instance from red, green and blue value.
public static FromRGBA ( byte red, byte green, byte blue, byte alpha = 255 ) : sPixel
red byte The red-value.
green byte The green-value.
blue byte The blue-value.
alpha byte The alpha-value.
return sPixel

FromRGBA() public static method

Factory to create a sPixel instance from red, green and blue value.
public static FromRGBA ( int red, int green, int blue, int alpha = 255 ) : sPixel
red int The red-value.
green int The green-value.
blue int The blue-value.
alpha int The alpha-value.
return sPixel

GetHashCode() public method

Returns a hash code for this instance.
public GetHashCode ( ) : int
return int

GetObjectData() public method

Serializes this instance.
public GetObjectData ( SerializationInfo serializationInfo, StreamingContext _ ) : void
serializationInfo System.Runtime.Serialization.SerializationInfo The serialization info.
_ System.Runtime.Serialization.StreamingContext The streaming context.
return void

Interpolate() public static method

Interpolates two sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2 ) : sPixel
pixel1 sPixel The first pixel instance.
pixel2 sPixel The second pixel instance.
return sPixel

Interpolate() public static method

Weighted interpolation of two sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2, byte quantifier1, byte quantifier2 ) : sPixel
pixel1 sPixel The first instance.
pixel2 sPixel The second instance.
quantifier1 byte The quantifier for the first instance.
quantifier2 byte The quantifier for the second instance.
return sPixel

Interpolate() public static method

Interpolates three sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3 ) : sPixel
pixel1 sPixel The first pixel instance.
pixel2 sPixel The second pixel instance.
pixel3 sPixel The third pixel instance.
return sPixel

Interpolate() public static method

Weighted interpolation of three sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, byte quantifier1, byte quantifier2, byte quantifier3 ) : sPixel
pixel1 sPixel The first instance.
pixel2 sPixel The second instance.
pixel3 sPixel The third instance.
quantifier1 byte The quantifier for the first instance.
quantifier2 byte The quantifier for the second instance.
quantifier3 byte The quantifier for the third instance.
return sPixel

Interpolate() public static method

Interpolates four sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, sPixel pixel4 ) : sPixel
pixel1 sPixel The first pixel instance.
pixel2 sPixel The second pixel instance.
pixel3 sPixel The third pixel instance.
pixel4 sPixel The fourth pixel instance.
return sPixel

Interpolate() public static method

Weighted interpolation of four sPixel instances.
public static Interpolate ( sPixel pixel1, sPixel pixel2, sPixel pixel3, sPixel pixel4, byte quantifier1, byte quantifier2, byte quantifier3, byte quantifier4 ) : sPixel
pixel1 sPixel The first instance.
pixel2 sPixel The second instance.
pixel3 sPixel The third instance.
pixel4 sPixel The fourth instance.
quantifier1 byte The quantifier for the first instance.
quantifier2 byte The quantifier for the second instance.
quantifier3 byte The quantifier for the third instance.
quantifier4 byte The quantifier for the fourth instance.
return sPixel

IsLike() public method

Determines whether the specified sPixel instance is similar to this instance.
public IsLike ( sPixel pixel ) : bool
pixel sPixel The instance to compare to.
return bool

IsNotLike() public method

Determines whether this instance is not like the specified sPixel instance.
public IsNotLike ( sPixel pixel ) : bool
pixel sPixel The instance to compare to.
return bool

ToString() public method

Returns a System.String that represents this instance.
public ToString ( ) : string
return string

operator() public static method

Test for inequality of at least one color component.
public static operator ( ) : bool
return bool

operator() public static method

Inverts the given color.
public static operator ( ) : sPixel
return sPixel

sPixel() public method

Initializes a new instance of the sPixel struct by using an instance of a the Color class.
public sPixel ( Color color ) : System.Diagnostics.Contracts
color Color The color.
return System.Diagnostics.Contracts

sPixel() public method

Initializes a new instance of the sPixel struct by deserializing it.
public sPixel ( SerializationInfo serializationInfo, StreamingContext _ ) : System.Diagnostics.Contracts
serializationInfo System.Runtime.Serialization.SerializationInfo The serialization info.
_ System.Runtime.Serialization.StreamingContext The streaming context.
return System.Diagnostics.Contracts

sPixel() public method

Initializes a new instance of the sPixel struct by using a grey value.
public sPixel ( byte grey, byte alpha = 255 ) : System.Diagnostics.Contracts
grey byte The grey value.
alpha byte The alpha value.
return System.Diagnostics.Contracts

sPixel() public method

Initializes a new instance of the sPixel struct by using red, green and blue component.
public sPixel ( byte red, byte green, byte blue, byte alpha = 255 ) : System.Diagnostics.Contracts
red byte The red-value.
green byte The green-value.
blue byte The blue-value.
alpha byte The alpha-value.
return System.Diagnostics.Contracts

sPixel() public method

Initializes a new instance of the sPixel struct by using red, green and blue component.
public sPixel ( double red, double green, double blue, double alpha = 1 ) : System.Diagnostics.Contracts
red double The red-value.
green double The green-value.
blue double The blue-value.
alpha double The alpha.
return System.Diagnostics.Contracts

sPixel() public method

Initializes a new instance of the sPixel struct by using an existing one.
public sPixel ( sPixel pixel ) : System.Diagnostics.Contracts
pixel sPixel The pixel instance to copy from.
return System.Diagnostics.Contracts

Property Details

AllowThresholds public_oe static_oe property

true when IsLike and IsNotLike should allow little differencies in comparison; otherwise, false.
public static bool AllowThresholds
return bool

Black public_oe static_oe property

Black
public static sPixel,Imager Black
return sPixel

ColorExtractionFactor public_oe static_oe property

Factor that is used to avoid noise in color extraction. The higher the factor, the lesser colors will be detected.
public static double ColorExtractionFactor
return double

Purple public_oe static_oe property

Purple
public static sPixel,Imager Purple
return sPixel

White public_oe static_oe property

White
public static sPixel,Imager White
return sPixel