How to change the bit-depth of XGetImage, Xlib ?
Hello, I am trying to use Xlib to capture the screen, this is what I have so far and it's working fine:
PHP Code:
P.S. The above code prints PHP Code:
|
I'm not pretending to be an expert here, but from what the Xlib programming manual hints at, the plane_mask (if used with the XYPixmap format), specifies the number of bits. So for example, if you want a 24-bit image, you use
XGetImage(display, pixmap, 0, 0, w, h, 0x00ffffff, XYPixmap); where 24 bits of the plane_mask parameter are set. The bits per pixels will probably be filled out automatically and rounded up to a value that is usable for the X11 server. This should be quite easy and fun to try out ! :) |
Quote:
PHP Code:
|
If you are requesting an 12-bit image, the data may actually only consist of 16-bit data (rounded by X11), so be careful if you pass this to OpenGL, which will expect the data type you are specifying (like B8G8R8A8 in your example), and this can be quite different and lead to memory corruption.
So best to check the bytes_per_line (= bytes per one row of bytes in the image) of the returned XImage. If this is less than you need to pass to GL, you may have to work on a temporary buffer and pass this to OpenGL for rendering. For >= 24-bit images this is probably not necessary. |
Quote:
Thanks again for the help :) |
So the scrambling with the XYPixmap you mentioned before should be expĺained now, or not ? :)
|
Quote:
I've been reading about the XYPixmap, I'm not sure, but, it seems that it stores all red pixels first then all green pixels then all blue pixels. |
All times are GMT -5. The time now is 03:48 PM. |