title: How do I get this XWindows.XGetImage call right?
body: <p>(update: the XGetPixel problem has been solved thanks to David)</p>
  
  <p>I am practicing some tasks from rosettacode.org for Standard ML, and I am stuck with the XGetImage call from XWindows (PolyML) . I get a badValue error for every attempt in XYPixmap format. 
  What I did, was</p>
  
  <pre><code> 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 ;
  </code></pre>
  
  <p>The XGetImage call returns</p>
  
  <pre><code> X Error BadValue in XGetImage
   Exception- XWindows "XGetImage failed" raised
  </code></pre>
  
  <p>The xwindows.cpp source does not make me much wiser:</p>
  
  <pre><code> XImage *image = XGetImage(d,drawable,x,y,w,h,mask,CImageFormat(format));
   if (image == 0) RaiseXWindows(taskData, "XGetImage failed");
  </code></pre>
  
  <blockquote>
    <p>ZPixmap + XGetPixel work fine in the most recent polyversion, the rest of this post has been solved:</p>
  </blockquote>
  
  <p>When I try ZPixmap, i get</p>
  
  <pre><code> 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}, ...}
  </code></pre>
  
  <p>but</p>
  
  <pre><code>XGetPixel disp im (XPoint {x=0,y=0}) ;
  </code></pre>
  
  <p>crashes PolyML</p>
  
  <p>The XGetImage example (in C) in the Xlib Programming Manual chapter 6.4.2 does not seem to do anything special, just use the display and a visible window. My window win is visible. I also tried the root window, and that does not work either. I think I have followed the PolyML for X manual correctly.</p>
  
  <p>What is missing here ?</p>