makecol15_dither(3alleg4)

πŸ’– makecol15_dither β€” bestie edition πŸ’–

okay so this is a page from the Allegro manual (that's the 3alleg4 section, iykyk) and it's about two lil functions that make dithered 15-bit and 16-bit RGB values for you. no cap, they're lowkey iconic for retro graphics.


✨ NAME ✨

makecol15_dither, makecol16_dither β€” they calculate a dithered 15-bit or 16-bit RGB value. yes bestie, that's the whole job. it's giving "Allegro game programming library" energy πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int makecol15_dither(int r, int g, int b, int x, int y);

int makecol16_dither(int r, int g, int b, int x, int y);

like, include the header, call the function, get a color. simple as that fr fr.


🌸 DESCRIPTION 🌸

so here's the tea β˜•: you hand over both a color value and a pixel coordinate, and these functions hand you back a dithered 15-bit or 16-bit RGB value. the whole point is that this can produce better results when reducing images from truecolor down to hicolor. she's not just a color maker, she's a color glow-up specialist.

and it gets better β€” you don't even have to call these directly if you don't wanna. hicolor dithering can be automatically enabled when you load graphics, by calling the set_color_conversion() function. for example:

set_color_conversion(COLORCONV_REDUCE_TRUE_TO_HI | COLORCONV_DITHER);

look at that flag combo. the way that COLORCONV_REDUCE_TRUE_TO_HI and COLORCONV_DITHER are just vibing together with a |? obsessed. 😭

πŸŽ€ Example πŸŽ€

here's the example straight from the page, and pls read the comment because it's important:

int pixel1, pixel2;

/* The following two color values MAY be different. */
pixel1 = makecol16_dither(255, 192, 64, 0, 0);
pixel2 = makecol16_dither(255, 192, 64, 1, 0);

notice how the RGB values are identical but the coordinates are different (0, 0 vs 1, 0) β€” and the results MAY be different. that's the dithering doing its little thing. main character behavior honestly. ✨


πŸ’« RETURN VALUE πŸ’«

returns the RGB value, dithered for the specified coordinate. that's it, that's the return. no drama, just a dithered color. 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next bestie, they're all in the same friend group:


⚠️ reminder that the two color values in the example MAY be different β€” that's not a bug, that's literally the dithering working as intended. don't come for her. πŸ’€

and that's the whole page, bestie! this was Allegro version 4.4.3 and the manual page is makecol15_dither(3alleg4). go forth and dither responsibly. slay πŸ’…πŸŒˆβ­