{"record":{"id":"054f43bb66e188e0","repo":"Yalantis/uCrop","slug":"cimgdisplay-no-display-available","errorCode":null,"errorMessage":"CImgDisplay(): No display available.","messagePattern":"CImgDisplay\\(\\): No display available\\.","errorType":"exception","errorClass":"CImgDisplayException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":8708,"sourceCode":"      _window_x(cimg::type<int>::min()),_window_y(cimg::type<int>::min()),\n      _mouse_x(-1),_mouse_y(-1),_wheel(0),\n      _is_closed(true),_is_resized(false),_is_moved(false),_is_event(false) {\n      assign(disp);\n    }\n\n    //! Take a screenshot.\n    /**\n       \\param[out] img Output screenshot. Can be empty on input\n    **/\n    template<typename T>\n    static void screenshot(CImg<T>& img) {\n      return screenshot(0,0,cimg::type<int>::max(),cimg::type<int>::max(),img);\n    }\n\n#if cimg_display==0\n\n    static void _no_display_exception() {\n      throw CImgDisplayException(\"CImgDisplay(): No display available.\");\n    }\n\n    //! Destructor - Empty constructor \\inplace.\n    /**\n       \\note Replace the current instance by an empty display.\n    **/\n    CImgDisplay& assign() {\n      return flush();\n    }\n\n    //! Construct a display with specified dimensions \\inplace.\n    /**\n    **/\n    CImgDisplay& assign(const unsigned int width, const unsigned int height,\n                        const char *const title=0, const unsigned int normalization=3,\n                        const bool is_fullscreen=false, const bool is_closed=false) {\n      cimg::unused(width,height,title,normalization,is_fullscreen,is_closed);\n      _no_display_exception();","sourceCodeStart":8690,"sourceCodeEnd":8726,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L8690-L8726","documentation":"When CImg is compiled with cimg_display==0 (no display support), every CImgDisplay constructor/operation routes through _no_display_exception(), which throws CImgDisplayException. This build simply has no windowing backend (X11/GDI/SDL) linked in, so no display object can ever exist.","triggerScenarios":"Constructing CImgDisplay or calling CImgDisplay::wait/assign/etc. in a binary built with cimg_display=0, or where none of the supported display libraries were detected at compile time.","commonSituations":"Building the Android NDK/JNI library (headless, no display headers) but reusing GUI code; cross-compiling on a machine without X11 headers so CImg silently disables display support.","solutions":["Remove CImgDisplay usage from headless builds — render to files or offscreen buffers instead","Rebuild with display support (cimg_display=1 and X11 dev headers installed) if a GUI is truly needed","Guard display code with #if cimg_display!=0 preprocessor checks"],"exampleFix":"// before\nCImgDisplay disp(img, \"preview\"); // cimg_display==0\n// after\n#if cimg_display!=0\nCImgDisplay disp(img, \"preview\");\n#else\nimg.save(\"preview.png\"); // headless fallback\n#endif","handlingStrategy":"fallback","validationCode":"#if cimg_display==0\n  // compile-time: display code is disabled — do not instantiate CImgDisplay\n#endif","typeGuard":"bool displaySupported() { return cimg_display != 0; }","tryCatchPattern":"try { cimg::CImgDisplay d(img, \"preview\"); } catch (const cimg_library::CImgDisplayException &e) { img.save(\"preview.png\"); // headless fallback\n}","preventionTips":["Guard all CImgDisplay usage with #if cimg_display!=0","For GUI features, build with display headers present (X11 dev packages)","Keep a file/offscreen output path for headless targets like Android NDK"],"tags":["cimg","display","build-configuration","headless"],"backgroundTag":"unsupported-operation","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"}