- for (x = y = 0; y < height; ++x < width || (x = 0, y++)) {
- unsigned long offset = (unsigned long) y * width + x;
- struct lbx_colour *c = &palette[pixels[offset]];
- unsigned char buf[4];
- bool vis;
-
- vis = mask[offset/CHAR_BIT] & (1u << offset%CHAR_BIT);
- buf[0] = c->red;
- buf[1] = c->green;
- buf[2] = c->blue;
- buf[3] = vis ? 63 : 0;
-
- if (fwrite(buf, 1, depth, f) < depth)
- goto err;
- }
- } else {
- depth = masked ? 2 : 1;