/*% cyntax % -lfb && cc -go # % -lfb * utah -- convert a utah format picture into a picio file. * doesn't do enough error checking. * A utah picture contains: * size data * ---- ---- * 2 magic number * 2 x position * 2 y position * 2 x size * 2 y size * 1 flags * 1 # of channels * 1 # of bits/channel (this program supports only 8 bits/channel) * 1 # of color map channels * 1 log2 of # of color map entries * ncolor background color (padded to even length) * 2*ncmap*(1< #include #include #include #include struct utah{ short magic; /* 0146122, all integers are filed lsb first */ short xpos, ypos; /* coordinates of upper-left corner */ short xsize, ysize; /* width, height */ unsigned char flags; /* see definitions below */ unsigned char ncolors; /* # of channels, not counting alpha */ char pixelbits; /* # of bits/channel, must be 8 */ unsigned char ncmap; /* # of channels of color map */ unsigned char cmaplen; /* 1<=0;--i) picwrite(f, utah.image+i*utah.xsize*utah.ncolors); } void main(int argc, char *argv[]){ switch(getflags(argc, argv, "n:1[name]")){ default: usage("[file]"); case 1: rdimage(rdhdr("/fd/0")); output(flag['n']?flag['n'][0]:0); break; case 2: rdimage(rdhdr(argv[1])); output(flag['n']?flag['n'][0]:argv[1]); break; } exits(0); }