remove whitespace at eol
[goodguy/history.git] / cinelerra-5.1 / guicast / bccapture.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCCAPTURE_H
23 #define BCCAPTURE_H
24
25 #include <sys/ipc.h>
26 #include <sys/shm.h>
27 #include <X11/Xlib.h>
28 #include <X11/extensions/XShm.h>
29
30 #include "sizes.h"
31 #include "vframe.inc"
32
33
34 class BC_Capture
35 {
36 public:
37         BC_Capture(int w, int h, const char *display_path = "");
38         virtual ~BC_Capture();
39
40         int init_window(const char *display_path);
41 // x1 and y1 are automatically adjusted if out of bounds
42         int capture_frame(VFrame *frame, int &x1, int &y1);
43         int get_w();
44         int get_h();
45
46         int w, h, default_depth;
47         unsigned char **row_data;
48
49 private:
50         int allocate_data();
51         int delete_data();
52         int get_top_w();
53         int get_top_h();
54
55         inline void import_RGB565_to_RGB888(unsigned char* &output, unsigned char* &input)
56         {
57                 *output++ = (*input & 0xf800) >> 8;
58                 *output++ = (*input & 0x7e0) >> 3;
59                 *output++ = (*input & 0x1f) << 3;
60
61                 input += 2;
62                 output += 3;
63         };
64
65         inline void import_BGR888_to_RGB888(unsigned char* &output, unsigned char* &input)
66         {
67                 *output++ = input[2];
68                 *output++ = input[1];
69                 *output++ = input[0];
70
71                 input += 3;
72                 output += 3;
73         };
74
75         inline void import_BGR8888_to_RGB888(unsigned char* &output, unsigned char* &input)
76         {
77                 *output++ = input[2];
78                 *output++ = input[1];
79                 *output++ = input[0];
80
81                 input += 4;
82                 output += 3;
83         };
84
85         int use_shm;
86         int bitmap_color_model;
87         unsigned char *data;
88         XImage *ximage;
89         XShmSegmentInfo shm_info;
90         Display* display;
91         Window rootwin;
92         Visual *vis;
93         int bits_per_pixel;
94         int screen;
95         long shm_event_type;
96         int client_byte_order, server_byte_order;
97 };
98
99 #endif