#include "image.h" #include void usage(void) { fprint(2, "usage: %s\n", argv0); exits("usage"); } void main(int argc, char **argv) { ImgHdr h; uchar buf[8192]; int n, m, o; Biobuf b; ARGBEGIN { default: usage(); } ARGEND if(argc != 0) usage(); if(fmtinstall('H', Hfmt) < 0) sysfatal("fmtinstall"); if(readimghdr(0, &h) < 0) sysfatal("header: %r"); fprint(1, "%H", h); n = Dy(h.r) * Dx(h.r) * chantodepth(h.chan)/8; o = 0; while((m = read(0, buf, sizeof buf)) > 0) { if(write(1, buf, m) != m) sysfatal("write: %r"); o += m; } if(m < 0) sysfatal("read: %r"); if(Binit(&b, 1, OWRITE) < 0) sysfatal("Binit"); while(o++ < n) Bputc(&b, 0); exits(nil); }