Let the quality of JPEG snapshots be configured
This commit is contained in:
parent
9f892e6d57
commit
f9da2b0e8e
16
src/camera.c
16
src/camera.c
|
@ -78,6 +78,7 @@ struct _Camera
|
||||||
gboolean ratio;
|
gboolean ratio;
|
||||||
GdkInterpType interp;
|
GdkInterpType interp;
|
||||||
CameraSnapshotFormat snapshot_format;
|
CameraSnapshotFormat snapshot_format;
|
||||||
|
int snapshot_quality;
|
||||||
|
|
||||||
guint source;
|
guint source;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -203,6 +204,7 @@ Camera * camera_new(GtkWidget * window, GtkAccelGroup * group,
|
||||||
camera->ratio = TRUE;
|
camera->ratio = TRUE;
|
||||||
camera->interp = GDK_INTERP_BILINEAR;
|
camera->interp = GDK_INTERP_BILINEAR;
|
||||||
camera->snapshot_format = CSF_PNG;
|
camera->snapshot_format = CSF_PNG;
|
||||||
|
camera->snapshot_quality = 100;
|
||||||
camera->source = 0;
|
camera->source = 0;
|
||||||
camera->fd = -1;
|
camera->fd = -1;
|
||||||
memset(&camera->cap, 0, sizeof(camera->cap));
|
memset(&camera->cap, 0, sizeof(camera->cap));
|
||||||
|
@ -376,7 +378,9 @@ int camera_load(Camera * camera)
|
||||||
char * filename;
|
char * filename;
|
||||||
Config * config;
|
Config * config;
|
||||||
char const * p;
|
char const * p;
|
||||||
|
char * q;
|
||||||
char const jpeg[] = "jpeg";
|
char const jpeg[] = "jpeg";
|
||||||
|
int i;
|
||||||
|
|
||||||
if((filename = _camera_get_config_filename(camera, CAMERA_CONFIG_FILE))
|
if((filename = _camera_get_config_filename(camera, CAMERA_CONFIG_FILE))
|
||||||
== NULL)
|
== NULL)
|
||||||
|
@ -407,6 +411,13 @@ int camera_load(Camera * camera)
|
||||||
!= NULL
|
!= NULL
|
||||||
&& strcmp(p, jpeg) == 0)
|
&& strcmp(p, jpeg) == 0)
|
||||||
camera->snapshot_format = CSF_JPEG;
|
camera->snapshot_format = CSF_JPEG;
|
||||||
|
/* snapshot quality */
|
||||||
|
camera->snapshot_quality = 100;
|
||||||
|
if((p = _load_variable(camera, config, "snapshot", "quality"))
|
||||||
|
!= NULL
|
||||||
|
&& p[0] != '\0' && (i = strtol(p, &q, 10)) >= 0
|
||||||
|
&& *q == '\0' && i <= 100)
|
||||||
|
camera->snapshot_quality = i;
|
||||||
/* FIXME also implement interpolation and overlay images */
|
/* FIXME also implement interpolation and overlay images */
|
||||||
}
|
}
|
||||||
if(config != NULL)
|
if(config != NULL)
|
||||||
|
@ -900,6 +911,7 @@ static int _snapshot_save(Camera * camera, char const * path,
|
||||||
{
|
{
|
||||||
struct v4l2_pix_format * pix = &camera->format.fmt.pix;
|
struct v4l2_pix_format * pix = &camera->format.fmt.pix;
|
||||||
GdkPixbuf * pixbuf;
|
GdkPixbuf * pixbuf;
|
||||||
|
char buf[16];
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
|
||||||
|
@ -911,8 +923,10 @@ static int _snapshot_save(Camera * camera, char const * path,
|
||||||
switch(format)
|
switch(format)
|
||||||
{
|
{
|
||||||
case CSF_JPEG:
|
case CSF_JPEG:
|
||||||
|
snprintf(buf, sizeof(buf), "%d",
|
||||||
|
camera->snapshot_quality);
|
||||||
res = gdk_pixbuf_save(pixbuf, path, "jpeg", &error,
|
res = gdk_pixbuf_save(pixbuf, path, "jpeg", &error,
|
||||||
"quality", "100", NULL);
|
"quality", buf, NULL);
|
||||||
break;
|
break;
|
||||||
case CSF_PNG:
|
case CSF_PNG:
|
||||||
res = gdk_pixbuf_save(pixbuf, path, "png", &error,
|
res = gdk_pixbuf_save(pixbuf, path, "png", &error,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user