2016-03-21 18:21:21 +00:00
|
|
|
// NOTE(inso): how to use:
|
|
|
|
//
|
|
|
|
// load up the icon in gimp and choose export, select "c source code (*.c)" as the format
|
|
|
|
// call the file gimp_icon.c, then include it by uncommenting line below.
|
|
|
|
//
|
|
|
|
// make sure the struct in the .c file is called gimp_image (the default).
|
|
|
|
//
|
|
|
|
// then just compile and run this program and it'll create linux_icon.h
|
|
|
|
|
|
|
|
#include "stdio.h"
|
|
|
|
// #include "gimp_icon.c"
|
|
|
|
|
|
|
|
#define OUTPUT_FILE "linux_icon.h"
|
|
|
|
|
|
|
|
int main(void){
|
|
|
|
|
|
|
|
FILE* f = fopen(OUTPUT_FILE, "w");
|
|
|
|
|
|
|
|
fputs("/* Generated by gen_linux_icon.c */\n", f);
|
|
|
|
|
|
|
|
int w = gimp_image.width, h = gimp_image.height;
|
|
|
|
fprintf(f, "static const unsigned long linux_icon[] = {\n %d, %d,", w, h);
|
|
|
|
|
|
|
|
const unsigned char* p = gimp_image.pixel_data;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < (w*h); ++i){
|
|
|
|
|
2016-03-22 18:47:03 +00:00
|
|
|
if((i % 6) == 0){
|
2016-03-21 18:21:21 +00:00
|
|
|
fputs("\n ", f);
|
|
|
|
}
|
|
|
|
|
2016-03-22 18:47:03 +00:00
|
|
|
unsigned int pixel = 0;
|
2016-03-21 18:21:21 +00:00
|
|
|
|
|
|
|
pixel |= *p++ << 16L;
|
|
|
|
pixel |= *p++ << 8L;
|
|
|
|
pixel |= *p++;
|
|
|
|
pixel |= *p++ << 24L;
|
|
|
|
|
2016-03-22 18:47:03 +00:00
|
|
|
fprintf(f, " 0x%08x,", pixel);
|
2016-03-21 18:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fputs("\n};\n", f);
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
puts("Generated linux icon in " OUTPUT_FILE);
|
|
|
|
}
|