READCOLMAP(3)
π READCOLMAP(3) β the one where we access the display color map
okay bestie, so this is a page from the Library Functions Manual and it's all about RGB, readcolmap, and writecolmap β aka how you get your hands on a display's color map. it's giving very old-school graphics energy and honestly? iconic. β¨
π SYNOPSIS
#include <u.h>
#include <libc.h>
#include <draw.h>
int readcolmap(Display *d, RGB *map)
int writecolmap(Display *d, RGB *map)
π DESCRIPTION
so first things first, bestie: colors get described by their red, green, and blue light intensities, all cozy inside an RGB datum. it looks like this:
typedef
struct RGB {
ulong red;
ulong green;
ulong blue;
} RGB;
now the vibe check: black is literally zero in all three positions π€, and white is the maximum unsigned long value in all three positions π€. no in-between drama, just full send.
a color map is an array of RGBs, of length 2^depth, and it gives you the colors for pixels 0, 1, 2, etc. π so on displays with color mapped pixels (typically 8-bit displays β yes, the vintage ones π§), you retrieve RGB color information by treating the pixel data as an offset into the color map. that's it, that's the whole trick, iykyk. π
readcolmapβ reads the color map for the given display into the provided map, which must have enough space to hold it. don't be out here handing it a tiny buffer, it will not slay. πwritecolmapβ associates the given color map with the given display, if possible. (the hardware might not allow this β lowkey rude of it, but okay. π)
both of them return 0 on success, or -1 on error, setting errstr. so check your return values, bestie, fr fr. π«Ά
β οΈ the big caveat, do not skip this one: changing the hardware color map does not change the color map used by thedraw(3)operator to convert between mapped and true color or greyscale images. that one is described incolor(7). two different color maps, two different vibes, keep them straight. πΈ β
π₯ SOURCE
/src/libdraw
π SEE ALSO
and that's the page!! π¦ mwah π
signing off from the Library Functions Manual β this one's READCOLMAP(3), straight outta /src/libdraw ππ
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms