C# Class Axiom.Media.Bitwise

Class for manipulating bit patterns.
Datei anzeigen Open project: WolfgangSt/axiom Class Usage Examples

Public Methods

Method Description
FirstPO2From ( uint n ) : uint

Returns the closest power-of-two number greater or equal to value.

0 and 1 are powers of two, so firstPO2From(0)==0 and firstPO2From(1)==1.

FixedToByteFixed ( uint value, int p ) : byte

Convert N bit colour channel value to 8 bits, and return as a byte. It fills P bits with thebit pattern repeated. (this is /((1<<n)-1) in fixed point)

FixedToFixed ( uint value, int n, int p ) : uint

Convert N bit colour channel value to P bits. It fills P bits with the bit pattern repeated. (this is /((1<<n)-1) in fixed point)

FixedToFloat ( uint value, int bits ) : float

Fixed point to float

FloatToByteFixed ( float value ) : byte

Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to an 8-bit integer, and return as a byte.

FloatToFixed ( float value, int bits ) : uint

Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to integer of a certain number of bits. Works for any value of bits between 0 and 31.

FloatToHalf ( float f ) : ushort

Convert a float32 to a float16 (NV_half_float) Courtesy of OpenEXR

FloatToHalfI ( uint i ) : ushort

Converts float in uint format to a a half in ushort format

HalfToFloat ( ushort y ) : float

Convert a float16 (NV_half_float) to a float32 Courtesy of OpenEXR

HalfToFloatI ( ushort y ) : uint

Converts a half in ushort format to a float in uint format

IntRead ( IntPtr src, int n ) : uint

Read a n*8 bits integer value to memory in native endian.

IntWrite ( IntPtr dest, int n, uint value ) : void
IsPow2 ( int number ) : bool

checks if a number is a power of 2

MostSignificantBitSet ( uint value ) : uint

Returns the most significant bit set in a value.

Method Details

FirstPO2From() public static method

Returns the closest power-of-two number greater or equal to value.
0 and 1 are powers of two, so firstPO2From(0)==0 and firstPO2From(1)==1.
public static FirstPO2From ( uint n ) : uint
n uint
return uint

FixedToByteFixed() public static method

Convert N bit colour channel value to 8 bits, and return as a byte. It fills P bits with thebit pattern repeated. (this is /((1<<n)-1) in fixed point)
public static FixedToByteFixed ( uint value, int p ) : byte
value uint
p int
return byte

FixedToFixed() public static method

Convert N bit colour channel value to P bits. It fills P bits with the bit pattern repeated. (this is /((1<<n)-1) in fixed point)
public static FixedToFixed ( uint value, int n, int p ) : uint
value uint
n int
p int
return uint

FixedToFloat() public static method

Fixed point to float
public static FixedToFloat ( uint value, int bits ) : float
value uint
bits int
return float

FloatToByteFixed() public static method

Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to an 8-bit integer, and return as a byte.
public static FloatToByteFixed ( float value ) : byte
value float
return byte

FloatToFixed() public static method

Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) to integer of a certain number of bits. Works for any value of bits between 0 and 31.
public static FloatToFixed ( float value, int bits ) : uint
value float
bits int
return uint

FloatToHalf() public static method

Convert a float32 to a float16 (NV_half_float) Courtesy of OpenEXR
public static FloatToHalf ( float f ) : ushort
f float
return ushort

FloatToHalfI() public static method

Converts float in uint format to a a half in ushort format
public static FloatToHalfI ( uint i ) : ushort
i uint
return ushort

HalfToFloat() public static method

Convert a float16 (NV_half_float) to a float32 Courtesy of OpenEXR
public static HalfToFloat ( ushort y ) : float
y ushort
return float

HalfToFloatI() public static method

Converts a half in ushort format to a float in uint format
public static HalfToFloatI ( ushort y ) : uint
y ushort
return uint

IntRead() public static method

Read a n*8 bits integer value to memory in native endian.
public static IntRead ( IntPtr src, int n ) : uint
src System.IntPtr
n int
return uint

IntWrite() public static method

public static IntWrite ( IntPtr dest, int n, uint value ) : void
dest System.IntPtr
n int
value uint
return void

IsPow2() public static method

checks if a number is a power of 2
public static IsPow2 ( int number ) : bool
number int
return bool

MostSignificantBitSet() public static method

Returns the most significant bit set in a value.
public static MostSignificantBitSet ( uint value ) : uint
value uint
return uint