c - How to save void * data into a header file? -


i working on images , procedurally generate images convert them dds or rtc1. due constrains of program, cannot open external files want them embedded code.

i found out gimp has "c header" exporter i'd myself generated textures.

using void* allow used types of data.

update: clarify things, thinking outputting unsigned int this:

void exporttoheader(const void* data, const uin32_t size, const char* name) {     uint32_t* pdata = (uint32_t*)data;      printf("void* %s = {\n");      // todo: handle last case     (int = 0; < size; ++i) {         printf("%s, ", pdata[i]);     }      printf("};\n");             } 

will compiler able understand ?

if understand correct want import binary image c code.

so in case is, write simple program dumps file list of bytes , write output this:

char mydata[] = { 122, 334, 45, ... }; 

then can include file , reference texture other c array.

to dump file rather simple (in pseudocode).

file = open(file); printf("char mydata[] = {\n"); while(file != eof) {     c = getc(file);     printf("%d, ", c); } close(file); printf("\n\;\n"); 

whith can include binary file in c code.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -