ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
However, I need to control the depth, for example, I need to capture a 8, 16, 24, 32 bit image, I think I need to change the plane-mask, the problem is I don't really understand what a plane-mask is (tried the manual, google no luck), so can anyone explain to me what a plane-mask is and how to use it to change the depth ?
P.S.
The above code prints
PHP Code:
bpp 32 depth 24
Which I don't understand either, because I thought that the bpp and depth are the same, right ?
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
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 !
the plane_mask (if used with the XYPixmap format), specifies the number of bits.
Thanks for the reply , I did some experiments like you said, I tried 0x00f0f0f0 for 12 bits and seems okay, except that when I use XYPixmap the image is all scrambled up (I'm using opengl to draw the image), here's all the code I have so far:
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.
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
I am not sure about the rounding up, but anyway, that's true if you use a XYPixmap, however, if you use a ZPixmap you get all of the 32 bits (the ones you don't set in the plane-mask are zeros), which I think I can live with, because I plan to compress the data anyways.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.