{"record":{"id":"46a5f8b052a2163b","repo":"Yalantis/uCrop","slug":"draw-point-invalid-specified-point-set-u-u","errorCode":null,"errorMessage":"draw_point(): Invalid specified point set (%u,%u,%u,%u,%p).","messagePattern":"draw_point\\(\\): 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":49881,"sourceCode":"    template<typename tc>\n    CImg<T>& draw_point(const int x0, const int y0,\n                        const tc *const color, const float opacity=1) {\n      return draw_point(x0,y0,0,color,opacity);\n    }\n\n    // Draw a points cloud.\n    /**\n       \\param points Image of vertices coordinates.\n       \\param color Pointer to \\c spectrum() consecutive values, defining the drawing color.\n       \\param opacity Drawing opacity.\n    **/\n    template<typename t, typename tc>\n    CImg<T>& draw_point(const CImg<t>& points,\n                        const tc *const color, const float opacity=1) {\n      if (is_empty() || !points) return *this;\n      switch (points._height) {\n      case 0 : case 1 :\n        throw CImgArgumentException(_cimg_instance\n                                    \"draw_point(): Invalid specified point set (%u,%u,%u,%u,%p).\",\n                                    cimg_instance,\n                                    points._width,points._height,points._depth,points._spectrum,points._data);\n      case 2 : {\n        cimg_forX(points,i) draw_point((int)points(i,0),(int)points(i,1),color,opacity);\n      } break;\n      default : {\n        cimg_forX(points,i) draw_point((int)points(i,0),(int)points(i,1),(int)points(i,2),color,opacity);\n      }\n      }\n      return *this;\n    }\n\n    //! Draw a 2D line.\n    /**\n       \\param x0 X-coordinate of the starting line point.\n       \\param y0 Y-coordinate of the starting line point.\n       \\param x1 X-coordinate of the ending line point.","sourceCodeStart":49863,"sourceCodeEnd":49899,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L49863-L49899","documentation":"CImg's draw_point(const CImg<t>& points, ...) overload draws multiple points from an image whose rows are point coordinates (2 or 3 values per point). The library requires points._height (the per-point coordinate count) to be at least 2; if the point-set image is empty (_height==0) or has only one row (_height==1), it cannot extract (x,y) per point and throws CImgArgumentException.","triggerScenarios":"Calling draw_point(CImg points, color) where the points image has _height==0 or _height==1, e.g. constructed with CImg<> pts(w,0) / (w,1), or a default-constructed empty CImg passed as the point set. Also fires on an unassigned points image (guard `!points` passes only when _data is non-null, but height can still be 0/1).","commonSituations":"Building the point list with wrong dimension order (CImg is column-major with x=point index, y=coordinates, so CImg<>(n,1) instead of CImg<>(1,n) style mistakes); an empty points image after failed population; copying API examples where points are (x,y) pairs but constructing with height 1.","solutions":["Ensure the points image has _height>=2: use CImg<int> pts(nb_points,2) (or 3 with z) and fill pts(i,0)=x, pts(i,1)=y.","Check the points image is non-empty before calling: if (points && points._height>=2) img.draw_point(...).","If drawing a single point, use the scalar overload draw_point(x,y,color) instead of the point-set overload.","For a point at a given index use the vector overload draw_point(x,y,z,color) rather than passing a 1-row image."],"exampleFix":"// before\nCImg<int> points(1,1); // height 1 -> throws\nimg.draw_point(points,color);\n\n// after\nCImg<int> points(1,2);\npoints(0,0)=10; points(0,1)=20;\nimg.draw_point(points,color);","handlingStrategy":"validation","validationCode":"bool validPointSet(const CImg<int>& pts) {\n  return pts && pts._height >= 2;\n}\nif (validPointSet(points)) img.draw_point(points, color);","typeGuard":"template<typename t>\nbool is_valid_point_set(const CImg<t>& p) {\n  return !p.is_empty() && p._height >= 2;\n}","tryCatchPattern":"try {\n  img.draw_point(points, color);\n} catch (CImgArgumentException& e) {\n  std::fprintf(stderr, \"invalid point set: %s\\n\", e.what());\n}","preventionTips":["Always construct point-set images as (nb_points, 2|3): coordinates on the y axis.","Check points._height>=2 before every point-set draw call.","Prefer the scalar draw_point(x,y,color) overload for single points.","Never pass default-constructed CImg objects as point sets."],"tags":["cimg","invalid-argument","graphics","point-set"],"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"}