Yalantis/uCrop · error · CImgDisplayException
CImgDisplay::screenshot(): Failed to take screenshot with…
Error message
CImgDisplay::screenshot(): Failed to take screenshot with coordinates (%d,%d)-(%d,%d).
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at ucrop/src/main/jni/CImg.h:11308 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/5d73f0a5e31afcea.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:11308
const unsigned long
red_mask = image->red_mask,
green_mask = image->green_mask,
blue_mask = image->blue_mask;
img.assign(image->width,image->height,1,3);
T *pR = img.data(0,0,0,0), *pG = img.data(0,0,0,1), *pB = img.data(0,0,0,2);
cimg_forXY(img,x,y) {
const unsigned long pixel = XGetPixel(image,x,y);
*(pR++) = (T)((pixel & red_mask)>>16);
*(pG++) = (T)((pixel & green_mask)>>8);
*(pB++) = (T)(pixel & blue_mask);
}
XDestroyImage(image);
}
}
if (!X11_attr.display) XCloseDisplay(dpy);
X11_attr.unlock();
if (img.is_empty())
throw CImgDisplayException("CImgDisplay::screenshot(): Failed to take screenshot "
"with coordinates (%d,%d)-(%d,%d).",
x0,y0,x1,y1);
}
template<typename T>
const CImgDisplay& snapshot(CImg<T>& img) const {
if (is_empty()) { img.assign(); return *this; }
const unsigned char *ptrs = (unsigned char*)_data;
img.assign(_width,_height,1,3);
T
*data1 = img.data(0,0,0,0),
*data2 = img.data(0,0,0,1),
*data3 = img.data(0,0,0,2);
cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
if (X11_attr.is_blue_first) cimg::swap(data1,data3);
switch (X11_attr.nb_bits) {
case 8 : {View on GitHub (pinned to f788b534b4)