{"record":{"id":"26f2d701d393f342","repo":"Yalantis/uCrop","slug":"save-dlm-instance-is-multispectral-values-alon","errorCode":null,"errorMessage":"save_dlm(): Instance is multispectral, values along C will be unrolled in file '%s'.","messagePattern":"save_dlm\\(\\): Instance is multispectral, values along C will be unrolled in file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":61461,"sourceCode":"\n    //! Save image as a DLM file \\overloading.\n    const CImg<T>& save_dlm(std::FILE *const file) const {\n      return _save_dlm(file,0);\n    }\n\n    const CImg<T>& _save_dlm(std::FILE *const file, const char *const filename) const {\n      if (!file && !filename)\n        throw CImgArgumentException(_cimg_instance\n                                    \"save_dlm(): Specified filename is (null).\",\n                                    cimg_instance);\n      if (is_empty()) { cimg::fempty(file,filename); return *this; }\n      if (_depth>1)\n        cimg::warn(_cimg_instance\n                   \"save_dlm(): Instance is volumetric, values along Z will be unrolled in file '%s'.\",\n                   cimg_instance,\n                   filename?filename:\"(FILE*)\");\n      if (_spectrum>1)\n        cimg::warn(_cimg_instance\n                   \"save_dlm(): Instance is multispectral, values along C will be unrolled in file '%s'.\",\n                   cimg_instance,\n                   filename?filename:\"(FILE*)\");\n\n      std::FILE *const nfile = file?file:cimg::fopen(filename,\"w\");\n      const T* ptrs = _data;\n      cimg_forYZC(*this,y,z,c) {\n        cimg_forX(*this,x) std::fprintf(nfile,\"%.17g%s\",(double)*(ptrs++),(x==width() - 1)?\"\":\",\");\n        std::fputc('\\n',nfile);\n      }\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Save image as a BMP file.\n    /**\n      \\param filename Filename, as a C-string.\n    **/","sourceCodeStart":61443,"sourceCodeEnd":61479,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L61443-L61479","documentation":"save_dlm() writes a plain 2D value table; multispectral images (_spectrum>1, e.g. RGB or vector-valued pixels) do not fit. The library warns that the C (channel/spectrum) axis will be unrolled into the file and proceeds, so channel structure is only implicitly encoded in the output rows.","triggerScenarios":"CImg::save_dlm() (or save() with a .dlm filename) on an image with _spectrum > 1, such as an RGB image loaded from PNG/JPEG or a multi-channel feature image.","commonSituations":"Exporting RGB images to DLM for spreadsheet/numeric tools; forgetting DLM is single-channel; save() dispatching on a .dlm extension on color images.","solutions":["Split channels first and save each one: img.get_channel(c).save_dlm(...).","Use a format supporting multispectral data (save_cimg, save_pnm for RGB, save_tiff).","Convert to grayscale (get_norm or channel 0) if a single-channel export is intended.","If unrolled layout is acceptable, document/parse the row-major (x, then y, then c) ordering explicitly on the consumer side."],"exampleFix":"// before\nrgb.save_dlm(\"rgb.dlm\");\n// after\nfor (int c = 0; c < rgb.spectrum(); ++c)\n  rgb.get_channel(c).save_dlm(cimg::format(\"rgb_c%d.dlm\", c));","handlingStrategy":"validation","validationCode":"if (img.spectrum() > 1) splitAndSaveChannels(img, base);\nelse img.save_dlm(path);","typeGuard":"bool isSingleChannel(const CImg<T>& im) { return im.spectrum() == 1; }","tryCatchPattern":null,"preventionTips":["Remember DLM is a 2D single-channel format.","Check spectrum before choosing export format.","Use get_channel/get_channels to make channel selection explicit."],"tags":["dlm","saving","multispectral","data-loss"],"backgroundTag":"unsupported-operation","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}