Make RAW option explicitly little-endian and ensure that bmp2rb works the same on both little-endian and big-endian hosts. Fix bug with generating <= 8-bit raw output on big-endian hosts. Also remove TAB characters, C99 variable declarations and extremely long lines in the source.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12063 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2007-01-18 09:30:25 +00:00
parent 186623e709
commit 024537d5b6

View file

@ -497,10 +497,12 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
fprintf(f, "\n};\n");
}
void generate_raw_file(char *id, char* header_dir, int width, int height, const unsigned short *t_bitmap, int t_width, int t_height, int t_depth, bool swap)
void generate_raw_file(char *id, const unsigned short *t_bitmap,
int t_width, int t_height, int t_depth)
{
FILE *f;
int i, a;
unsigned char lo,hi;
f = stdout;
@ -509,15 +511,17 @@ void generate_raw_file(char *id, char* header_dir, int width, int height, const
for (a = 0; a < t_width; a++)
{
if (t_depth <= 8)
fwrite(&t_bitmap[i * t_width + a], 1, 1, f);
else {
unsigned short w;
w = t_bitmap[i * t_width + a];
if(swap)
w = swab(w);
fwrite(&w, 2, 1, f);
}
{
lo = (t_bitmap[i * t_width + a] & 0x00ff);
fwrite(&lo, 1, 1, f);
}
else
{
lo = (t_bitmap[i * t_width + a] & 0x00ff);
hi = (t_bitmap[i * t_width + a] & 0xff00) >> 8;
fwrite(&lo, 1, 1, f);
fwrite(&hi, 1, 1, f);
}
}
}
}
@ -552,8 +556,7 @@ void print_usage(void)
"\t-i <id> Bitmap name (default is filename without extension)\n"
"\t-h <dir> Create header file in <dir>/<id>.h\n"
"\t-a Show ascii picture of bitmap\n"
"\t-r Generate RAW file\n"
"\t-b swap bytes\n"
"\t-r Generate RAW file (little-endian)\n"
"\t-f <n> Generate destination format n, default = 0\n"
"\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n"
"\t 1 Archos player graphics library\n"
@ -580,7 +583,6 @@ int main(int argc, char **argv)
int width, height;
int t_width, t_height, t_depth;
bool raw = false;
bool swap = false;
for (i = 1;i < argc;i++)
@ -630,10 +632,6 @@ int main(int argc, char **argv)
case 'r': /* Raw File */
raw = true;
break;
case 'b': /* Swap bytes */
swap = true;
break;
case 'f':
if (argv[i][2])
@ -701,12 +699,14 @@ int main(int argc, char **argv)
}
else
{
if (transform_bitmap(bitmap, width, height, format, &t_bitmap, &t_width, &t_height, &t_depth))
if (transform_bitmap(bitmap, width, height, format, &t_bitmap,
&t_width, &t_height, &t_depth))
exit(1);
if(raw)
generate_raw_file(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth, swap);
generate_raw_file(id, t_bitmap, t_width, t_height, t_depth);
else
generate_c_source(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth);
generate_c_source(id, header_dir, width, height, t_bitmap,
t_width, t_height, t_depth);
}
return 0;