{"record":{"id":"93f7373327b90c51","repo":"Yalantis/uCrop","slug":"draw-spline-invalid-specified-texture-u-u-u","errorCode":null,"errorMessage":"draw_spline(): Invalid specified texture (%u,%u,%u,%u,%p).","messagePattern":"draw_spline\\(\\): Invalid specified texture \\(%u,%u,%u,%u,%p\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":50483,"sourceCode":"       \\param tx0 X-coordinate of the starting texture point.\n       \\param ty0 Y-coordinate of the starting texture point.\n       \\param tx1 X-coordinate of the ending texture point.\n       \\param ty1 Y-coordinate of the ending texture point.\n       \\param precision Curve drawing precision.\n       \\param opacity Drawing opacity.\n       \\param pattern An integer whose bits describe the line pattern.\n       \\param init_hatch if \\c true, reinit hatch motif.\n    **/\n    template<typename t>\n    CImg<T>& draw_spline(const int x0, const int y0, const float u0, const float v0,\n                         const int x1, const int y1, const float u1, const float v1,\n                         const CImg<t>& texture,\n                         const int tx0, const int ty0, const int tx1, const int ty1,\n                         const float opacity=1,\n                         const float precision=4, const unsigned int pattern=~0U,\n                         const bool init_hatch=true) {\n      if (texture._depth>1 || texture._spectrum<_spectrum)\n        throw CImgArgumentException(_cimg_instance\n                                    \"draw_spline(): Invalid specified texture (%u,%u,%u,%u,%p).\",\n                                    cimg_instance,\n                                    texture._width,texture._height,texture._depth,texture._spectrum,texture._data);\n      if (is_empty()) return *this;\n      if (is_overlapped(texture))\n        return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,+texture,tx0,ty0,tx1,ty1,precision,opacity,pattern,init_hatch);\n      if (x0==x1 && y0==y1)\n        return draw_point(x0,y0,texture.get_vector_at(x0<=0?0:x0>=texture.width()?texture.width() - 1:x0,\n                                                      y0<=0?0:y0>=texture.height()?texture.height() - 1:y0).data(),\n                          opacity);\n      bool ninit_hatch = init_hatch;\n      const float\n        ax = u0 + u1 + 2*(x0 - x1),\n        bx = 3*(x1 - x0) - 2*u0 - u1,\n        ay = v0 + v1 + 2*(y0 - y1),\n        by = 3*(y1 - y0) - 2*v0 - v1,\n        _precision = 1/(cimg::hypot((float)x0 - x1,(float)y0 - y1)*(precision>0?precision:1));\n      int ox = x0, oy = y0, otx = tx0, oty = ty0;","sourceCodeStart":50465,"sourceCodeEnd":50501,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L50465-L50501","documentation":"draw_spline() with a texture validates texture._depth<=1 and texture._spectrum>=instance._spectrum. Textures must be flat 2D images with enough channels; otherwise CImgArgumentException reports the texture dimensions.","triggerScenarios":"Passing a 3D (depth>1) image or a texture with fewer spectrum channels than the drawing image as the texture parameter of the tangent-based draw_spline overload.","commonSituations":"Gradient/gradient-map textures stored as volumes; grayscale gradient map used on an RGB image; texture loaded with wrong channel count.","solutions":["Flatten the texture to depth 1 and resize channels: tex.get_resize(tex.width(),tex.height(),1,img.spectrum()).","Ensure the texture is 2D before passing.","Match or exceed the image channel count in the texture.","For overlap the library handles copies internally; only depth/spectrum need pre-checks."],"exampleFix":"// before\nCImg<float> grad(128,128,1,1); // 1 channel\nimg.draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,grad,0,0,127,127,1.0f);\n// after\nCImg<float> grad3 = grad.get_resize(grad.width(),grad.height(),1,img.spectrum());\nimg.draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,grad3,0,0,127,127,1.0f);","handlingStrategy":"validation","validationCode":"if (texture.depth()>1 || texture.spectrum()<img.spectrum()) {\n  texture = texture.get_resize(-100,-100,1,img.spectrum());\n}\nimg.draw_spline(x0,y0,u0,v0,x1,y1,u1,v1, texture, tx0,ty0,tx1,ty1, opacity, precision);","typeGuard":"template<typename T, typename t>\nbool isFlatSufficientTexture(const CImg<T>& img, const CImg<t>& tex) {\n  return tex.depth()<=1 && tex.spectrum()>=img.spectrum();\n}","tryCatchPattern":"try {\n  img.draw_spline(x0,y0,u0,v0,x1,y1,u1,v1, texture, tx0,ty0,tx1,ty1);\n} catch (const cimg_library::CImgArgumentException& e) {\n  std::fprintf(stderr, \"draw_spline texture: %s\\n\", e.what());\n}","preventionTips":["Normalize all textures (depth 1, spectrum >= target) at load time.","Reuse the same texture-validation helper for draw_line/draw_spline/draw_triangle.","Check texture channels whenever image spectrum changes (e.g. switching to RGBA)."],"tags":["cimg","texture","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"}