// 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){

		if((i % 6) == 0){
			fputs("\n   ", f);
		}

		unsigned int pixel = 0;

		pixel |= *p++ << 16L;
		pixel |= *p++ << 8L;
		pixel |= *p++;
		pixel |= *p++ << 24L;

		fprintf(f, " 0x%08x,", pixel);
	}

	fputs("\n};\n", f);

	fclose(f);

	puts("Generated linux icon in " OUTPUT_FILE);
}