To write BMP, you can use, for example, the arsd library, from which you will need the bmp and color modules.
import arsd.bmp, arsd.color; void main() { ubyte[][] image = [ [ 0, 0, 0, 0, 0, 0, 0, 1], [ 0, 0, 0, 0, 0, 0, 1, 1], [ 0, 0, 0, 0, 0, 1, 1, 1], [ 0, 0, 0, 0, 1, 1, 1, 1], [ 0, 0, 0, 1, 1, 1, 1, 1], [ 0, 0, 1, 1, 1, 1, 1, 1], [ 0, 1, 1, 1, 1, 1, 1, 1], [ 1, 1, 1, 1, 1, 1, 1, 1], [ 0, 1, 0, 1, 0, 1, 0, 1], ]; auto col = [Color.black, Color.green]; auto w = image[0][].length; auto h = image[].length; ubyte[] data; for (int j=0; j<h; j++) { for (int i=0; i<w; i++) { auto val = image[j][i]; data ~= col[val].r; data ~= col[val].g; data ~= col[val].b; data ~= col[val].a; } } auto img = new TrueColorImage(w, h, data); writeBmp(img, "result.bmp"); }