Graphics2D gr = bi.createGraphics();
gr.setBackground(Color.white);
gr.clearRect(0, 0, width, height);
WritableRaster wr = bi.getRaster();
long c;
<BUG>int r, g, b, m, n, d;
for (int i = width - 1; i >= 0; i--) {</BUG>
for (int j = height - 1; j >= 0; j--) {
c = grid[i + j * width];
if (c >= 0) {

Graphics2D gr = bi.createGraphics();
gr.setBackground(Color.white);
gr.clearRect(0, 0, width, height);
WritableRaster wr = bi.getRaster();
long c;
if (complementary) {
int r, g, b;
for (int i = width - 1; i >= 0; i--) {
for (int j = height - 1; j >= 0; j--) {
c = grid[i + j * width];
if (c >= 0) {
