summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/control.c4
-rw-r--r--test/grab.c12
2 files changed, 9 insertions, 7 deletions
diff --git a/test/control.c b/test/control.c
index 010d6bc..1eb7e0f 100644
--- a/test/control.c
+++ b/test/control.c
@@ -309,12 +309,12 @@ int main(int argc, char *argv[])
gtk_tree_view_column_set_cell_data_func(value_column, GTK_CELL_RENDERER(value_renderer), value_cell_data_func, NULL, NULL);
/* start grabbing and thread */
- int mem_size = bits_per_sample == 8 ? 1 : 2;
+ int pixel_size = bits_per_sample == 8 ? 1 : 2;
struct ThreadData td;
uca_cam_alloc(cam, 20);
td.image = image;
td.pixbuf = pixbuf;
- td.buffer = (guchar *) g_malloc(mem_size * width * height);
+ td.buffer = (guchar *) g_malloc(pixel_size * width * height);
td.pixels = gdk_pixbuf_get_pixels(pixbuf);
td.width = width;
td.height = height;
diff --git a/test/grab.c b/test/grab.c
index e2973dc..5ae44f1 100644
--- a/test/grab.c
+++ b/test/grab.c
@@ -15,18 +15,20 @@ int main(int argc, char *argv[])
/* take first camera */
struct uca_camera_t *cam = uca->cameras;
- uint32_t val = 5000;
+ uint32_t val = 1;
cam->set_property(cam, UCA_PROP_EXPOSURE, &val);
val = 0;
cam->set_property(cam, UCA_PROP_DELAY, &val);
- uint32_t width, height;
+ uint32_t width, height, bits;
cam->get_property(cam, UCA_PROP_WIDTH, &width);
cam->get_property(cam, UCA_PROP_HEIGHT, &height);
+ cam->get_property(cam, UCA_PROP_BITDEPTH, &bits);
- uca_cam_alloc(cam, 20);
+ uca_cam_alloc(cam, 10);
- uint16_t *buffer = (uint16_t *) malloc(width * height * 2);
+ const int pixel_size = bits == 8 ? 1 : 2;
+ uint16_t *buffer = (uint16_t *) malloc(width * height * pixel_size);
cam->start_recording(cam);
cam->grab(cam, (char *) buffer);
@@ -34,7 +36,7 @@ int main(int argc, char *argv[])
uca_destroy(uca);
FILE *fp = fopen("out.raw", "wb");
- fwrite(buffer, width*height, 2, fp);
+ fwrite(buffer, width*height, pixel_size, fp);
fclose(fp);
free(buffer);