{"record":{"id":"5d73f0a5e31afcea","repo":"Yalantis/uCrop","slug":"cimgdisplay-screenshot-failed-to-take-screensh","errorCode":null,"errorMessage":"CImgDisplay::screenshot(): Failed to take screenshot with coordinates (%d,%d)-(%d,%d).","messagePattern":"CImgDisplay::screenshot\\(\\): Failed to take screenshot with coordinates \\((.+?),(.+?)\\)-\\((.+?),(.+?)\\)\\.","errorType":"exception","errorClass":"CImgDisplayException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":11308,"sourceCode":"          const unsigned long\n            red_mask = image->red_mask,\n            green_mask = image->green_mask,\n            blue_mask = image->blue_mask;\n          img.assign(image->width,image->height,1,3);\n          T *pR = img.data(0,0,0,0), *pG = img.data(0,0,0,1), *pB = img.data(0,0,0,2);\n          cimg_forXY(img,x,y) {\n            const unsigned long pixel = XGetPixel(image,x,y);\n            *(pR++) = (T)((pixel & red_mask)>>16);\n            *(pG++) = (T)((pixel & green_mask)>>8);\n            *(pB++) = (T)(pixel & blue_mask);\n          }\n          XDestroyImage(image);\n        }\n      }\n      if (!X11_attr.display) XCloseDisplay(dpy);\n      X11_attr.unlock();\n      if (img.is_empty())\n        throw CImgDisplayException(\"CImgDisplay::screenshot(): Failed to take screenshot \"\n                                   \"with coordinates (%d,%d)-(%d,%d).\",\n                                   x0,y0,x1,y1);\n    }\n\n    template<typename T>\n    const CImgDisplay& snapshot(CImg<T>& img) const {\n      if (is_empty()) { img.assign(); return *this; }\n      const unsigned char *ptrs = (unsigned char*)_data;\n      img.assign(_width,_height,1,3);\n      T\n        *data1 = img.data(0,0,0,0),\n        *data2 = img.data(0,0,0,1),\n        *data3 = img.data(0,0,0,2);\n\n      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();\n      if (X11_attr.is_blue_first) cimg::swap(data1,data3);\n      switch (X11_attr.nb_bits) {\n      case 8 : {","sourceCodeStart":11290,"sourceCodeEnd":11326,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L11290-L11326","documentation":"Thrown by CImgDisplay::screenshot() when XGetImage fails to read the requested screen rectangle, i.e. the coordinates (x0,y0)-(x1,y1) lie (fully or partly) outside the screen geometry or the root-window image could not be retrieved.","triggerScenarios":"Thrown at ucrop/src/main/jni/CImg.h:11308 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp the capture rectangle to the actual screen dimensions (e.g. via screen_width()/screen_height()) before calling screenshot()","Verify that x1>=x0 and y1>=y0 and that all four coordinates are non-negative and within the display bounds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}