{"record":{"id":"a34ab7a52ea59260","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-function-a34ab7","errorCode":null,"errorMessage":"\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': Sprite vector (%lu values) and its specified sprite geometry (%d,%d,%d,%d) (%lu values) do not match.\"","messagePattern":"\"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>: Function 'draw\\(\\)': Sprite vector \\(%lu values\\) and its specified sprite geometry \\((.+?),(.+?),(.+?),(.+?)\\) \\(%lu values\\) do not match\\.\"","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":30176,"sourceCode":"        dy = (unsigned int)dy==~0U?h:(int)_mp_arg(14);\n        dz = (unsigned int)dz==~0U?d:(int)_mp_arg(15);\n        dc = (unsigned int)dc==~0U?s:(int)_mp_arg(16);\n\n        if (w<=0 || h<=0 || d<=0 || s<=0)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Invalid specified target vector geometry (%d,%d,%d,%d).\",\n                                      mp.imgin.pixel_type(),w,h,d,s);\n        if (sizD<(ulongT)w*h*d*s)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Target vector (%lu values) and its specified target geometry (%d,%d,%d,%d) \"\n                                      \"(%lu values) do not match.\",\n                                      mp.imgin.pixel_type(),sizD,w,h,d,s,(ulongT)w*h*d*s);\n        if (dx<=0 || dy<=0 || dz<=0 || dc<=0)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Invalid specified sprite geometry (%d,%d,%d,%d).\",\n                                      mp.imgin.pixel_type(),dx,dy,dz,dc);\n        if (sizS<(ulongT)dx*dy*dz*dc)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                      \"Sprite vector (%lu values) and its specified sprite geometry (%d,%d,%d,%d) \"\n                                      \"(%lu values) do not match.\",\n                                      mp.imgin.pixel_type(),sizS,dx,dy,dz,dc,(ulongT)dx*dy*dz*dc);\n\n        CImg<doubleT> D(ptrd,w,h,d,s,true);\n        const CImg<doubleT> S(ptrs,dx,dy,dz,dc,true);\n        const float opacity = (float)_mp_arg(17);\n\n        if (mp.opcode[18]!=~0U) { // Opacity mask specified\n          const ulongT sizM = mp.opcode[19];\n          if (sizM<(ulongT)dx*dy*dz)\n            throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'draw()': \"\n                                        \"Mask vector (%lu values) and specified sprite geometry (%u,%u,%u,%u) \"\n                                        \"(%lu values) do not match.\",\n                                        mp.imgin.pixel_type(),sizS,dx,dy,dz,dc,(ulongT)dx*dy*dz*dc);\n          const CImg<doubleT> M(&_mp_arg(18) + 1,dx,dy,dz,(unsigned int)(sizM/(dx*dy*dz)),true);\n          D.draw_image(x,y,z,c,S,M,opacity,(float)_mp_arg(20));\n        } else D.draw_image(x,y,z,c,S,opacity);","sourceCodeStart":30158,"sourceCodeEnd":30194,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L30158-L30194","documentation":"The math-parser 'draw()' opcode checks that the sprite (source) vector contains at least dx*dy*dz*dc values. If sizS is smaller than the product of the declared sprite geometry, the vector cannot back the requested CImg view, so CImgArgumentException is thrown.","triggerScenarios":"Calling draw(...) where the sprite vector has fewer elements than the product of the specified sprite dimensions dx*dy*dz*dc.","commonSituations":"Passing a flat vector with an oversized declared geometry; recomputing geometry after resizing the source without updating the vector; copy-pasted dimension constants from another call site.","solutions":["Enlarge the sprite vector so it has at least dx*dy*dz*dc values, or","Shrink dx,dy,dz,dc so their product fits within sizS","Print/verify vector size vs geometry product before the call"],"exampleFix":"// before\ndraw(ind,src,10,10,1,3,...); // src has 100 values\n// after\ndraw(ind,src,10,10,1,1,...); // matches 100-value vector","handlingStrategy":"validation","validationCode":"if (sprite.size() < (unsigned long)dx*dy*dz*dc) { /* fix sprite or geometry */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive dx,dy,dz,dc from the sprite vector's size","Recompute geometry whenever the source vector is resized","Log vector size and geometry product during development"],"tags":["cimg","image-processing","argument-validation","math-parser"],"backgroundTag":"tensor-shape-mismatch","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"}