{"record":{"id":"bb8ac49faafd941a","repo":"Yalantis/uCrop","slug":"draw-spline-invalid-specified-point-set-u-u","errorCode":null,"errorMessage":"draw_spline(): Invalid specified point set (%u,%u,%u,%u,%p).","messagePattern":"draw_spline\\(\\): Invalid specified point set \\(%u,%u,%u,%u,%p\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":50536,"sourceCode":"       \\param points Vertices data.\n       \\param tangents Tangents data.\n       \\param color Pointer to \\c spectrum() consecutive values of type \\c T, defining the drawing color.\n       \\param opacity Drawing opacity.\n       \\param is_closed_set Tells if the drawn spline set is closed.\n       \\param precision Precision of the drawing.\n       \\param pattern An integer whose bits describe the line pattern.\n       \\param init_hatch If \\c true, init hatch motif.\n    **/\n    template<typename tp, typename tt, typename tc>\n    CImg<T>& draw_spline(const CImg<tp>& points, const CImg<tt>& tangents,\n                         const tc *const color, const float opacity=1,\n                         const bool is_closed_set=false, const float precision=4,\n                         const unsigned int pattern=~0U, const bool init_hatch=true) {\n      if (is_empty() || !points || !tangents || points._width<2 || tangents._width<2) return *this;\n      bool ninit_hatch = init_hatch;\n      switch (points._height) {\n      case 0 : case 1 :\n        throw CImgArgumentException(_cimg_instance\n                                    \"draw_spline(): Invalid specified point set (%u,%u,%u,%u,%p).\",\n                                    cimg_instance,\n                                    points._width,points._height,points._depth,points._spectrum,points._data);\n\n      default : {\n        const int x0 = (int)points(0,0), y0 = (int)points(0,1);\n        const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1);\n        int ox = x0, oy = y0;\n        float ou = u0, ov = v0;\n        for (unsigned int i = 1; i<points._width; ++i) {\n          const int x = (int)points(i,0), y = (int)points(i,1);\n          const float u = (float)tangents(i,0), v = (float)tangents(i,1);\n          draw_spline(ox,oy,ou,ov,x,y,u,v,color,precision,opacity,pattern,ninit_hatch);\n          ninit_hatch = false;\n          ox = x; oy = y; ou = u; ov = v;\n        }\n        if (is_closed_set) draw_spline(ox,oy,ou,ov,x0,y0,u0,v0,color,precision,opacity,pattern,false);\n      }","sourceCodeStart":50518,"sourceCodeEnd":50554,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L50518-L50554","documentation":"In the draw_spline(points,tangents,...) overload, each point must have at least 2 coordinates (points._height>=2); height 0 or 1 means points carry no 2D position and cannot define a spline, so CImgArgumentException is thrown with the points image dimensions and data pointer. Note the guard returns silently for empty/null/width<2 inputs; only height 0/1 with otherwise valid sizes throws.","triggerScenarios":"Passing a points image of dimension Wx1 (one coordinate per point, e.g. only x values) or an empty-height set while width>=2 and tangents._width>=2.","commonSituations":"Storing points as a single-row vector; a transposition bug producing 1-row matrices; generated point sets from numeric code that collapsed rows.","solutions":["Ensure points is Wx2 (or Wx3 with z) with height>=2 before calling.","Transpose or reshape the points image: points.get_transpose() or assign(width,2,...).","Verify tangents has matching width>=2 and height>=2 as well.","Skip the call when points data is degenerate (guard in caller)."],"exampleFix":"// before\nCImg<float> pts(10,1); // height 1\nimg.draw_spline(pts,tangents,color,1,false);\n// after\nCImg<float> pts(10,2); // rows: x[], y[]\nimg.draw_spline(pts,tangents,color,1,false);","handlingStrategy":"validation","validationCode":"if (points.height()<2 || tangents.height()<2) {\n  throw std::invalid_argument(\"spline points/tangents need >=2 rows (x,y per point)\");\n}\nimg.draw_spline(points, tangents, color, opacity, is_closed_set);","typeGuard":"template<typename T> bool isSplinePointSet(const CImg<T>& pts, const CImg<T>& tan) {\n  return pts.height()>=2 && tan.height()>=2 && pts.width()>=2 && tan.width()>=2;\n}","tryCatchPattern":"try {\n  img.draw_spline(points, tangents, color, opacity, closed);\n} catch (const cimg_library::CImgArgumentException& e) {\n  std::fprintf(stderr, \"draw_spline points: %s\\n\", e.what());\n}","preventionTips":["Store spline points as Wx2 (or Wx3) matrices: one row per coordinate axis.","Validate points and tangents layouts together; widths must match.","Assert points.height()>=2 in debug builds before spline drawing.","Guard against degenerate generated point sets (e.g. after transposition)."],"tags":["cimg","point-set","spline","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-14T05:17:10.506Z"}