ref: d8e653b95a6df550c71616ac69a21ab352dfc9ff
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+1] & 0xff){ if (b[15+i] < 0x4f4f4fff) set[i/8] |= 1<<(7-i&7); else 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); }