OLD | NEW |
---|---|
1 /* ply-image.c - png file loader | 1 /* ply-image.c - png file loader |
2 * | 2 * |
3 * Copyright (C) 2006, 2007 Red Hat, Inc. | 3 * Copyright (C) 2006, 2007 Red Hat, Inc. |
4 * Copyright (C) 2003 University of Southern California | 4 * Copyright (C) 2003 University of Southern California |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2, or (at your option) | 8 * the Free Software Foundation; either version 2, or (at your option) |
9 * any later version. | 9 * any later version. |
10 * | 10 * |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 if (!ply_image_load (image)) | 444 if (!ply_image_load (image)) |
445 { | 445 { |
446 exit_code = errno; | 446 exit_code = errno; |
447 perror (path); | 447 perror (path); |
448 exit (exit_code); | 448 exit (exit_code); |
449 } | 449 } |
450 return image; | 450 return image; |
451 } | 451 } |
452 | 452 |
453 #include "ply-frame-buffer.h" | 453 #include "ply-frame-buffer.h" |
454 #include "ply-gamma.h" | |
454 | 455 |
455 #include <math.h> | 456 #include <math.h> |
456 #include <signal.h> | 457 #include <signal.h> |
457 #include <stdio.h> | 458 #include <stdio.h> |
458 #include <sys/ioctl.h> | 459 #include <sys/ioctl.h> |
459 #include <sys/time.h> | 460 #include <sys/time.h> |
460 #include <values.h> | 461 #include <values.h> |
461 | 462 |
462 #include <linux/kd.h> | 463 #include <linux/kd.h> |
463 | 464 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 return 0; | 511 return 0; |
511 } | 512 } |
512 return timespec_to_nsec(ts); | 513 return timespec_to_nsec(ts); |
513 } | 514 } |
514 | 515 |
515 | 516 |
516 int usage(void) | 517 int usage(void) |
517 { | 518 { |
518 fprintf(stderr, | 519 fprintf(stderr, |
519 "usage: ply-image --clear\n" | 520 "usage: ply-image --clear\n" |
520 " ply-image <background> [<x-offset> <y-offset> " | 521 " ply-image <background> [<x-offset> <y-offset> " |
Daniel Erat
2011/04/19 20:13:36
forgot to mention: add something about --gamma her
| |
521 "<frame-1> ... <frame-n>]\n"); | 522 "<frame-1> ... <frame-n>]\n"); |
522 exit(1); | 523 exit(1); |
523 } | 524 } |
524 | 525 |
525 | 526 |
526 int | 527 int |
527 main (int argc, | 528 main (int argc, |
528 char **argv) | 529 char **argv) |
529 { | 530 { |
530 int exit_code = 0; | 531 int exit_code = 0; |
531 int clear = 0; | 532 int clear = 0; |
533 int gamma = 0; | |
532 int help = 0; | 534 int help = 0; |
533 ply_frame_buffer_t *buffer; | 535 ply_frame_buffer_t *buffer; |
534 int i; | 536 int i; |
535 int xoff, yoff; | 537 int xoff, yoff; |
536 char *endptr; | 538 char *endptr; |
537 | 539 |
538 // hide_cursor (); | 540 // hide_cursor (); |
539 | 541 |
540 /* | 542 /* |
541 * Ad-hoc arg parsing, to keep the program small. | 543 * Ad-hoc arg parsing, to keep the program small. |
542 */ | 544 */ |
543 | 545 |
544 if (argc > 1) | 546 if (argc > 1) |
545 { | 547 { |
546 clear = strcasecmp (argv[1], "--clear") == 0; | 548 clear = strcasecmp (argv[1], "--clear") == 0; |
549 gamma = strcasecmp (argv[1], "--gamma") == 0; | |
547 help = strcasecmp (argv[1], "--help") == 0 || | 550 help = strcasecmp (argv[1], "--help") == 0 || |
548 strcasecmp (argv[1], "-h") == 0; | 551 strcasecmp (argv[1], "-h") == 0; |
549 } | 552 } |
550 | 553 |
551 if (help || argc == 1 || argc == 3 || argc == 4) | 554 if (help) |
552 { | 555 { |
553 usage(); | 556 usage(); |
554 } | 557 } |
555 | 558 |
556 buffer = ply_frame_buffer_new (NULL); | 559 buffer = ply_frame_buffer_new (NULL); |
557 | 560 |
558 if (!ply_frame_buffer_open (buffer)) | 561 if (!ply_frame_buffer_open (buffer)) |
559 { | 562 { |
560 exit_code = errno; | 563 exit_code = errno; |
561 perror ("could not open framebuffer"); | 564 perror ("could not open framebuffer"); |
562 return exit_code; | 565 return exit_code; |
563 } | 566 } |
564 | 567 |
565 if (clear) | 568 if (clear) |
566 { | 569 { |
567 ply_frame_buffer_clear (buffer); | 570 ply_frame_buffer_clear (buffer); |
568 } | 571 } |
569 else | 572 else |
570 { | 573 { |
574 int num_gamma_args = 0; | |
575 if (gamma) | |
576 { | |
577 if (argc < 6) | |
578 usage(); | |
579 ply_gamma_set(argv[2]); | |
580 argv += 2; | |
581 argc -= 2; | |
582 } | |
583 else | |
584 if (argc < 4) | |
585 usage(); | |
586 | |
571 /* | 587 /* |
572 * Display main image. | 588 * Display main image. |
573 */ | 589 */ |
574 ply_frame_buffer_show_file_at_xy (buffer, argv[1], 0, 0); | 590 ply_frame_buffer_show_file_at_xy (buffer, argv[1], 0, 0); |
575 | 591 |
576 if (argc >= 4) | 592 if (argc >= 4) |
577 { | 593 { |
578 /* | 594 /* |
579 * Animate frames. | 595 * Animate frames. |
580 */ | 596 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 } | 648 } |
633 } | 649 } |
634 } | 650 } |
635 | 651 |
636 // Skip these to save time. | 652 // Skip these to save time. |
637 // ply_frame_buffer_close (buffer); | 653 // ply_frame_buffer_close (buffer); |
638 // ply_frame_buffer_free (buffer); | 654 // ply_frame_buffer_free (buffer); |
639 | 655 |
640 return exit_code; | 656 return exit_code; |
641 } | 657 } |
OLD | NEW |