XCB/X11: fix crop
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 8 May 2009 15:31:52 +0000 (18:31 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 8 May 2009 16:16:57 +0000 (19:16 +0300)
modules/video_output/xcb/x11.c

index 8e09880..0c5a123 100644 (file)
@@ -378,17 +378,24 @@ static void Display (vout_thread_t *vout, picture_t *pic)
     if (segment != 0)
         xcb_shm_put_image (p_sys->conn, p_sys->window, p_sys->gc,
           /* real width */ pic->p->i_pitch / pic->p->i_pixel_pitch,
-         /* real height */ pic->p->i_lines, /* x */ 0, /* y */ 0,
-               /* width */ pic->p->i_visible_pitch / pic->p->i_pixel_pitch,
-              /* height */ pic->p->i_visible_lines, /* x */ 0, /* y */ 0,
-                           p_sys->depth, XCB_IMAGE_FORMAT_Z_PIXMAP,
+         /* real height */ pic->p->i_lines,
+                   /* x */ vout->fmt_out.i_x_offset,
+                   /* y */ vout->fmt_out.i_y_offset,
+               /* width */ vout->fmt_out.i_visible_width,
+              /* height */ vout->fmt_out.i_visible_height,
+                           0, 0, p_sys->depth, XCB_IMAGE_FORMAT_Z_PIXMAP,
                            0, segment, 0);
     else
+    {
+        const size_t offset = vout->fmt_out.i_y_offset * pic->p->i_pitch;
+        const unsigned lines = pic->p->i_lines - vout->fmt_out.i_y_offset;
+
         xcb_put_image (p_sys->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
                        p_sys->window, p_sys->gc,
                        pic->p->i_pitch / pic->p->i_pixel_pitch,
-                       pic->p->i_lines, 0, 0, 0, p_sys->depth,
-                       pic->p->i_pitch * pic->p->i_lines, pic->p->p_pixels);
+                       lines, -vout->fmt_out.i_x_offset, 0, 0, p_sys->depth,
+                       pic->p->i_pitch * lines, pic->p->p_pixels + offset);
+    }
     xcb_flush (p_sys->conn);
 }