summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/bmp2rb.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c
index aa23d45830..1d49dd5bcf 100644
--- a/tools/bmp2rb.c
+++ b/tools/bmp2rb.c
@@ -497,6 +497,27 @@ 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
500void generate_raw_file(char *id, char* header_dir, int width, int height,
501 const unsigned short *t_bitmap, int t_width,
502 int t_height, int t_depth)
503{
504 FILE *f;
505 int i, a;
506
507 f = stdout;
508
509 for (i = 0; i < t_height; i++)
510 {
511 for (a = 0; a < t_width; a++)
512 {
513 if (t_depth <= 8)
514 fwrite(&t_bitmap[i * t_width + a], 1, 1, f);
515 else
516 fwrite(&t_bitmap[i * t_width + a], 2, 1, f);
517 }
518 }
519}
520
500/**************************************************************************** 521/****************************************************************************
501 * generate_ascii() 522 * generate_ascii()
502 * 523 *
@@ -527,6 +548,7 @@ void print_usage(void)
527 "\t-i <id> Bitmap name (default is filename without extension)\n" 548 "\t-i <id> Bitmap name (default is filename without extension)\n"
528 "\t-h <dir> Create header file in <dir>/<id>.h\n" 549 "\t-h <dir> Create header file in <dir>/<id>.h\n"
529 "\t-a Show ascii picture of bitmap\n" 550 "\t-a Show ascii picture of bitmap\n"
551 "\t-r Generate RAW file\n"
530 "\t-f <n> Generate destination format n, default = 0\n" 552 "\t-f <n> Generate destination format n, default = 0\n"
531 "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" 553 "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n"
532 "\t 1 Archos player graphics library\n" 554 "\t 1 Archos player graphics library\n"
@@ -552,6 +574,7 @@ int main(int argc, char **argv)
552 unsigned short *t_bitmap = NULL; 574 unsigned short *t_bitmap = NULL;
553 int width, height; 575 int width, height;
554 int t_width, t_height, t_depth; 576 int t_width, t_height, t_depth;
577 bool raw = false;
555 578
556 579
557 for (i = 1;i < argc;i++) 580 for (i = 1;i < argc;i++)
@@ -598,6 +621,10 @@ int main(int argc, char **argv)
598 ascii = true; 621 ascii = true;
599 break; 622 break;
600 623
624 case 'r': /* Ascii art */
625 raw = true;
626 break;
627
601 case 'f': 628 case 'f':
602 if (argv[i][2]) 629 if (argv[i][2])
603 { 630 {
@@ -664,11 +691,12 @@ int main(int argc, char **argv)
664 } 691 }
665 else 692 else
666 { 693 {
667 if (transform_bitmap(bitmap, width, height, format, &t_bitmap, 694 if (transform_bitmap(bitmap, width, height, format, &t_bitmap, &t_width, &t_height, &t_depth))
668 &t_width, &t_height, &t_depth))
669 exit(1); 695 exit(1);
670 generate_c_source(id, header_dir, width, height, t_bitmap, 696 if(raw)
671 t_width, t_height, t_depth); 697 generate_raw_file(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth);
698 else
699 generate_c_source(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth);
672 } 700 }
673 701
674 return 0; 702 return 0;