c = grid[i + j * width];
if (c >= 0) {
r = (int) (c >> 16);
g = (int) ((c >> 8) & 0xff);
b = (int) (c & 0xff);
<BUG>m = Math.max(g + b, Math.max(r + b, r + g)); // max of m = 0x1fe
n = Math.max(r, Math.max(g, b));
d = 1 + ((m + n) / 0x1ff);
if (complementary) {
wr.setPixel(i, j, new int[]{(m + 2 * r - g - b) / d, (m + 2 * g - r - b) / d , (m + 2 * b - r - g) / d});

} else {
wr.setPixel(i, j, new int[]{r, g, b});
}</BUG>
}

c = grid[i + j * width];
if (c >= 0) {
r = (int) (c >> 16);
g = (int) ((c >> 8) & 0xff);
b = (int) (c & 0xff);
wr.setPixel(i, j, new int[]{(0x1fe - g - b) / 2, (0x1fe - r - b) / 2, (0x1fe - r - g) / 2});
