Macros

Macros — Macros

Functions

#define oil_min()
#define oil_max()
#define oil_divide_255()
#define oil_argb()
#define oil_argb_noclamp()
#define oil_argb_A()
#define oil_argb_G()
#define oil_argb_B()
#define oil_argb_R()
#define oil_muldiv_255()
#define oil_clamp_255()
#define OIL_GET()
#define OIL_OFFSET()
#define OIL_INCREMENT()

Description

Functions

oil_min()

#define oil_min(x,y) ((x)<(y)?(x):(y))

Evaluates to the minimum of x and y .

Parameters

x

a value

 

y

a value

 

oil_max()

#define oil_max(x,y) ((x)>(y)?(x):(y))

Evaluates to the maximum of x and y .

Parameters

x

a value

 

y

a value

 

oil_divide_255()

#define oil_divide_255(x) ((((x)+128) + (((x)+128)>>8))>>8)

Divides x by 255 in a way that is compatible with the pixel operations in Liboil. The number 65025 is 255*255.

Evaluates to x divided by 255.

Parameters

x

a value in the range [0,65025]

 

oil_argb()

#define             oil_argb(a,r,g,b)

Creates a Liboil ARGB value from individual components. Clamps each component to [0,255].

Evaluates to the ARGB value

Parameters

a

alpha component

 

r

red component

 

g

green component

 

b

blue component

 

oil_argb_noclamp()

#define             oil_argb_noclamp(a,r,g,b)

Creates a Liboil ARGB value from individual components. Does not clamp components.

Evaluates to the ARGB value

Parameters

a

alpha component

 

r

red component

 

g

green component

 

b

blue component

 

oil_argb_A()

#define oil_argb_A(color) (((color)>>24)&0xff)

Extracts the alpha component from color .

Evaluates to the alpha component

Parameters

color

an ARGB value

 

oil_argb_G()

#define oil_argb_G(color) (((color)>>8)&0xff)

Extracts the green component from color .

Evaluates to the green component

Parameters

color

an ARGB value

 

oil_argb_B()

#define oil_argb_B(color) (((color)>>0)&0xff)

Extracts the blue component from color .

Evaluates to the blue component

Parameters

color

an ARGB value

 

oil_argb_R()

#define oil_argb_R(color) (((color)>>16)&0xff)

Extracts the red component from color .

Evaluates to the red component

Parameters

color

an ARGB value

 

oil_muldiv_255()

#define oil_muldiv_255(a,b) oil_divide_255((a)*(b))

Multiplies a and b and divides the result by 255 in a way that is compatible with the pixel operations in Liboil.

Evaluates to the result.

Parameters

a

a value in the range [0,255]

 

b

a value in the range [0,255]

 

oil_clamp_255()

#define oil_clamp_255(x) oil_max(0,oil_min((x),255))

Clamps x to the range [0,255].

Evaluates to the clamped value.

Parameters

x

a value

 

OIL_GET()

#define OIL_GET(ptr, offset, type) (*(type *)((uint8_t *)(ptr) + (offset)) )

Offsets ptr by offset number of bytes, and dereferences it as type type . Note that the offset is in bytes, and not in the size of the pointer type.


OIL_OFFSET()

#define OIL_OFFSET(ptr, offset) ((void *)((uint8_t *)(ptr) + (offset)) )

Add offset bytes to the pointer ptr .


OIL_INCREMENT()

#define OIL_INCREMENT(ptr, offset) (ptr = (void *)((uint8_t *)ptr + (offset)) )

Increments the pointer ptr by offset number of bytes.