+ self._dither = dither
+ self._depth = 16
+
+ def _compute_rgb565(self, color):
+ self._depth = 16
+ return (color >> 19) << 11 | ((color >> 10) & 0x3F) << 5 | (color >> 3) & 0x1F
+
+ def _compute_luma(self, color):
+ r8 = color >> 16
+ g8 = (color >> 8) & 0xFF
+ b8 = color & 0xFF
+ return (r8 * 19) / 255 + (g8 * 182) / 255 + (b8 + 54) / 255
+
+ def _compute_chroma(self, color):
+ r8 = color >> 16
+ g8 = (color >> 8) & 0xFF
+ b8 = color & 0xFF
+ return max(r8, g8, b8) - min(r8, g8, b8)
+
+ def _compute_hue(self, color):
+ r8 = color >> 16
+ g8 = (color >> 8) & 0xFF
+ b8 = color & 0xFF
+ max_color = max(r8, g8, b8)
+ chroma = self._compute_chroma(color)
+ if chroma == 0:
+ return 0
+ hue = 0
+ if max_color == r8:
+ hue = (((g8 - b8) * 40) / chroma) % 240
+ elif max_color == g8:
+ hue = (((b8 - r8) + (2 * chroma)) * 40) / chroma
+ elif max_color == b8:
+ hue = (((r8 - g8) + (4 * chroma)) * 40) / chroma
+ if hue < 0:
+ hue += 240
+
+ return hue
+
+ def _dither_noise_1(self, noise):
+ n = (n >> 13) ^ n
+ nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7FFFFFFF
+ return (nn / (1073741824.0 * 2)) * 255
+
+ def _dither_noise_2(self, x, y):
+ return self._dither_noise_1(x + y * 0xFFFF)
+
+ def _compute_tricolor(self):
+ pass
+