summaryrefslogtreecommitdiffstats
path: root/test/grab.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-09 11:34:30 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-03-09 11:34:30 +0100
commitcd7590bac56800586c4aadef077d1effe03b00c4 (patch)
tree38863a4996a42301cb68becb88f137d2c28ccac3 /test/grab.c
parentcc74561cfaff3a4c8719b6972d4ec5c21be535ea (diff)
downloaduca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.gz
uca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.bz2
uca-cd7590bac56800586c4aadef077d1effe03b00c4.tar.xz
uca-cd7590bac56800586c4aadef077d1effe03b00c4.zip
Use correct number of bytes per pixel when allocating buffers
Diffstat (limited to 'test/grab.c')
-rw-r--r--test/grab.c12
1 files changed, 7 insertions, 5 deletions
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);