title: X11 XGetImage BadMatch Error (invalid parameter attributes)
body: <p>I am trying to capture a screenshot on my linux pc. The compilation of code is fine but if I try to execute it, it keeps throwing same error as below:</p>
  
  <pre><code>X Error of failed request:  BadMatch (invalid parameter attributes)
    Major opcode of failed request:  73 (X_GetImage)
    Serial number of failed request:  7
    Current serial number in output stream:  7
  </code></pre>
  
  <p>Can anybody help me to figure out what is the problem?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  #include &lt;opencv2/highgui.hpp&gt;
  #include &lt;X11/Xlib.h&gt;
  #include &lt;X11/Xutil.h&gt;
  
  using namespace cv;
  
  int main()
  {
      Display* d = XOpenDisplay(nullptr);
      auto root = DefaultRootWindow(d);
  
      auto img = XGetImage(d, root, 0, 0, 1000, 1000, AllPlanes, ZPixmap);
      auto rimg = Mat(1000, 1000, CV_8UC4, img-&gt;data);
      imshow("test image", rimg);
      waitKey(0);
  
      return 0;
  }
  </code></pre>