{"record":{"id":"8f3734d6bfc94a49","repo":"Yalantis/uCrop","slug":"linear-atxy-p-empty-instance","errorCode":null,"errorMessage":"linear_atXY_p(): Empty instance.","messagePattern":"linear_atXY_p\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":15965,"sourceCode":"      const unsigned int\n        x = (unsigned int)nfx,\n        y = (unsigned int)nfy;\n      const float\n        dx = nfx - x,\n        dy = nfy - y;\n      const unsigned int\n        nx = dx>0?x + 1:x,\n        ny = dy>0?y + 1:y;\n      const Tfloat\n        Icc = (Tfloat)(*this)(x,y,z,c),  Inc = (Tfloat)(*this)(nx,y,z,c),\n        Icn = (Tfloat)(*this)(x,ny,z,c), Inn = (Tfloat)(*this)(nx,ny,z,c);\n      return Icc + (Inc - Icc + (Icc + Inn - Icn - Inc)*dy)*dx + (Icn - Icc)*dy;\n    }\n\n    //! Return pixel value, using linear interpolation and periodic boundary conditions for the X and Y-coordinates.\n    Tfloat linear_atXY_p(const float fx, const float fy, const int z=0, const int c=0) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"linear_atXY_p(): Empty instance.\",\n                                    cimg_instance);\n\n      return _linear_atXY_p(fx,fy,z,c);\n    }\n\n    Tfloat _linear_atXY_p(const float fx, const float fy, const int z=0, const int c=0) const {\n      const float\n        nfx = cimg::mod(fx,_width - 0.5f),\n        nfy = cimg::mod(fy,_height - 0.5f);\n      const unsigned int\n        x = (unsigned int)nfx,\n        y = (unsigned int)nfy;\n      const float\n        dx = nfx - x,\n        dy = nfy - y;\n      const unsigned int\n        nx = cimg::mod(x + 1,_width),","sourceCodeStart":15947,"sourceCodeEnd":15983,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L15947-L15983","documentation":"CImg<T>::linear_atXY_p(fx,fy,z,c) returns a bilinearly interpolated value with periodic (wrap-around) boundary conditions on both X and Y coordinates. It throws CImgInstanceException when the instance is empty since interpolation needs an allocated pixel buffer.","triggerScenarios":"Calling linear_atXY_p() on an empty CImg (never assigned, failed load, zero dimensions).","commonSituations":"Seamless/tiling image operations on an image that failed to load; texture sampling in panorama stitching with an empty source frame.","solutions":["Check img.is_empty() before invoking linear_atXY_p.","Ensure the image data was loaded or allocated before sampling.","Fix upstream producers so they never emit empty images (validate after load).","Prefer _linear_atXY_p() only when non-emptiness is already enforced."],"exampleFix":"// before\nfloat v = img.linear_atXY_p(fx, fy);\n// after\nif (!img.is_empty()) {\n  float v = img.linear_atXY_p(fx, fy);\n}","handlingStrategy":"validation","validationCode":"if (!img.is_empty()) { float v = img.linear_atXY_p(fx, fy); } else { /* load or fail */ }","typeGuard":"inline bool valid(const cimg_library::CImg<T>& img) { return !img.is_empty(); }","tryCatchPattern":"try { float v = img.linear_atXY_p(fx, fy); } catch (cimg_library::CImgInstanceException& e) { std::cerr << e.what() << '\\n'; v = fallbackValue; }","preventionTips":["Verify image load before tiling/seamless operations.","Assert non-empty state in class invariants.","Fail fast when upstream produces zero-sized images.","Prefer checked variants unless profiling shows overhead."],"tags":["cimg","interpolation","empty-instance"],"backgroundTag":"empty-required-field","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"}