readcolmap 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. .TH READCOLMAP 2
  2. .SH NAME
  3. RGB, readcolmap, writecolmap \- access display color map
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .br
  9. .B #include <draw.h>
  10. .PP
  11. .PP
  12. .ta \w'\fLvoid 'u
  13. .PP
  14. .B
  15. int readcolmap(Display *d, RGB *map)
  16. .PP
  17. .B
  18. int writecolmap(Display *d, RGB *map)
  19. .fi
  20. .SH DESCRIPTION
  21. Colors are described by their red, green, and blue
  22. light intensities, in an
  23. .B RGB
  24. datum:
  25. .IP
  26. .EX
  27. .ta 6n
  28. typedef
  29. struct RGB {
  30. ulong red;
  31. ulong green;
  32. ulong blue;
  33. } RGB;
  34. .EE
  35. .PP
  36. Black is represented by zero in all three positions and
  37. white has the maximum
  38. .B unsigned
  39. .B long
  40. value in all three positions.
  41. .PP
  42. A color map is an array of
  43. .BR RGB s,
  44. of length
  45. .if t \x'-.8n'2\u\s-1\fIdepth\fP\s+1\d,
  46. .if n 2^\fIdepth\fP,
  47. giving the colors for pixels 0, 1, 2, etc.
  48. On displays with color mapped pixels
  49. (typically 8-bit displays),
  50. one retrieves RGB color information
  51. by treating the pixel data as an offset
  52. into the color map.
  53. .PP
  54. .I Readcolmap
  55. reads the color map for the given display into the provided
  56. .IR map ,
  57. which must have enough space to hold it.
  58. .I Writecolmap
  59. associates the given color map with the given display, if possible.
  60. (The hardware might not allow this.)
  61. Both return 0 on success, or \-1 on error, setting
  62. .IR errstr .
  63. .PP
  64. Changing the hardware color map does not change
  65. the color map used by the
  66. .IR draw (2)
  67. operator to convert between
  68. mapped and true color or greyscale images,
  69. which is described in
  70. .IR color (6).
  71. .SH SOURCE
  72. .B /sys/src/libdraw
  73. .SH "SEE ALSO"
  74. .IR graphics (2),
  75. .IR draw (3),
  76. .IR color (6)