mediaLib Library Functions mlib_ImageDataTypeConvert(3MLIB)
NAME
mlib_ImageDataTypeConvert - data type conversion
SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ]
#include
mlib_status mlib_ImageDataTypeConvert(mlib_image *dst, const mlib_image *src);
DESCRIPTION
The mlib_ImageDataTypeConvert() function converts between
data types MLIB_BIT, MLIB_BYTE, MLIB_SHORT, MLIB_USHORT,
MLIB_INT, MLIB_FLOAT, and MLIB_DOUBLE.
The input and output data images must have the same width, height, and number of channels. Conversion to a smaller pixel format clamps the source value to the dynamic range of the destination pixel. See the following table for available variations of the data type conversion function. Source Type Dest. Type Action___________________________________________________________________________________
MLIB_BYTE MLIB_BIT (x > 0) ? 1 : 0
MLIB_SHORT MLIB_BIT (x > 0) ? 1 : 0
___________________________________________________________________________________
MLIB_USHORT MLIB_BIT (x > 0) ? 1 : 0
___________________________________________________________________________________
MLIB_INT MLIB_BIT (x > 0) ? 1 : 0
___________________________________________________________________________________
MLIB_FLOAT MLIB_BIT (x > 0) ? 1 : 0
___________________________________________________________________________________
MLIB_DOUBLE MLIB_BIT (x > 0) ? 1 : 0
___________________________________________________________________________________
MLIB_BIT MLIB_BYTE (x == 1) ? 1 : 0
___________________________________________________________________________________
MLIB_SHORT MLIB_BYTE (mlib_u8)clamp(x, 0, 255)
___________________________________________________________________________________
MLIB_USHORT MLIB_BYTE (mlib_u8)clamp(x, 0, 255)
___________________________________________________________________________________
MLIB_INT MLIB_BYTE (mlib_u8)clamp(x, 0, 255)
___________________________________________________________________________________
MLIB_FLOAT MLIB_BYTE (mlib_u8)clamp(x, 0, 255)
___________________________________________________________________________________
MLIB_DOUBLE MLIB_BYTE (mlib_u8)clamp(x, 0, 255)
___________________________________________________________________________________
SunOS 5.11 Last change: 2 Mar 2007 1
mediaLib Library Functions mlib_ImageDataTypeConvert(3MLIB)
MLIB_BIT MLIB_SHORT (x == 1) ? 1 : 0
___________________________________________________________________________________
MLIB_BYTE MLIB_SHORT (mlib_s16)x
___________________________________________________________________________________
MLIB_USHORT MLIB_SHORT (mlib_s16)clamp(x, -32768, 32767)
___________________________________________________________________________________
MLIB_INT MLIB_SHORT (mlib_s16)clamp(x, -32768, 32767)
___________________________________________________________________________________
MLIB_FLOAT MLIB_SHORT (mlib_s16)clamp(x, -32768, 32767)
___________________________________________________________________________________
MLIB_DOUBLE MLIB_SHORT (mlib_s16)clamp(x, -32768, 32767)
___________________________________________________________________________________
MLIB_BIT MLIB_USHORT (x == 1) ? 1 : 0
___________________________________________________________________________________
MLIB_BYTE MLIB_USHORT (mlib_u16)x
___________________________________________________________________________________
MLIB_SHORT MLIB_USHORT (mlib_u16)clamp(x, 0, 65535)
___________________________________________________________________________________
MLIB_INT MLIB_USHORT (mlib_u16)clamp(x, 0, 65535)
___________________________________________________________________________________
MLIB_FLOAT MLIB_USHORT (mlib_u16)clamp(x, 0, 65535)
___________________________________________________________________________________
MLIB_DOUBLE MLIB_USHORT (mlib_u16)clamp(x, 0, 65535)
___________________________________________________________________________________
MLIB_BIT MLIB_INT (x == 1) ? 1 : 0
___________________________________________________________________________________
MLIB_BYTE MLIB_INT (mlib_s32)x
___________________________________________________________________________________
MLIB_SHORT MLIB_INT (mlib_s32)x
___________________________________________________________________________________
MLIB_USHORT MLIB_INT (mlib_s32)x
___________________________________________________________________________________
MLIB_FLOAT MLIB_INT (mlib_s32)clamp(x, -2147483647-1, 2147483647)
___________________________________________________________________________________
MLIB_DOUBLE MLIB_INT (mlib_s32)clamp(x, -2147483647-1, 2147483647)
___________________________________________________________________________________
MLIB_BIT MLIB_FLOAT (x == 1) ? 1.0 : 0.0
___________________________________________________________________________________
MLIB_BYTE MLIB_FLOAT (mlib_f32)x
___________________________________________________________________________________
MLIB_SHORT MLIB_FLOAT (mlib_f32)x
___________________________________________________________________________________
MLIB_USHORT MLIB_FLOAT (mlib_f32)x
___________________________________________________________________________________
MLIB_INT MLIB_FLOAT (mlib_f32)x
___________________________________________________________________________________
MLIB_DOUBLE MLIB_FLOAT (mlib_f32)x
___________________________________________________________________________________
MLIB_BIT MLIB_DOUBLE (x == 1) ? 1.0 : 0.0
___________________________________________________________________________________
MLIB_BYTE MLIB_DOUBLE (mlib_d64)x
___________________________________________________________________________________
SunOS 5.11 Last change: 2 Mar 2007 2
mediaLib Library Functions mlib_ImageDataTypeConvert(3MLIB)
MLIB_SHORT MLIB_DOUBLE (mlib_d64)x
___________________________________________________________________________________
MLIB_USHORT MLIB_DOUBLE (mlib_d64)x
___________________________________________________________________________________
MLIB_INT MLIB_DOUBLE (mlib_d64)x
___________________________________________________________________________________
MLIB_FLOAT MLIB_DOUBLE (mlib_d64)x
The actions are defined in C-style pseudo-code. All type
casts follow the rules of standard C. clamp() can be definedas a macro: #define clamp(x, low, high) (((x) < (low)) ?
(low) : (((x) > (high)) ? (high) : (x)))PARAMETERS
The function takes the following arguments: dst Pointer to destination image. src Pointer to source image.RETURN VALUES
The function returns MLIB_SUCCESS if successful. Otherwise
it returns MLIB_FAILURE.
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| MT-Level | MT-Safe |
|_____________________________|_____________________________|
SEE ALSO
mlib_ImageReformat(3MLIB), attributes(5)
SunOS 5.11 Last change: 2 Mar 2007 3