00001 #ifndef BCCAPTURE_H
00002 #define BCCAPTURE_H
00003
00004 #include <sys/ipc.h>
00005 #include <sys/shm.h>
00006 #include <X11/Xlib.h>
00007 #include <X11/extensions/XShm.h>
00008
00009 #include "sizes.h"
00010 #include "vframe.inc"
00011
00012
00013 class BC_Capture
00014 {
00015 public:
00016 BC_Capture(int w, int h, char *display_path = "");
00017 virtual ~BC_Capture();
00018
00019 int init_window(char *display_path);
00020
00021 int capture_frame(VFrame *frame, int &x1, int &y1);
00022 int get_w();
00023 int get_h();
00024
00025 int w, h, default_depth;
00026 unsigned char **row_data;
00027
00028 private:
00029 int allocate_data();
00030 int delete_data();
00031 int get_top_w();
00032 int get_top_h();
00033
00034 inline void import_RGB565_to_RGB888(unsigned char* &output, unsigned char* &input)
00035 {
00036 *output++ = (*input & 0xf800) >> 8;
00037 *output++ = (*input & 0x7e0) >> 3;
00038 *output++ = (*input & 0x1f) << 3;
00039
00040 input += 2;
00041 output += 3;
00042 };
00043
00044 inline void import_BGR888_to_RGB888(unsigned char* &output, unsigned char* &input)
00045 {
00046 *output++ = input[2];
00047 *output++ = input[1];
00048 *output++ = input[0];
00049
00050 input += 3;
00051 output += 3;
00052 };
00053
00054 inline void import_BGR8888_to_RGB888(unsigned char* &output, unsigned char* &input)
00055 {
00056 *output++ = input[2];
00057 *output++ = input[1];
00058 *output++ = input[0];
00059
00060 input += 4;
00061 output += 3;
00062 };
00063
00064 int use_shm;
00065 int bitmap_color_model;
00066 unsigned char *data;
00067 XImage *ximage;
00068 XShmSegmentInfo shm_info;
00069 Display* display;
00070 Window rootwin;
00071 Visual *vis;
00072 int bits_per_pixel;
00073 int screen;
00074 long shm_event_type;
00075 int client_byte_order, server_byte_order;
00076 };
00077
00078 #endif