forked from len0rd/rockbox
made it output valid C code even if given a filename that starts with a
dot, also made the width and height get written as proper #defines in the output C source. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1795 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
eac3cfd8a7
commit
8c78975300
1 changed files with 8 additions and 3 deletions
|
|
@ -140,7 +140,6 @@ int read_bmp_file(char* filename,
|
||||||
close(fd);
|
close(fd);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
debugf("Bitmap is %d pixels wide\n", readlong(fh.Width));
|
|
||||||
|
|
||||||
/* Exit if too high */
|
/* Exit if too high */
|
||||||
if(readlong(fh.Height) > 64)
|
if(readlong(fh.Height) > 64)
|
||||||
|
|
@ -150,7 +149,6 @@ int read_bmp_file(char* filename,
|
||||||
close(fd);
|
close(fd);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
debugf("Bitmap is %d pixels heigh\n", readlong(fh.Height));
|
|
||||||
|
|
||||||
for(l=0;l < 2;l++)
|
for(l=0;l < 2;l++)
|
||||||
{
|
{
|
||||||
|
|
@ -243,7 +241,14 @@ void generate_c_source(char *id, int width, int height, unsigned char *bitmap)
|
||||||
|
|
||||||
f = stdout;
|
f = stdout;
|
||||||
|
|
||||||
fprintf(f, "\nconst unsigned char %s[] = {\n", id);
|
if(!id || !id[0])
|
||||||
|
id = "bitmap";
|
||||||
|
|
||||||
|
fprintf(f,
|
||||||
|
"#define BMPHEIGHT_%s %d"
|
||||||
|
"\n#define BMPWIDTH_%s %d"
|
||||||
|
"\nconst unsigned char %s[] = {\n",
|
||||||
|
id, height, id, width, id );
|
||||||
|
|
||||||
for(i=0, eline=0; i< height; i+=8, eline++) {
|
for(i=0, eline=0; i< height; i+=8, eline++) {
|
||||||
for (a=0; a<width; a++) fprintf(f, "0x%02x, ", bitmap[eline*width + a]);
|
for (a=0; a<width; a++) fprintf(f, "0x%02x, ", bitmap[eline*width + a]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue