OldSchool Library
|
Topics | |
Main | |
General | |
Colors | |
Color manipulation utilities. | |
Low level drawing | |
Macros | |
#define | oslRgbaGet8888(data, r, g, b, a) |
Extracts the R, G, B, A (Red, Green, Blue, Alpha) component values from a 32-bit color. | |
#define | oslRgbaGet4444(data, r, g, b, a) |
Extracts R, G, B, A values from a 4444 color. | |
#define | oslRgbaGet5551(data, r, g, b, a) |
Extracts R, G, B, A values from a 5551 color. | |
#define | oslRgbGet5650(data, r, g, b) |
Extracts R, G, B values from a 5650 color. | |
#define | oslRgbaGet4444f(data, r, g, b, a) |
Extracts R, G, B, A values from a 4444 color with finer precision. | |
#define | oslRgbaGet5551f(data, r, g, b, a) |
Extracts R, G, B, A values from a 5551 color with finer precision. | |
#define | oslRgbGet5650f(data, r, g, b) |
Extracts R, G, B values from a 5650 color with finer precision. | |
Drawing operations in OSLib.
#define oslRgbaGet8888 | ( | data, | |
r, | |||
g, | |||
b, | |||
a ) |
Extracts the R, G, B, A (Red, Green, Blue, Alpha) component values from a 32-bit color.
This macro takes a 32-bit color value and extracts the individual 8-bit R, G, B, and A components. The extracted values are stored in the variables provided as the second to fifth arguments.
data | The 32-bit color value from which to extract the components. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
a | The variable to store the alpha component (0-255). |
This example will print: 1 2 3 4
.
#define oslRgbaGet4444 | ( | data, | |
r, | |||
g, | |||
b, | |||
a ) |
Extracts R, G, B, A values from a 4444 color.
This macro takes a 16-bit color value in 4444 format and extracts the individual 8-bit R, G, B, and A components. The 4-bit components are expanded to 8-bit by multiplying with 16.
data | The 16-bit color value in 4444 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
a | The variable to store the alpha component (0-255). |
This example will print: 240 128 0 0
. The alpha value was 1 but was lost due to precision limits in 12-bit mode. The red color value was 255 but lost precision due to 12-bit conversion, resulting in 240 instead of 255. For more precise results, consider using the 'f' alternate routines like oslRgbaGet4444f
.
#define oslRgbaGet5551 | ( | data, | |
r, | |||
g, | |||
b, | |||
a ) |
Extracts R, G, B, A values from a 5551 color.
This macro takes a 16-bit color value in 5551 format and extracts the individual 8-bit R, G, B, and A components. The 5-bit components are expanded to 8-bit by multiplying with 8, and the 1-bit alpha is expanded to 8-bit by multiplying with 128.
data | The 16-bit color value in 5551 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
a | The variable to store the alpha component (0-255). |
This example will print the expanded values of the 5551 format color.
#define oslRgbGet5650 | ( | data, | |
r, | |||
g, | |||
b ) |
Extracts R, G, B values from a 5650 color.
This macro takes a 16-bit color value in 5650 format and extracts the individual 8-bit R, G, and B components. The 5-bit R and B components are expanded to 8-bit by multiplying with 8, and the 6-bit G component is expanded to 8-bit by multiplying with 4.
data | The 16-bit color value in 5650 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
This example will print the expanded values of the 5650 format color.
#define oslRgbaGet4444f | ( | data, | |
r, | |||
g, | |||
b, | |||
a ) |
Extracts R, G, B, A values from a 4444 color with finer precision.
This macro extracts the R, G, B, and A components from a 16-bit color value in 4444 format. It expands the 4-bit components to 8-bit values by using both bit-shifting and masking techniques to provide better color accuracy.
data | The 16-bit color value in 4444 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
a | The variable to store the alpha component (0-255). |
This example will provide more accurate color values compared to oslRgbaGet4444
.
#define oslRgbaGet5551f | ( | data, | |
r, | |||
g, | |||
b, | |||
a ) |
Extracts R, G, B, A values from a 5551 color with finer precision.
This macro extracts the R, G, B, and A components from a 16-bit color value in 5551 format. It provides more accurate color values by expanding the 5-bit components and the 1-bit alpha using bit-shifting and masking.
data | The 16-bit color value in 5551 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
a | The variable to store the alpha component (0-255). |
This example will provide more accurate color values compared to oslRgbaGet5551
.
#define oslRgbGet5650f | ( | data, | |
r, | |||
g, | |||
b ) |
Extracts R, G, B values from a 5650 color with finer precision.
This macro extracts the R, G, and B components from a 16-bit color value in 5650 format. It expands the 5-bit R and B components and the 6-bit G component to 8-bit values for more accurate color representation.
data | The 16-bit color value in 5650 format. |
r | The variable to store the red component (0-255). |
g | The variable to store the green component (0-255). |
b | The variable to store the blue component (0-255). |
This example will provide more accurate color values compared to oslRgbGet5650
.