Ignore:
Timestamp:
Nov 7, 2007, 11:29:02 AM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added switch to control output font size, and updated documentation

accordingly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/img2txt.c

    r1917 r1919  
    5050    fprintf(stderr, "  -W, --width=WIDTH\t\tWidth of resulting image\n");
    5151    fprintf(stderr, "  -H, --height=HEIGHT\t\tHeight of resulting image\n");
     52    fprintf(stderr, "  -x, --font-width=WIDTH\t\tWidth of output font\n");
     53    fprintf(stderr, "  -y, --font-height=HEIGHT\t\tHeight of output font\n");
    5254    fprintf(stderr, "  -b, --brightness=BRIGHTNESS\tBrightness of resulting image\n");
    5355    fprintf(stderr, "  -c, --contrast=CONTRAST\tContrast of resulting image\n");
     
    9799    unsigned long int len;
    98100    struct image *i;
    99     unsigned int cols = 0, lines = 0;
     101    unsigned int cols = 0, lines = 0, font_width = 6, font_height = 10;
    100102    char *format = NULL;
    101103    char *dither = NULL;
     
    116118            { "width",       1, NULL, 'W' },
    117119            { "height",      1, NULL, 'H' },
     120            { "font-width",  1, NULL, 'x' },
     121            { "font-height", 1, NULL, 'y' },
    118122            { "format",      1, NULL, 'f' },
    119123            { "dither",      1, NULL, 'd' },
     
    122126            { "contrast",    1, NULL, 'c' },
    123127            { "help",        0, NULL, 'h' },
    124             { "version",        0, NULL, 'v' },
     128            { "version",     0, NULL, 'v' },
    125129        };
    126         int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v", long_options, &option_index);
     130        int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v:x:y:", long_options, &option_index);
    127131        if(c == -1)
    128132            break;
     
    136140            lines = atoi(myoptarg);
    137141            break;
     142        case 'x': /* --width */
     143            font_width = atoi(myoptarg);
     144            break;
     145        case 'y': /* --height */
     146            font_height = atoi(myoptarg);
     147            break;
    138148        case 'f': /* --format */
    139149            format = myoptarg;
     
    185195    {
    186196        cols = 60;
    187         lines = cols * i->h * 6 / i->w / 10;
     197        lines = cols * i->h * font_width / i->w / font_height;
    188198    }
    189199    else if(cols && !lines)
    190200    {
    191         lines = cols * i->h * 6 / i->w / 10;
     201        lines = cols * i->h * font_width / i->w / font_height;
    192202    }
    193203    else if(!cols && lines)
    194204    {
    195         cols = lines * i->w * 10 / i->h / 6;
     205        cols = lines * i->w * font_height / i->h / font_width;
    196206    }
    197207
Note: See TracChangeset for help on using the changeset viewer.