ref: aa515b1b5b5071884815b1e22bb01ade901d8c03
dir: /tocursor.c/
#include <u.h> #include <libc.h> void main(int argc, char **argv) { u32int b[1084/4]; uchar clr[2*16], set[2*16]; int i; if (argc < 3) { fprint(2, "usage: png -9t <cursor.png | %s OFFSETX OFFSETY >/dev/snarf\n", argv[0]); exits("usage"); } if (readn(0, b, sizeof(b)) != sizeof(b)) sysfatal("%r"); memset(clr, 0, sizeof(clr)); memset(set, 0, sizeof(set)); print("Cursor lol = {\n"); print("\t{%s, %s},\n", argv[1], argv[2]); for (i = 0; i < nelem(b); i++) { if (b[15+i] == 0x000000ff) set[i/8] |= 1<<(7-i&7); else if (b[15+i] == 0xffffffff) clr[i/8] |= 1<<(7-i&7); } print("\t{"); for (i = 0; i < sizeof(clr); i++) { if (i > 0 && !(i % 8)) print("\n\t "); print(" 0x%02x,", clr[i]); } print("\n\t},\n\t{"); for (i = 0; i < sizeof(set); i++) { if (i > 0 && !(i % 8)) print("\n\t "); print(" 0x%02x,", set[i]); } print("\n\t},\n};\n"); exits(nil); }