diff options
author | Dave Chapman <dave@dchapman.com> | 2007-01-18 09:30:25 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-01-18 09:30:25 +0000 |
commit | 024537d5b6098434a4856e84b2c43ee306c578de (patch) | |
tree | d11697c6314df317089d466b7df3c5da2956e635 | |
parent | 186623e7092be0b7c4cb7b547a7258460b9da621 (diff) | |
download | rockbox-024537d5b6098434a4856e84b2c43ee306c578de.tar.gz rockbox-024537d5b6098434a4856e84b2c43ee306c578de.zip |
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
-rw-r--r-- | tools/bmp2rb.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c index 345f682499..7848298136 100644 --- a/tools/bmp2rb.c +++ b/tools/bmp2rb.c | |||
@@ -497,10 +497,12 @@ void generate_c_source(char *id, char* header_dir, int width, int height, | |||
497 | fprintf(f, "\n};\n"); | 497 | fprintf(f, "\n};\n"); |
498 | } | 498 | } |
499 | 499 | ||
500 | 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) | 500 | void generate_raw_file(char *id, const unsigned short *t_bitmap, |
501 | int t_width, int t_height, int t_depth) | ||
501 | { | 502 | { |
502 | FILE *f; | 503 | FILE *f; |
503 | int i, a; | 504 | int i, a; |
505 | unsigned char lo,hi; | ||
504 | 506 | ||
505 | f = stdout; | 507 | f = stdout; |
506 | 508 | ||
@@ -509,15 +511,17 @@ void generate_raw_file(char *id, char* header_dir, int width, int height, const | |||
509 | for (a = 0; a < t_width; a++) | 511 | for (a = 0; a < t_width; a++) |
510 | { | 512 | { |
511 | if (t_depth <= 8) | 513 | if (t_depth <= 8) |
512 | fwrite(&t_bitmap[i * t_width + a], 1, 1, f); | 514 | { |
513 | else { | 515 | lo = (t_bitmap[i * t_width + a] & 0x00ff); |
514 | unsigned short w; | 516 | fwrite(&lo, 1, 1, f); |
515 | 517 | } | |
516 | w = t_bitmap[i * t_width + a]; | 518 | else |
517 | if(swap) | 519 | { |
518 | w = swab(w); | 520 | lo = (t_bitmap[i * t_width + a] & 0x00ff); |
519 | fwrite(&w, 2, 1, f); | 521 | hi = (t_bitmap[i * t_width + a] & 0xff00) >> 8; |
520 | } | 522 | fwrite(&lo, 1, 1, f); |
523 | fwrite(&hi, 1, 1, f); | ||
524 | } | ||
521 | } | 525 | } |
522 | } | 526 | } |
523 | } | 527 | } |
@@ -552,8 +556,7 @@ void print_usage(void) | |||
552 | "\t-i <id> Bitmap name (default is filename without extension)\n" | 556 | "\t-i <id> Bitmap name (default is filename without extension)\n" |
553 | "\t-h <dir> Create header file in <dir>/<id>.h\n" | 557 | "\t-h <dir> Create header file in <dir>/<id>.h\n" |
554 | "\t-a Show ascii picture of bitmap\n" | 558 | "\t-a Show ascii picture of bitmap\n" |
555 | "\t-r Generate RAW file\n" | 559 | "\t-r Generate RAW file (little-endian)\n" |
556 | "\t-b swap bytes\n" | ||
557 | "\t-f <n> Generate destination format n, default = 0\n" | 560 | "\t-f <n> Generate destination format n, default = 0\n" |
558 | "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" | 561 | "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" |
559 | "\t 1 Archos player graphics library\n" | 562 | "\t 1 Archos player graphics library\n" |
@@ -580,7 +583,6 @@ int main(int argc, char **argv) | |||
580 | int width, height; | 583 | int width, height; |
581 | int t_width, t_height, t_depth; | 584 | int t_width, t_height, t_depth; |
582 | bool raw = false; | 585 | bool raw = false; |
583 | bool swap = false; | ||
584 | 586 | ||
585 | 587 | ||
586 | for (i = 1;i < argc;i++) | 588 | for (i = 1;i < argc;i++) |
@@ -630,10 +632,6 @@ int main(int argc, char **argv) | |||
630 | case 'r': /* Raw File */ | 632 | case 'r': /* Raw File */ |
631 | raw = true; | 633 | raw = true; |
632 | break; | 634 | break; |
633 | |||
634 | case 'b': /* Swap bytes */ | ||
635 | swap = true; | ||
636 | break; | ||
637 | 635 | ||
638 | case 'f': | 636 | case 'f': |
639 | if (argv[i][2]) | 637 | if (argv[i][2]) |
@@ -701,12 +699,14 @@ int main(int argc, char **argv) | |||
701 | } | 699 | } |
702 | else | 700 | else |
703 | { | 701 | { |
704 | if (transform_bitmap(bitmap, width, height, format, &t_bitmap, &t_width, &t_height, &t_depth)) | 702 | if (transform_bitmap(bitmap, width, height, format, &t_bitmap, |
703 | &t_width, &t_height, &t_depth)) | ||
705 | exit(1); | 704 | exit(1); |
706 | if(raw) | 705 | if(raw) |
707 | generate_raw_file(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth, swap); | 706 | generate_raw_file(id, t_bitmap, t_width, t_height, t_depth); |
708 | else | 707 | else |
709 | generate_c_source(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth); | 708 | generate_c_source(id, header_dir, width, height, t_bitmap, |
709 | t_width, t_height, t_depth); | ||
710 | } | 710 | } |
711 | 711 | ||
712 | return 0; | 712 | return 0; |