+
+ if( do_cursor ) {
+ XFixesCursorImage *cursor;
+ cursor = XFixesGetCursorImage(display);
+ if( cursor ) {
+//printf("BC_Capture::capture_frame %d cursor=%p colormodel=%d\n",
+// __LINE__, cursor, frame->get_color_model());
+ int scale = do_cursor;
+ int cursor_x = cursor->x - x1 - cursor->xhot * scale;
+ int cursor_y = cursor->y - y1 - cursor->yhot * scale;
+ int w = frame->get_w();
+ int h = frame->get_h();
+ for( int i = 0; i < cursor->height; i++ ) {
+ for( int yscale = 0; yscale < scale; yscale++ ) {
+ if( cursor_y + i * scale + yscale >= 0 &&
+ cursor_y + i * scale + yscale < h ) {
+ unsigned char *src = (unsigned char*)(cursor->pixels +
+ i * cursor->width);
+ int dst_y = cursor_y + i * scale + yscale;
+ int dst_x = cursor_x;
+ for( int j = 0; j < cursor->width; j++ ) {
+ for( int xscale = 0; xscale < scale ; xscale++ ) {
+ if( cursor_x + j * scale + xscale >= 0 &&
+ cursor_x + j * scale + xscale < w ) {
+ int a = src[3];
+ int invert_a = 0xff - a;
+ int r = src[2];
+ int g = src[1];
+ int b = src[0];
+ switch( frame->get_color_model() ) {
+ case BC_RGB888: {
+ unsigned char *dst = frame->get_rows()[dst_y] +
+ dst_x * 3;
+ dst[0] = (r * a + dst[0] * invert_a) / 0xff;
+ dst[1] = (g * a + dst[1] * invert_a) / 0xff;
+ dst[2] = (b * a + dst[2] * invert_a) / 0xff;
+ break; }
+
+ case BC_YUV420P: {
+ unsigned char *dst_y_ = frame->get_y() +
+ dst_y * w + dst_x;
+ unsigned char *dst_u = frame->get_u() +
+ (dst_y / 2) * (w / 2) + (dst_x / 2);
+ unsigned char *dst_v = frame->get_v() +
+ (dst_y / 2) * (w / 2) + (dst_x / 2);
+ int y, u, v;
+ RGB_TO_YUV(y, u, v, r, g, b);
+
+ *dst_y_ = (y * a + *dst_y_ * invert_a) / 0xff;
+ *dst_u = (u * a + *dst_u * invert_a) / 0xff;
+ *dst_v = (v * a + *dst_v * invert_a) / 0xff;
+ break; }
+ }
+ }
+ dst_x++;
+ }
+ src += sizeof(long);
+ }
+ }
+ }
+ }
+
+// This frees cursor->pixels
+ XFree(cursor);
+ }
+ }