forked from fsphil/fswebcam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dec_grey.c
57 lines (46 loc) · 1.42 KB
/
dec_grey.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* fswebcam - Small and simple webcam for *nix */
/*============================================================*/
/* Copyright (C)2005-2011 Philip Heron <phil@sanslogic.co.uk> */
/* */
/* This program is distributed under the terms of the GNU */
/* General Public License, version 2. You may use, modify, */
/* and redistribute it under the terms of this license. A */
/* copy should be included with this source. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdint.h>
#include "fswebcam.h"
#include "src.h"
int fswc_add_image_y16(src_t *src, avgbmp_t *abitmap)
{
uint16_t *bitmap = (uint16_t *) src->img;
uint32_t i = src->width * src->height;
if(src->length < i) return(-1);
while(i-- > 0)
{
abitmap[0] += (*bitmap >> 8) + (*bitmap << 8);
abitmap[1] += (*bitmap >> 8) + (*bitmap << 8);
abitmap[2] += (*bitmap >> 8) + (*bitmap << 8);
//*(abitmap++) += *bitmap >> 8;
//*(abitmap++) += *(bitmap++) >> 8;
// abitmap[0] = *bitmap >> 8;
// abitmap[1] = *bitmap & 0xFF;
abitmap += 3;
bitmap++;
}
return(0);
}
int fswc_add_image_grey(src_t *src, avgbmp_t *abitmap)
{
uint8_t *bitmap = (uint8_t *) src->img;
uint32_t i = src->width * src->height;
if(src->length < i) return(-1);
while(i-- > 0)
{
*(abitmap++) += *bitmap;
*(abitmap++) += *bitmap;
*(abitmap++) += *(bitmap++);
}
return(0);
}