(更新:感谢 David,XGetPixel 问题已得到解决)
我正在从 rosettacode.org 为 Standard ML 练习一些任务,但我被 XWindows (PolyML) 的 XGetImage 调用困住了。对于 XYPixmap 格式的每次尝试,我都会收到一个 badValue 错误。我所做的是
open XWindows ;
val disp = XOpenDisplay "" ;
val win = XCreateSimpleWindow (RootWindow disp) origin (Area {x=0,y=0,w=300,h=100}) 2 0 0xffffff ;
XMapWindow win;
XFlush disp ;
XGetImage win (Area {x=0,y=0,w=100,h=100}) AllPlanes XYPixmap ;
XGetImage 调用返回
X Error BadValue in XGetImage
Exception- XWindows "XGetImage failed" raised
xwindows.cpp 源代码并没有让我变得更聪明:
XImage *image = XGetImage(d,drawable,x,y,w,h,mask,CImageFormat(format));
if (image == 0) RaiseXWindows(taskData, "XGetImage failed");
ZPixmap + XGetPixel 在最近的 polyversion 中工作正常,这篇文章的其余部分已经解决:
当我尝试 ZPixmap 时,我得到了
val im = XGetImage win (Area {x=0,y=0,w=1,h=1}) AllPlanes ZPixmap ;
val im =
XImage
{bitmapBitOrder = MSBFirst, bitmapPad = 32, bitmapUnit = 32,
bitsPerPixel = 1, byteOrder = MSBFirst, bytesPerLine = 4, data =
ImageData
"\^A\^@\^@\^@ ... repeat 22 x .... \^A\^@\^@\^@",
depth = 24, format = ZPixmap, size =
Rect {bottom = 1, left = 0, right = 1, top = 0}, ...}
但
XGetPixel disp im (XPoint {x=0,y=0}) ;
PolyML 崩溃
Xlib 编程手册第 6.4.2 章中的 XGetImage 示例(C 语言)似乎没有做任何特别的事情,只是使用了显示和可见窗口。我的窗口胜利是可见的。我也尝试了根窗口,但这也不起作用。我想我已经正确地遵循了 PolyML for X 手册。
这里缺少什么?