-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathdec_png.c
41 lines (32 loc) · 1.06 KB
/
dec_png.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
/* fswebcam - Small and simple webcam for *nix */
/*============================================================*/
/* Copyright (C)2005-2011 Philip Heron <[email protected]> */
/* */
/* 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 <gd.h>
#include "fswebcam.h"
#include "src.h"
int fswc_add_image_png(src_t *src, avgbmp_t *abitmap)
{
uint32_t x, y;
gdImage *im;
im = gdImageCreateFromPngPtr(src->length, src->img);
if(!im) return(-1);
for(y = 0; y < src->height; y++)
for(x = 0; x < src->width; x++)
{
int c = gdImageGetPixel(im, x, y);
*(abitmap++) += (c & 0xFF0000) >> 16;
*(abitmap++) += (c & 0x00FF00) >> 8;
*(abitmap++) += (c & 0x0000FF);
}
gdImageDestroy(im);
return(0);
}