makecol15_dither(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– makecol15_dither β€” the Allegro manual, but make it bestie-coded πŸŽ€

okay so this is a page from the Allegro manual (yes, that Allegro, the game programming library, she's iconic, she's legendary πŸ‘‘). Today's topic? makecol15_dither and her twin sister makecol16_dither. Let's get into it, no cap. ✨


✨ NAME ✨

makecol15_dither, makecol16_dither β€” these two calculate a dithered 15 or 16-bit RGB value. Allegro game programming library, obviously. πŸ¦‹


🌸 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, that's the whole vibe right there πŸ’…


πŸ’… DESCRIPTION πŸ’…

so bestie, here's the tea πŸ“: you give these functions both a color value AND a pixel coordinate, and they calculate a dithered 15 or 16-bit RGB value for you. That combo? That's the whole point. The coordinate matters, the color matters, they work together. main character energy fr fr.

Why would you even want this? Because it can produce better results when reducing images from truecolor to hicolor. That's the glow-up. That's the transformation arc. 🌈

And here's the part where you don't even have to call these functions directly if you don't want to: hicolor dithering can be automatically enabled when loading graphics by calling the set_color_conversion() function. Like, for example:

set_color_conversion(COLORCONV_REDUCE_TRUE_TO_HI | COLORCONV_DITHER);

see how she just handles it for you? obsessed. 😭

Example:

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 that MAY is in ALL CAPS in that comment β€” because the same RGB input at two different coordinates genuinely might come back as two different values. That's the dithering doing its thing, not a bug. slay. πŸ’–

⭐ RETURN VALUE ⭐

Returns the RGB value dithered for the specified coordinate. simple as that, bestie. 🫢


πŸŽ€ SEE ALSO πŸŽ€

go read those too, they're all connected, iykyk 🧚


and that's the page!! this was Allegro, version 4.4.3, and the whole thing is dated like the classic manual page it is β€” makecol15_dither(3), still serving looks since forever. πŸ’œβœ¨

later bestie, go dither some pixels πŸ¦‹

πŸ“¦ where this page comes from