{"record":{"id":"a12a20e953e113ed","repo":"Yalantis/uCrop","slug":"screenshot-screenshot-feature-is-not-supported","errorCode":null,"errorMessage":"screenshot(): Screenshot feature is not supported when using SDL3-based display.","messagePattern":"screenshot\\(\\): Screenshot feature is not supported when using SDL3-based display\\.","errorType":"exception","errorClass":"CImgDisplayException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":12635,"sourceCode":"            const unsigned char\n              R = (unsigned char)((*(data1++) - _min)*mm),\n              G = (unsigned char)((*(data2++) - _min)*mm),\n              B = (unsigned char)((*(data3++) - _min)*mm);\n            *(ptrd++) = (unsigned int)((R<<24) | (G<<16) | (B<<8) | 255);\n          }\n        }\n        }\n      }\n      if (ndata!=_data) { _render_resize(ndata,img._width,img._height,_data,_width,_height); delete[] ndata; }\n      SDL3_attr.unlock();\n\n//      process_events(false);\n      return *this;\n    }\n\n    template<typename T>\n    static void screenshot(const int, const int, const int, const int, CImg<T>&) {\n      throw CImgDisplayException(\"screenshot(): Screenshot feature is not supported when using SDL3-based display.\");\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 int *ptrs = _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      for (cimg_ulong xy = (cimg_ulong)img._width*img._height; xy>0; --xy) {\n        const unsigned int val = *(ptrs++);\n        *(data1++) = (T)(unsigned char)(val>>24);\n        *(data2++) = (T)(unsigned char)((val>>16)&0xFF);\n        *(data3++) = (T)(unsigned char)((val>>8)&0xFF);\n      }\n      return *this;","sourceCodeStart":12617,"sourceCodeEnd":12653,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L12617-L12653","documentation":"The SDL3 build of CImgDisplay implements screenshot() as a stub that always throws CImgDisplayException: capturing screen content is not implemented for the SDL3 display backend. Unlike the X11/GDI/Win32 backends, there is no native screen-grab path wired up, so the static screenshot() overloads are unconditionally unsupported here.","triggerScenarios":"Calling any CImgDisplay::screenshot(x,y,w,h,img) overload in a build compiled with cimg_display=3 (SDL3).","commonSituations":"Porting code that used screenshot() with the X11 or Win32 backend to an SDL3 build; assuming feature parity across CImg display backends; build scripts switched the CImg display type to SDL3.","solutions":["Build with a supported display backend (cimg_display=1 X11, =2 Win32/GDI) if screenshot() is required.","Replace screenshot() with an SDL3-native or OS-level capture (e.g. SDL_RenderReadPixels on your own renderer, or a platform screen-capture API).","Wrap the call in a capability check for your backend and degrade gracefully."],"exampleFix":"// before\nCImg<unsigned char> cap;\nCImgDisplay::screenshot(0,0,w,h,cap); // throws under SDL3\n// after\n#if cimg_display != 3\nCImg<unsigned char> cap;\nCImgDisplay::screenshot(0,0,w,h,cap);\n#endif","handlingStrategy":"fallback","validationCode":"#if cimg_display == 3\n#error screenshot() unsupported with SDL3 backend\n#endif","typeGuard":"constexpr bool screenshot_supported = (cimg_display != 3);","tryCatchPattern":"try { CImgDisplay::screenshot(0,0,w,h,cap); }\ncatch (cimg_library::CImgDisplayException &e) { /* use SDL/OS capture instead */ }","preventionTips":["Gate screenshot() calls behind cimg_display preprocessor checks.","Keep backend feature matrices documented for X11/Win32/SDL3 builds.","Abstract screen capture behind your own interface with per-backend implementations."],"tags":["cimg","sdl3","unsupported-feature"],"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"}