XGetImage是否会返回32位深度的XImage?

时间:2014-10-13 21:54:53

标签: xlib

我正在使用XGetImage来读取OpenGL窗口的像素。返回的XImage显示24位的深度,但我的OpenGL上下文具有我想要返回的alpha值。有没有办法从XGetImage获取32位XImage,或者X已经将图像展平为24位?

函数调用:

::XImage *winImage = XGetImage(dpy_i->dpy, wnd_i->wnd,
    x, y, width, height, 0xffffffff, ZPixmap);

GDB输出:

(gdb) print *winImage
$2 = {width = 640, height = 512, xoffset = 0, format = 2, 
data = 0x7fffe72fd010 "\377\377\377", byte_order = 0, 
bitmap_unit = 32, bitmap_bit_order = 0, bitmap_pad = 32, 
depth = 24, bytes_per_line = 2560, bits_per_pixel = 32, 
red_mask = 16711680, green_mask = 65280, blue_mask = 255, 
obdata = 0x0, f = {create_image = 0x7ffff4b67810 <XCreateImage>, 
destroy_image = 0x7ffff4b665b0, get_pixel = 0x7ffff4b67520, 
put_pixel = 0x7ffff4b67450, sub_image = 0x7ffff4b67170, 
add_pixel = 0x7ffff4b66650}}

1 个答案:

答案 0 :(得分:0)

我似乎总是得到32位图像。这是我的代码,js-ctypes,我拍了所有显示器的截图。

https://github.com/Noitidart/_scratchpad/blob/c41012b16842f0769595033bd51a3801451319be/x11%20new%20way%20skel%20non%20jsm.js

这是我在XGetImage之后的XImage结构:

"width:" "1280" "height:" "919" "xoffset:" "0" "format:" "2" "data:" "ctypes.char.ptr(ctypes.UInt64("0x7f850fe00000"))" "byte_order:" "0" "bitmap_unit:" "32" "bitmap_bit_order:" "0" "bitmap_pad:" "32" "depth:" "24" "bytes_per_line:" "5120" "bits_per_pixel:" "32" "red_mask:" "16711680" "green_mask:" "65280" "blue_mask:" "255" "_END_"