#include "image.h" #include void usage(void) { fprint(2, "usage: %s x y [color]\n", argv0); exits("usage"); } void main(int argc, char **argv) { Biobuf b; int x, y, n, m, o, l; ulong c; uchar buf[4]; ARGBEGIN { default: usage(); } ARGEND c = 0; switch(argc) { case 3: c = atoi(argv[2]); case 2: x = atoi(argv[0]); y = atoi(argv[1]); break; default: usage(); return; } if(fmtinstall('H', Hfmt) < 0) sysfatal("fmtinstall"); if(Binit(&b, 1, OWRITE) < 0) sysfatal("Binit: %r"); Bprint(&b, "%H", (ImgHdr){0, RGBA32, Rect(0, 0, x, y)}); BPLONG(buf, c); n = y*x*4; for(o = 0; o < n; o += m) { l = n-o > sizeof buf ? sizeof buf : n-o; if((m = Bwrite(&b, buf, l)) != l) sysfatal("write: %r"); } exits(nil); }