Implemented command-line flags to influence the aspect ratio
This commit is contained in:
parent
97c4e2e01e
commit
45909c6efe
|
@ -56,6 +56,8 @@
|
||||||
<replaceable>overlay</replaceable></arg>
|
<replaceable>overlay</replaceable></arg>
|
||||||
<arg choice="opt"><option>-H</option></arg>
|
<arg choice="opt"><option>-H</option></arg>
|
||||||
<arg choice="opt"><option>-h</option></arg>
|
<arg choice="opt"><option>-h</option></arg>
|
||||||
|
<arg choice="opt"><option>-R</option></arg>
|
||||||
|
<arg choice="opt"><option>-r</option></arg>
|
||||||
<arg choice="opt"><option>-V</option></arg>
|
<arg choice="opt"><option>-V</option></arg>
|
||||||
<arg choice="opt"><option>-v</option></arg>
|
<arg choice="opt"><option>-v</option></arg>
|
||||||
<arg choice="opt"><option>-x</option></arg>
|
<arg choice="opt"><option>-x</option></arg>
|
||||||
|
@ -96,6 +98,18 @@
|
||||||
<para>Specify an image to display on top of the camera feed.</para>
|
<para>Specify an image to display on top of the camera feed.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-R</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Force the output to preserve the aspect ratio when scaling.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-r</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Scale the output without preserving the aspect ratio.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-V</option></term>
|
<term><option>-V</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
30
src/main.c
30
src/main.c
|
@ -45,7 +45,7 @@
|
||||||
/* private */
|
/* private */
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static int _camera(int embedded, char const * device, int hflip, int vflip,
|
static int _camera(int embedded, char const * device, int hflip, int vflip,
|
||||||
char const * overlay);
|
int ratio, char const * overlay);
|
||||||
|
|
||||||
static int _error(char const * message, int ret);
|
static int _error(char const * message, int ret);
|
||||||
static int _usage(void);
|
static int _usage(void);
|
||||||
|
@ -54,16 +54,16 @@ static int _usage(void);
|
||||||
/* functions */
|
/* functions */
|
||||||
/* camera */
|
/* camera */
|
||||||
static int _camera_embedded(char const * device, int hflip, int vflip,
|
static int _camera_embedded(char const * device, int hflip, int vflip,
|
||||||
char const * overlay);
|
int ratio, char const * overlay);
|
||||||
static void _embedded_on_embedded(gpointer data);
|
static void _embedded_on_embedded(gpointer data);
|
||||||
|
|
||||||
static int _camera(int embedded, char const * device, int hflip, int vflip,
|
static int _camera(int embedded, char const * device, int hflip, int vflip,
|
||||||
char const * overlay)
|
int ratio, char const * overlay)
|
||||||
{
|
{
|
||||||
CameraWindow * camera;
|
CameraWindow * camera;
|
||||||
|
|
||||||
if(embedded != 0)
|
if(embedded != 0)
|
||||||
return _camera_embedded(device, hflip, vflip, overlay);
|
return _camera_embedded(device, hflip, vflip, ratio, overlay);
|
||||||
if((camera = camerawindow_new(device)) == NULL)
|
if((camera = camerawindow_new(device)) == NULL)
|
||||||
return error_print(PACKAGE);
|
return error_print(PACKAGE);
|
||||||
camerawindow_load(camera);
|
camerawindow_load(camera);
|
||||||
|
@ -71,6 +71,8 @@ static int _camera(int embedded, char const * device, int hflip, int vflip,
|
||||||
camerawindow_set_hflip(camera, hflip ? TRUE : FALSE);
|
camerawindow_set_hflip(camera, hflip ? TRUE : FALSE);
|
||||||
if(vflip >= 0)
|
if(vflip >= 0)
|
||||||
camerawindow_set_vflip(camera, vflip ? TRUE : FALSE);
|
camerawindow_set_vflip(camera, vflip ? TRUE : FALSE);
|
||||||
|
if(ratio >= 0)
|
||||||
|
camerawindow_set_aspect_ratio(camera, ratio ? TRUE : FALSE);
|
||||||
if(overlay != NULL)
|
if(overlay != NULL)
|
||||||
camerawindow_add_overlay(camera, overlay, 50);
|
camerawindow_add_overlay(camera, overlay, 50);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
@ -79,7 +81,7 @@ static int _camera(int embedded, char const * device, int hflip, int vflip,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _camera_embedded(char const * device, int hflip, int vflip,
|
static int _camera_embedded(char const * device, int hflip, int vflip,
|
||||||
char const * overlay)
|
int ratio, char const * overlay)
|
||||||
{
|
{
|
||||||
GtkWidget * window;
|
GtkWidget * window;
|
||||||
GtkWidget * widget;
|
GtkWidget * widget;
|
||||||
|
@ -100,6 +102,8 @@ static int _camera_embedded(char const * device, int hflip, int vflip,
|
||||||
camera_set_hflip(camera, hflip ? TRUE : FALSE);
|
camera_set_hflip(camera, hflip ? TRUE : FALSE);
|
||||||
if(vflip >= 0)
|
if(vflip >= 0)
|
||||||
camera_set_vflip(camera, vflip ? TRUE : FALSE);
|
camera_set_vflip(camera, vflip ? TRUE : FALSE);
|
||||||
|
if(ratio >= 0)
|
||||||
|
camera_set_aspect_ratio(camera, ratio ? TRUE : FALSE);
|
||||||
if(overlay != NULL)
|
if(overlay != NULL)
|
||||||
camera_add_overlay(camera, overlay, 50);
|
camera_add_overlay(camera, overlay, 50);
|
||||||
widget = camera_get_widget(camera);
|
widget = camera_get_widget(camera);
|
||||||
|
@ -133,11 +137,13 @@ static int _error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Usage: %s [-d device][-O filename][-HVx]\n"
|
fprintf(stderr, _("Usage: %s [-d device][-O filename][-HhRrVvx]\n"
|
||||||
" -d Video device to open\n"
|
" -d Video device to open\n"
|
||||||
" -H Flip horizontally\n"
|
" -H Flip horizontally\n"
|
||||||
" -h Do not flip horizontally\n"
|
" -h Do not flip horizontally\n"
|
||||||
" -O Use this file as an overlay\n"
|
" -O Use this file as an overlay\n"
|
||||||
|
" -R Preserve the aspect ratio when scaling\n"
|
||||||
|
" -r Do not preserve the aspect ratio when scaling\n"
|
||||||
" -V Flip vertically\n"
|
" -V Flip vertically\n"
|
||||||
" -v Do not flip vertically\n"
|
" -v Do not flip vertically\n"
|
||||||
" -x Start in embedded mode\n"), PROGNAME);
|
" -x Start in embedded mode\n"), PROGNAME);
|
||||||
|
@ -155,6 +161,7 @@ int main(int argc, char * argv[])
|
||||||
char const * device = NULL;
|
char const * device = NULL;
|
||||||
int hflip = -1;
|
int hflip = -1;
|
||||||
int vflip = -1;
|
int vflip = -1;
|
||||||
|
int ratio = -1;
|
||||||
char const * overlay = NULL;
|
char const * overlay = NULL;
|
||||||
|
|
||||||
if(setlocale(LC_ALL, "") == NULL)
|
if(setlocale(LC_ALL, "") == NULL)
|
||||||
|
@ -162,7 +169,7 @@ int main(int argc, char * argv[])
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
while((o = getopt(argc, argv, "d:HhO:Vvx")) != -1)
|
while((o = getopt(argc, argv, "d:HhO:RrVvx")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -177,6 +184,12 @@ int main(int argc, char * argv[])
|
||||||
case 'O':
|
case 'O':
|
||||||
overlay = optarg;
|
overlay = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
ratio = 1;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
ratio = 0;
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
vflip = 1;
|
vflip = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -191,5 +204,6 @@ int main(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
if(optind != argc)
|
if(optind != argc)
|
||||||
return _usage();
|
return _usage();
|
||||||
return (_camera(embedded, device, hflip, vflip, overlay) == 0) ? 0 : 2;
|
return (_camera(embedded, device, hflip, vflip, ratio, overlay) == 0)
|
||||||
|
? 0 : 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user