{"record":{"id":"c5c59b6b74c0280b","repo":"Yalantis/uCrop","slug":"cimg-s-streamline-invalid-specified-integrat","errorCode":null,"errorMessage":"CImg<%s>::streamline(): Invalid specified integration length %g (should be >0).","messagePattern":"CImg<(.+?)>::streamline\\(\\): Invalid specified integration length %g \\(should be >0\\)\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":41329,"sourceCode":"       \\param is_backward_tracking Tells if the streamline is estimated forward or backward.\n       \\param is_oriented_only Tells if the direction of the vectors must be ignored.\n       \\param x0 X-coordinate of the first bounding-box vertex.\n       \\param y0 Y-coordinate of the first bounding-box vertex.\n       \\param z0 Z-coordinate of the first bounding-box vertex.\n       \\param x1 X-coordinate of the second bounding-box vertex.\n       \\param y1 Y-coordinate of the second bounding-box vertex.\n       \\param z1 Z-coordinate of the second bounding-box vertex.\n    **/\n    template<typename tfunc>\n    static CImg<floatT> streamline(const tfunc& func,\n                                   const float x, const float y, const float z,\n                                   const float L=256, const float dl=0.1f,\n                                   const unsigned int interpolation_type=2, const bool is_backward_tracking=false,\n                                   const bool is_oriented_only=false,\n                                   const float x0=0, const float y0=0, const float z0=0,\n                                   const float x1=0, const float y1=0, const float z1=0) {\n      if (dl<=0)\n        throw CImgArgumentException(\"CImg<%s>::streamline(): Invalid specified integration length %g \"\n                                    \"(should be >0).\",\n                                    pixel_type(),\n                                    dl);\n\n      const bool is_bounded = (x0!=x1 || y0!=y1 || z0!=z1);\n      if (L<=0 || (is_bounded && (x<x0 || x>x1 || y<y0 || y>y1 || z<z0 || z>z1))) return CImg<floatT>();\n      const unsigned int size_L = (unsigned int)cimg::round(L/dl + 1);\n      CImg<floatT> coordinates(size_L,3);\n      const float dl2 = dl/2;\n      float\n        *ptr_x = coordinates.data(0,0),\n        *ptr_y = coordinates.data(0,1),\n        *ptr_z = coordinates.data(0,2),\n        pu = (float)(dl*func(x,y,z,0)),\n        pv = (float)(dl*func(x,y,z,1)),\n        pw = (float)(dl*func(x,y,z,2)),\n        X = x, Y = y, Z = z;\n","sourceCodeStart":41311,"sourceCodeEnd":41347,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L41311-L41347","documentation":"CImg<T>::streamline() validates the integration step length dl and throws CImgArgumentException if dl<=0, since a positive step is required for the RK-style integration. It also silently returns an empty image if the total length L<=0 or the seed point lies outside the optional bounding box.","triggerScenarios":"Calling the functor-based streamline(...) overload with dl=0, a negative dl, or NaN, e.g. passing a user-supplied step length without validation.","commonSituations":"Computing dl from a user parameter or a division (e.g. L/steps with steps=0 or negative) that yields 0 or negative values; configuration default of 0 meaning 'unset'; float precision pushing dl to 0.","solutions":["Pass a strictly positive dl (e.g. 0.1, the default) to streamline().","Validate/normalize the step length before the call: if (dl <= 0) dl = 0.1f; or throw your own descriptive error.","Also ensure L > 0 and the seed point is inside the bounding box (x0..x1, y0..y1, z0..z1) when using the bounded variant, otherwise the call silently returns an empty image.","Derive dl defensively, e.g. dl = L / std::max(1u, nb_steps), to avoid division producing 0 or negative values."],"exampleFix":"// before\nfloat dl = L / steps;               // steps could be 0\nimg.streamline(func, x, y, z, L, dl);\n// after\nfloat dl = steps > 0 ? L / steps : 0.1f;\nif (dl <= 0) dl = 0.1f;\nimg.streamline(func, x, y, z, L, dl);","handlingStrategy":"validation","validationCode":"if (!(dl > 0)) throw std::invalid_argument(\"streamline dl must be > 0\");\nif (!(L > 0)) throw std::invalid_argument(\"streamline L must be > 0\");","typeGuard":null,"tryCatchPattern":"try { img.streamline(func, x, y, z, L, dl); }\ncatch (CImgArgumentException& e) { /* clamp dl to 0.1f and retry */ }","preventionTips":["Validate user-supplied step lengths before integration","Guard divisions that compute dl (steps >= 1)","Check the returned image is non-empty when using the bounded variant"],"tags":["cimg","image-processing","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}