{"record":{"id":"0438533431a84373","repo":"Yalantis/uCrop","slug":"atnxy-empty-instance","errorCode":null,"errorMessage":"atNXY(): Empty instance.","messagePattern":"atNXY\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":65122,"sourceCode":"    }\n\n    //! Access to pixel value with Dirichlet boundary conditions for the 3 coordinates (\\c pos, \\c x,\\c y) \\const.\n    T atNXY(const int pos, const int x, const int y, const int z, const int c, const T& out_value) const {\n      return (pos<0 || pos>=width())?out_value:_data[pos].atXY(x,y,z,c,out_value);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions for the 3 coordinates (\\c pos, \\c x,\\c y).\n    /**\n       \\param pos Index of the image element to access.\n       \\param x X-coordinate of the pixel value.\n       \\param y Y-coordinate of the pixel value.\n       \\param z Z-coordinate of the pixel value.\n       \\param c C-coordinate of the pixel value.\n       \\note <tt>list.atNXYZ(p,x,y,z,c);</tt> is equivalent to <tt>list[p].atXYZ(x,y,z,c);</tt>.\n    **/\n    T& atNXY(const int pos, const int x, const int y, const int z=0, const int c=0) {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXY(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXY(pos,x,y,z,c);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions for the 3 coordinates (\\c pos, \\c x,\\c y) \\const.\n    T atNXY(const int pos, const int x, const int y, const int z=0, const int c=0) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXY(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXY(pos,x,y,z,c);\n    }\n\n    T& _atNXY(const int pos, const int x, const int y, const int z=0, const int c=0) {\n      return _data[cimg::cut(pos,0,width() - 1)].atXY(x,y,z,c);","sourceCodeStart":65104,"sourceCodeEnd":65140,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L65104-L65140","documentation":"Non-const CImgList<T>::atNXY(pos,x,y,z=0,c=0) accesses a writable pixel with Neumann boundary conditions on coordinates (pos,x,y) (z and c default to 0). It throws CImgInstanceException when the list instance is empty.","triggerScenarios":"Calling list.atNXY(p,x,y) on a CImgList with is_empty()==true, e.g. an unloaded or cleared list.","commonSituations":"2D pixel edits on a list-based image set whose load failed; code after remove_image() removed all entries; lists returned empty by a filtering routine.","solutions":["Check list.is_empty() before any atNXY call.","Confirm the list-populating call succeeded and returned a nonzero size.","If editing a single image, extract it (or use a CImg directly) and check is_empty() on the image instead.","Catch CImgInstanceException if empty lists are a normal input condition."],"exampleFix":"// before\nCImgList<unsigned char> frames;\nframes.atNXY(0, x, y) = 255;\n// after\nCImgList<unsigned char> frames;\nif (!frames.load(path) || frames.is_empty()) return;\nframes.atNXY(0, x, y, 0, 0) = 255;","handlingStrategy":"validation","validationCode":"// C++\nif (list.is_empty()) return; // before atNXY writes","typeGuard":"template <typename T>\nbool writable(const CImgList<T>& l) { return !l.is_empty(); }","tryCatchPattern":"// C++\ntry {\n  list.atNXY(p, x, y) = v;\n} catch (CImgInstanceException& e) {\n  // empty list: re-load or skip\n}","preventionTips":["Check is_empty() before 2D pixel-edit loops on lists.","Detect remove_image() calls that can empty the list mid-pipeline.","Check load() results so emptiness is caught at the source.","Prefer editing a CImg directly for single-image work."],"tags":["cimg","cpp","empty-list","pixel-access"],"backgroundTag":"empty-result-set","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"}