{"record":{"id":"3c60d02c67987a6d","repo":"Yalantis/uCrop","slug":"cimgdisplay-assign-invalid-u-bits-screen-mode","errorCode":null,"errorMessage":"CImgDisplay::assign(): Invalid %u bits screen mode detected (only 8, 16, 24 and 32 bits modes are managed).","messagePattern":"CImgDisplay::assign\\(\\): Invalid %u bits screen mode detected \\(only 8, 16, 24 and 32 bits modes are managed\\)\\.","errorType":"exception","errorClass":"CImgDisplayException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":10048,"sourceCode":"      if (s) std::memcpy(tmp_title,np_title,s*sizeof(char));\n\n      // Destroy previous display window if existing.\n      if (!is_empty()) assign(false);\n\n      // Open X11 display and retrieve graphical properties.\n      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();\n      Display* &dpy = X11_attr.display;\n      if (!dpy) {\n        dpy = XOpenDisplay(0);\n        if (!dpy)\n          throw CImgDisplayException(_cimgdisplay_instance\n                                     \"assign(): Failed to open X11 display.\",\n                                     cimgdisplay_instance);\n\n        X11_attr.nb_bits = DefaultDepth(dpy,DefaultScreen(dpy));\n        if (X11_attr.nb_bits!=8 && X11_attr.nb_bits!=16 &&\n            X11_attr.nb_bits!=24 && X11_attr.nb_bits!=32)\n          throw CImgDisplayException(_cimgdisplay_instance\n                                     \"assign(): Invalid %u bits screen mode detected \"\n                                     \"(only 8, 16, 24 and 32 bits modes are managed).\",\n                                     cimgdisplay_instance,\n                                     X11_attr.nb_bits);\n        XVisualInfo vtemplate;\n        vtemplate.visualid = XVisualIDFromVisual(DefaultVisual(dpy,DefaultScreen(dpy)));\n        int nb_visuals;\n        XVisualInfo *vinfo = XGetVisualInfo(dpy,VisualIDMask,&vtemplate,&nb_visuals);\n        if (vinfo && vinfo->red_mask<vinfo->blue_mask) X11_attr.is_blue_first = true;\n        X11_attr.byte_order = ImageByteOrder(dpy);\n        XFree(vinfo);\n      }\n\n      X11_attr.lock();\n      if (!X11_attr.events_thread) {\n        X11_attr.events_thread = new pthread_t;\n        pthread_create(X11_attr.events_thread,0,_events_thread,0);\n      }","sourceCodeStart":10030,"sourceCodeEnd":10066,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L10030-L10066","documentation":"After opening the X11 display, CImg reads DefaultDepth() and throws CImgDisplayException if the visual depth is not 8/16/24/32 bits, because its display code only knows how to convert pixels for those depths. Unusual server/visual configurations (e.g. 12-, 15-, or 30-bit depth) are unsupported.","triggerScenarios":"Calling CImgDisplay::assign()/constructor while connected to an X server whose DefaultScreen depth is outside {8,16,24,32} — e.g. 15 or 16-bit framebuffers on embedded devices or legacy X setups.","commonSituations":"Embedded/ARM boards with unusual framebuffer depths; X servers started with a legacy depth (e.g. Depth 15) in xorg.conf; remote X servers with rare visual configurations.","solutions":["Reconfigure the X server to a standard 24-bit (or 32-bit) depth in xorg.conf / fbdev settings","Update graphics drivers/firmware so the framebuffer reports a supported depth","Use a different machine/Xvfb instance with depth 24 for display output"],"exampleFix":"# before (xorg.conf)\nDefaultDepth 15\n# after\nDefaultDepth 24","handlingStrategy":"try-catch","validationCode":"// depth check approximated with xdpyinfo:\n// xdpyinfo | grep 'depth of root window'  -> must be 8/16/24/32","typeGuard":null,"tryCatchPattern":"try { cimg::CImgDisplay d(img, \"win\"); } catch (const cimg_library::CImgDisplayException &e) { fprintf(stderr, \"Unsupported screen depth: %s\\n\", e.what()); }","preventionTips":["Configure the X server / framebuffer to standard 24-bit depth","Avoid exotic depths (12/15/30-bit) on embedded targets used with CImg","Use Xvfb with -screen 0 WxHx24 for consistent depth in CI"],"tags":["x11","display","color-depth","unsupported-configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}