Yalantis/uCrop · error · CImgArgumentException
draw_point(): Invalid specified point set (%u,%u,%u,%u,%p).
Error message
draw_point(): Invalid specified point set (%u,%u,%u,%u,%p).
What it means
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.
Source
Thrown at ucrop/src/main/jni/CImg.h:49881
template<typename tc>
CImg<T>& draw_point(const int x0, const int y0,
const tc *const color, const float opacity=1) {
return draw_point(x0,y0,0,color,opacity);
}
// Draw a points cloud.
/**
\param points Image of vertices coordinates.
\param color Pointer to \c spectrum() consecutive values, defining the drawing color.
\param opacity Drawing opacity.
**/
template<typename t, typename tc>
CImg<T>& draw_point(const CImg<t>& points,
const tc *const color, const float opacity=1) {
if (is_empty() || !points) return *this;
switch (points._height) {
case 0 : case 1 :
throw CImgArgumentException(_cimg_instance
"draw_point(): Invalid specified point set (%u,%u,%u,%u,%p).",
cimg_instance,
points._width,points._height,points._depth,points._spectrum,points._data);
case 2 : {
cimg_forX(points,i) draw_point((int)points(i,0),(int)points(i,1),color,opacity);
} break;
default : {
cimg_forX(points,i) draw_point((int)points(i,0),(int)points(i,1),(int)points(i,2),color,opacity);
}
}
return *this;
}
//! Draw a 2D line.
/**
\param x0 X-coordinate of the starting line point.
\param y0 Y-coordinate of the starting line point.
\param x1 X-coordinate of the ending line point.View on GitHub (pinned to f788b534b4)
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.
Example fix
// before CImg<int> points(1,1); // height 1 -> throws img.draw_point(points,color); // after CImg<int> points(1,2); points(0,0)=10; points(0,1)=20; img.draw_point(points,color);
Defensive patterns
Strategy: validation
Validate before calling
bool validPointSet(const CImg<int>& pts) {
return pts && pts._height >= 2;
}
if (validPointSet(points)) img.draw_point(points, color); Type guard
template<typename t>
bool is_valid_point_set(const CImg<t>& p) {
return !p.is_empty() && p._height >= 2;
} Try / catch
try {
img.draw_point(points, color);
} catch (CImgArgumentException& e) {
std::fprintf(stderr, "invalid point set: %s\n", e.what());
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- "[" cimg_appname "_math_parser] CImg<%s>: Function 'polygon(
- "[" cimg_appname "_math_parser] CImg<%s>: Function 'polygon(
- invert(): Specified lambda (%g) should be >=0.
- sort(): Invalid specified axis '%c' (should be { x | y | z |
- %s
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/46a5f8b052a2163b.
Report an issue: GitHub.