MCPcopy Create free account
hub / github.com/NetHack/NetHack / pix_to_colormap

Function pix_to_colormap

win/X11/tile2x11.c:29–47  ·  view source on GitHub ↗

Look up the given pixel and return its colormap index. */

Source from the content-addressed store, hash-verified

27
28/* Look up the given pixel and return its colormap index. */
29static unsigned char
30pix_to_colormap(pixel pix)
31{
32 unsigned long i;
33
34 for (i = 0; i < header.ncolors; i++) {
35 if (pix.r == ColorMap[CM_RED][i]
36 && pix.g == ColorMap[CM_GREEN][i]
37 && pix.b == ColorMap[CM_BLUE][i])
38 break;
39 }
40
41 if (i == header.ncolors) {
42 Fprintf(stderr, "can't find color: [%u,%u,%u]\n", pix.r, pix.g,
43 pix.b);
44 exit(1);
45 }
46 return (unsigned char) (i & 0xFF);
47}
48
49/* Convert the tiles in the file to our format of bytes. */
50static unsigned long

Callers 1

convert_tilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected