diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-04-10 10:46:49 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-04-10 10:46:49 +0200 |
commit | f4fbaa3e7c5f4f1d4d1ca4374859e6fc600ebc82 (patch) | |
tree | 40ba33c20826ce7bdc6912a21a232719e6f32fd1 | |
parent | 9d300f1b4d26558049a87e38afc80d9e3b80ba26 (diff) | |
download | uca-f4fbaa3e7c5f4f1d4d1ca4374859e6fc600ebc82.tar.gz uca-f4fbaa3e7c5f4f1d4d1ca4374859e6fc600ebc82.tar.bz2 uca-f4fbaa3e7c5f4f1d4d1ca4374859e6fc600ebc82.tar.xz uca-f4fbaa3e7c5f4f1d4d1ca4374859e6fc600ebc82.zip |
Round bits per sample (e.g. 10 -> 16)
-rw-r--r-- | tools/grab.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/grab.c b/tools/grab.c index 0b9601f..41f5a6e 100644 --- a/tools/grab.c +++ b/tools/grab.c @@ -68,9 +68,10 @@ get_camera_list (void) static guint get_bytes_per_pixel (guint bits_per_pixel) { - return bits_per_pixel == 8 ? 1 : 2; + return bits_per_pixel > 8 ? 2 : 1; } + #ifdef HAVE_LIBTIFF static void write_tiff (RingBuffer *buffer, @@ -82,6 +83,7 @@ write_tiff (RingBuffer *buffer, TIFF *tif; guint32 rows_per_strip; guint n_frames; + guint bits_per_sample; gsize bytes_per_pixel; if (opts->filename) @@ -92,6 +94,7 @@ write_tiff (RingBuffer *buffer, n_frames = ring_buffer_get_num_blocks (buffer); rows_per_strip = TIFFDefaultStripSize (tif, (guint32) - 1); bytes_per_pixel = get_bytes_per_pixel (bits_per_pixel); + bits_per_sample = bits_per_pixel > 8 ? 16 : 8; /* Write multi page TIFF file */ TIFFSetField (tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE); @@ -104,7 +107,7 @@ write_tiff (RingBuffer *buffer, TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField (tif, TIFFTAG_IMAGELENGTH, height); - TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel); + TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, bits_per_sample); TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); |