ソースを参照

* Added switch to control output font size, and updated documentation

accordingly
tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18年前
コミット
7d7f4c42e1
2個のファイルの変更30行の追加6行の削除
  1. +14
    -0
      doc/img2txt.1
  2. +16
    -6
      src/img2txt.c

+ 14
- 0
doc/img2txt.1 ファイルの表示

@@ -11,6 +11,14 @@ img2txt \- convert images to various text-based coloured files
.B \-H .B \-H
.I height .I height
] ]
[
.B \-x
.I font-width
]
[
.B \-y
.I font-height
]
.PD 0 .PD 0
.IP .IP
.PD .PD
@@ -60,6 +68,12 @@ Change output column count. If not given, the default is set to 60.
.B \-H, \-\-height=<height> .B \-H, \-\-height=<height>
Change output line count. If not given, the height is computed to match correct aspect ratio. Change output line count. If not given, the height is computed to match correct aspect ratio.
.TP .TP
.B \-x, \-\-font-width=<width>
Change output font width. If not given, the default is set to 6. This value will be used for computing aspect ratio.
.TP
.B \-y, \-\-font-height=<height>
Change output font height. If not given, the default is set to 10. This value will be used for computing aspect ratio.
.TP
.B \-b, \-\-brightness=<brightness> .B \-b, \-\-brightness=<brightness>
Change image brightness. Default to 1.0. Change image brightness. Default to 1.0.
.TP .TP


+ 16
- 6
src/img2txt.c ファイルの表示

@@ -49,6 +49,8 @@ static void usage(int argc, char **argv)
fprintf(stderr, " -v, --version\t\t\tVersion of the program\n"); fprintf(stderr, " -v, --version\t\t\tVersion of the program\n");
fprintf(stderr, " -W, --width=WIDTH\t\tWidth of resulting image\n"); fprintf(stderr, " -W, --width=WIDTH\t\tWidth of resulting image\n");
fprintf(stderr, " -H, --height=HEIGHT\t\tHeight of resulting image\n"); fprintf(stderr, " -H, --height=HEIGHT\t\tHeight of resulting image\n");
fprintf(stderr, " -x, --font-width=WIDTH\t\tWidth of output font\n");
fprintf(stderr, " -y, --font-height=HEIGHT\t\tHeight of output font\n");
fprintf(stderr, " -b, --brightness=BRIGHTNESS\tBrightness of resulting image\n"); fprintf(stderr, " -b, --brightness=BRIGHTNESS\tBrightness of resulting image\n");
fprintf(stderr, " -c, --contrast=CONTRAST\tContrast of resulting image\n"); fprintf(stderr, " -c, --contrast=CONTRAST\tContrast of resulting image\n");
fprintf(stderr, " -g, --gamma=GAMMA\t\tGamma of resulting image\n"); fprintf(stderr, " -g, --gamma=GAMMA\t\tGamma of resulting image\n");
@@ -96,7 +98,7 @@ int main(int argc, char **argv)
void *export; void *export;
unsigned long int len; unsigned long int len;
struct image *i; struct image *i;
unsigned int cols = 0, lines = 0;
unsigned int cols = 0, lines = 0, font_width = 6, font_height = 10;
char *format = NULL; char *format = NULL;
char *dither = NULL; char *dither = NULL;
float gamma = -1, brightness = -1, contrast = -1; float gamma = -1, brightness = -1, contrast = -1;
@@ -115,15 +117,17 @@ int main(int argc, char **argv)
{ {
{ "width", 1, NULL, 'W' }, { "width", 1, NULL, 'W' },
{ "height", 1, NULL, 'H' }, { "height", 1, NULL, 'H' },
{ "font-width", 1, NULL, 'x' },
{ "font-height", 1, NULL, 'y' },
{ "format", 1, NULL, 'f' }, { "format", 1, NULL, 'f' },
{ "dither", 1, NULL, 'd' }, { "dither", 1, NULL, 'd' },
{ "gamma", 1, NULL, 'g' }, { "gamma", 1, NULL, 'g' },
{ "brightness", 1, NULL, 'b' }, { "brightness", 1, NULL, 'b' },
{ "contrast", 1, NULL, 'c' }, { "contrast", 1, NULL, 'c' },
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "version", 0, NULL, 'v' },
}; };
int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v", long_options, &option_index);
int c = mygetopt(argc, argv, "W:H:f:d:g:b:c:h:v:x:y:", long_options, &option_index);
if(c == -1) if(c == -1)
break; break;


@@ -135,6 +139,12 @@ int main(int argc, char **argv)
case 'H': /* --height */ case 'H': /* --height */
lines = atoi(myoptarg); lines = atoi(myoptarg);
break; break;
case 'x': /* --width */
font_width = atoi(myoptarg);
break;
case 'y': /* --height */
font_height = atoi(myoptarg);
break;
case 'f': /* --format */ case 'f': /* --format */
format = myoptarg; format = myoptarg;
break; break;
@@ -184,15 +194,15 @@ int main(int argc, char **argv)
if(!cols && !lines) if(!cols && !lines)
{ {
cols = 60; cols = 60;
lines = cols * i->h * 6 / i->w / 10;
lines = cols * i->h * font_width / i->w / font_height;
} }
else if(cols && !lines) else if(cols && !lines)
{ {
lines = cols * i->h * 6 / i->w / 10;
lines = cols * i->h * font_width / i->w / font_height;
} }
else if(!cols && lines) else if(!cols && lines)
{ {
cols = lines * i->w * 10 / i->h / 6;
cols = lines * i->w * font_height / i->h / font_width;
} }






読み込み中…
キャンセル
保存