I\'m trying to make a screenshot using Xlib and Cairo, however I\'m not sure to do it the good way, \"stride\" is really confusing me.
TFM:
CAIRO_FORMAT_RGB24
each pixel is a 32-bit quantity, with the upper 8 bits unused
TFM:
stride = cairo_format_stride_for_width (format, width);
data = malloc (stride * height);
Hence, the correct index calculation is
data[y * stride + x * 4 + 0] = blue;
data[y * stride + x * 4 + 1] = green;
data[y * stride + x * 4 + 2] = red; /* yes, in this order */
Also, masks are taken from the image and shifts are hard-coded, which makes absolutely no sense. Calculate the shifts from the masks.