/* * I guess more for a feeling of completeness than anything else, * here is the 24bit to 12bit converter written in generic C. It's * so basic it should compile and run everywhere; it's been tested * on macosx. Compile and run like "24to12 <24bitrawinfile >foo.jbp" * * "Released to the public domain." * */ #include int nibcount = 0; void put4bits(int bits) { static unsigned char outbyte; outbyte = (outbyte << 4) | ((bits & 0xF)); if ((++nibcount & 1) == 0) /* Have a full byte every two nibbles*/ putchar(outbyte); } main() { int inbyte; while(1) { inbyte = getchar(); if (inbyte == EOF) break; put4bits((inbyte)>>4); } }