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 [--gamma <gammafile>] " |
| 522 "<background> [<x-offset> <y-offset> " |
521 "<frame-1> ... <frame-n>]\n"); | 523 "<frame-1> ... <frame-n>]\n"); |
522 exit(1); | 524 exit(1); |
523 } | 525 } |
524 | 526 |
525 | 527 |
526 int | 528 int |
527 main (int argc, | 529 main (int argc, |
528 char **argv) | 530 char **argv) |
529 { | 531 { |
530 int exit_code = 0; | 532 int exit_code = 0; |
531 int clear = 0; | 533 int clear = 0; |
| 534 int gamma = 0; |
532 int help = 0; | 535 int help = 0; |
533 ply_frame_buffer_t *buffer; | 536 ply_frame_buffer_t *buffer; |
534 int i; | 537 int i; |
535 int xoff, yoff; | 538 int xoff, yoff; |
536 char *endptr; | 539 char *endptr; |
537 | 540 |
538 // hide_cursor (); | 541 // hide_cursor (); |
539 | 542 |
540 /* | 543 /* |
541 * Ad-hoc arg parsing, to keep the program small. | 544 * Ad-hoc arg parsing, to keep the program small. |
542 */ | 545 */ |
543 | 546 |
544 if (argc > 1) | 547 if (argc > 1) |
545 { | 548 { |
546 clear = strcasecmp (argv[1], "--clear") == 0; | 549 clear = strcasecmp (argv[1], "--clear") == 0; |
| 550 gamma = strcasecmp (argv[1], "--gamma") == 0; |
547 help = strcasecmp (argv[1], "--help") == 0 || | 551 help = strcasecmp (argv[1], "--help") == 0 || |
548 strcasecmp (argv[1], "-h") == 0; | 552 strcasecmp (argv[1], "-h") == 0; |
549 } | 553 } |
550 | 554 |
551 if (help || argc == 1 || argc == 3 || argc == 4) | 555 if (help) |
552 { | 556 { |
553 usage(); | 557 usage(); |
554 } | 558 } |
555 | 559 |
556 buffer = ply_frame_buffer_new (NULL); | 560 buffer = ply_frame_buffer_new (NULL); |
557 | 561 |
558 if (!ply_frame_buffer_open (buffer)) | 562 if (!ply_frame_buffer_open (buffer)) |
559 { | 563 { |
560 exit_code = errno; | 564 exit_code = errno; |
561 perror ("could not open framebuffer"); | 565 perror ("could not open framebuffer"); |
562 return exit_code; | 566 return exit_code; |
563 } | 567 } |
564 | 568 |
565 if (clear) | 569 if (clear) |
566 { | 570 { |
567 ply_frame_buffer_clear (buffer); | 571 ply_frame_buffer_clear (buffer); |
568 } | 572 } |
569 else | 573 else |
570 { | 574 { |
| 575 int num_gamma_args = 0; |
| 576 if (gamma) |
| 577 { |
| 578 if (argc < 6) |
| 579 usage(); |
| 580 ply_gamma_set(argv[2]); |
| 581 argv += 2; |
| 582 argc -= 2; |
| 583 } |
| 584 else |
| 585 if (argc < 4) |
| 586 usage(); |
| 587 |
571 /* | 588 /* |
572 * Display main image. | 589 * Display main image. |
573 */ | 590 */ |
574 ply_frame_buffer_show_file_at_xy (buffer, argv[1], 0, 0); | 591 ply_frame_buffer_show_file_at_xy (buffer, argv[1], 0, 0); |
575 | 592 |
576 if (argc >= 4) | 593 if (argc >= 4) |
577 { | 594 { |
578 /* | 595 /* |
579 * Animate frames. | 596 * Animate frames. |
580 */ | 597 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 649 } |
633 } | 650 } |
634 } | 651 } |
635 | 652 |
636 // Skip these to save time. | 653 // Skip these to save time. |
637 // ply_frame_buffer_close (buffer); | 654 // ply_frame_buffer_close (buffer); |
638 // ply_frame_buffer_free (buffer); | 655 // ply_frame_buffer_free (buffer); |
639 | 656 |
640 return exit_code; | 657 return exit_code; |
641 } | 658 } |
OLD | NEW |