@@ -63,11 +63,11 @@ int main(int argc, char* argv[])
6363 int16_t width ;
6464 int16_t height ;
6565 get_window_size (conn , root , & width , & height );
66- void * frameBuffer = malloc (3UL * width * height );
66+ void * frameBuffer = malloc (4UL * width * height );
6767
68- rfbScreenInfoPtr rfbScreen = rfbGetScreen (& argc , argv , (int )width , (int )height , 8 , 3 , 3 );
68+ rfbScreenInfoPtr rfbScreen = rfbGetScreen (& argc , argv , (int )width , (int )height , 8 , 3 , 4 );
6969 rfbScreen -> desktopName = "LibVNCServer X11 Example" ;
70- rfbScreen -> frameBuffer = (char * )malloc (3UL * width * height );
70+ rfbScreen -> frameBuffer = (char * )malloc (4UL * width * height );
7171 rfbScreen -> alwaysShared = TRUE;
7272 rfbScreen -> kbdAddEvent = keyCallback ;
7373 rfbScreen -> ptrAddEvent = mouseCallback ;
@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
7777 while (TRUE)
7878 {
7979 get_window_image (conn , root , (uint8_t * )frameBuffer );
80- dirty_copy (rfbScreen , (uint8_t * )frameBuffer , (int )width , (int )height , 3 );
80+ dirty_copy (rfbScreen , (uint8_t * )frameBuffer , (int )width , (int )height , 4 );
8181 }
8282
8383 free (rfbScreen -> frameBuffer );
@@ -117,13 +117,14 @@ void convert_bgrx_to_rgb(const uint8_t* in, uint16_t width, uint16_t height, uin
117117 {
118118 for (uint16_t x = 0 ; x < width ; x ++ )
119119 {
120- buff [(y * width + x )* 3 ] = in [(y * width + x )* 4 + 2 ];
121- buff [(y * width + x )* 3 + 1 ] = in [(y * width + x )* 4 + 1 ];
122- buff [(y * width + x )* 3 + 2 ] = in [(y * width + x )* 4 ];
120+ buff [(y * width + x )* 4 ] = in [(y * width + x )* 4 + 2 ];
121+ buff [(y * width + x )* 4 + 1 ] = in [(y * width + x )* 4 + 1 ];
122+ buff [(y * width + x )* 4 + 2 ] = in [(y * width + x )* 4 ];
123123 }
124124 }
125125}
126126
127+
127128void get_window_size (xcb_connection_t * conn , xcb_window_t window , uint16_t * width , uint16_t * height )
128129{
129130 xcb_get_geometry_cookie_t cookie = xcb_get_geometry (conn , window );
@@ -176,4 +177,4 @@ void send_motion(xcb_connection_t *conn, int16_t x, int16_t y)
176177{
177178 xcb_test_fake_input (conn , XCB_MOTION_NOTIFY , 0 , XCB_CURRENT_TIME , XCB_NONE , x , y , 0 );
178179 xcb_flush (conn );
179- }
180+ }
0 commit comments