FPS option part 2
[fswebcam.git] / src_test.c
blob9ff36de67b6d893ed851e52461d7330defeefd61
1 /* fswebcam - FireStorm.cx's webcam generator */
2 /*===========================================================*/
3 /* Copyright (C)2005-2006 Philip Heron <phil@firestorm.cx> */
4 /* */
5 /* This program is distributed under the terms of the GNU */
6 /* General Public License, version 2. You may use, modify, */
7 /* and redistribute it under the terms of this license. A */
8 /* copy should be included with this source. */
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
14 #include <stdlib.h>
15 #include "src.h"
16 #include "log.h"
18 #define PUT_RGB(d, r, g, b) { d[0] = r; d[1] = g; d[2] = b; }
20 int src_test_open(src_t *src)
22 uint8_t *p;
23 uint32_t x, y;
25 if(src->list & SRC_LIST_INPUTS) HEAD("--- No inputs.");
26 if(src->list & SRC_LIST_TUNERS) HEAD("--- No tuners.");
27 if(src->list & SRC_LIST_FORMATS) HEAD("--- Test only supports RGB24.");
28 if(src->list & SRC_LIST_CONTROLS) HEAD("--- No controls.");
30 /* Allocate memory for the test image. */
31 src->length = src->width * src->height * 3;
32 src->img = (uint8_t *) malloc(src->length);
33 if(!src->img) return(-1);
35 /* Set the palette type. */
36 src->palette = SRC_PAL_RGB24;
38 /* Draw the test image. */
39 p = src->img;
40 for(y = 0; y < src->height; y++)
42 for(x = 0; x < src->width; x++)
44 int i = x / (src->width / 8);
46 i = 7 - i;
48 switch(i)
50 case 0: /* Black */
51 PUT_RGB(p, 0x00, 0x00, 0x00); break;
52 case 1: /* Blue */
53 PUT_RGB(p, 0x00, 0x00, 0xFF); break;
54 case 2: /* Red */
55 PUT_RGB(p, 0xFF, 0x00, 0x00); break;
56 case 3: /* Purple */
57 PUT_RGB(p, 0xFF, 0x00, 0xFF); break;
58 case 4: /* Green */
59 PUT_RGB(p, 0x00, 0xFF, 0x00); break;
60 case 5: /* Cyan */
61 PUT_RGB(p, 0x00, 0xFF, 0xFF); break;
62 case 6: /* Yellow */
63 PUT_RGB(p, 0xFF, 0xFF, 0x00); break;
64 default: /* White */
65 PUT_RGB(p, 0xFF, 0xFF, 0xFF); break;
68 p += 3;
72 return(0);
75 int src_test_close(src_t *src)
77 free(src->img);
78 return(0);
81 int src_test_grab(src_t *src)
83 return(0);
86 src_mod_t src_test = {
87 "test", SRC_TYPE_NONE,
88 src_test_open,
89 src_test_close,
90 src_test_grab