3 ms·
What are upsides of using this format instead of a more generic array of pixels (something like output of imagemagick to .h files or PPM files)? BTW I know one
by mkotowski 5y ago
What are upsides of using this format instead of a more generic array of pixels (something like output of imagemagick to .h files or PPM files)?
BTW I know one can use resource files (.rc) on Windows to embed various resources, but is there an analogous mechanism for linux binaries?
- yissp 5y agoThe examples in the wiki article show the difference pretty well. XPM lets you sort-of see what the image is just by looking at the source file. E.G. compare this static char blarg_bits[] = { 0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80, 0x00, 0x60 }; with this static char * blarg_xpm[] = { "16 7 2 1", "* c #000000", ". c #ffffff", "**..*...........", "*.*.*...........", "**..*..**.**..**", "*.*.*.*.*.*..*.*", "**..*..**.*...**", "...............*", ".............**." };
- electroly 5y agoOn Linux you can use "ld -o myobj.o -r -b binary myfile.dat" and it will generate a linkable object file that contains your file data as a byte array. However, other platforms do it other ways, so it's generally easier to use "xxd" from the vim package to generate a C source file with a literal array, similar to the way that XPM works. That will work on all platforms.