ref: e712b341a4b7ba5d7f9e6a52e8ef43d2e2c60bed
dir: /tocursor.c/
#include <u.h> #include <libc.h> void main(int argc, char **argv) { u32int b[5*12/4+16*16]; uchar clr[16*16/8], set[16*16/8]; int i; if(argc < 3){ fprint(2, "usage: png -9t <cursor.png | %s OFFSETX OFFSETY >/dev/snarf\n", argv[0]); exits("usage"); } if((i = readn(0, b, sizeof(b))) != sizeof(b)) sysfatal("short read: %d < %d (not r8g8b8a8?)", i, sizeof(b)); 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 < 16*16; 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); }