{"record":{"id":"a9faf49b55ad09d1","repo":"Yalantis/uCrop","slug":"save-dlm-instance-is-volumetric-values-along-z","errorCode":null,"errorMessage":"save_dlm(): Instance is volumetric, values along Z will be unrolled in file '%s'.","messagePattern":"save_dlm\\(\\): Instance is volumetric, values along Z will be unrolled in file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":61456,"sourceCode":"       \\param filename Filename, as a C-string.\n    **/\n    const CImg<T>& save_dlm(const char *const filename) const {\n      return _save_dlm(0,filename);\n    }\n\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    }","sourceCodeStart":61438,"sourceCodeEnd":61474,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L61438-L61474","documentation":"save_dlm() writes a 2D table of values to a delimited (DLM) text file, which cannot represent a 3D volume. When the image has _depth>1, the library warns that Z values will be unrolled (flattened into rows) and continues, producing a file whose layout does not preserve the volume structure.","triggerScenarios":"Calling CImg::save_dlm() (or save(\"file.dlm\")) on an image where _depth > 1, i.e. a volumetric image created e.g. via load_cimg, volume data, or 3D crops.","commonSituations":"Saving 3D medical/volume data to DLM by accident due to wrong extension dispatch (save() choosing DLM from filename); exporting intermediate results of 3D processing; format chosen for portability without checking dimensionality.","solutions":["Save volumetric data in a format that supports 3D: save_cimg(), save_analyze(), or save_tiff (multi-page).","Explicitly extract a 2D slice before DLM export: img.get_slice(z).save_dlm(filename).","Loop over z and save one DLM file per slice.","Avoid generic save() with a .dlm extension on 3D images; name the format deliberately."],"exampleFix":"// before\nvolume.save_dlm(\"out.dlm\"); // 3D data flattened\n// after\nfor (int z = 0; z < volume.depth(); ++z)\n  volume.get_slice(z).save_dlm(cimg::format(\"out_z%06d.dlm\", z));","handlingStrategy":"validation","validationCode":"if (img.depth() > 1) throw std::logic_error(\"save_dlm requires 2D image; use get_slice or another format\");\nimg.save_dlm(path);","typeGuard":"bool is2D(const CImg<T>& im) { return im.depth() == 1; }","tryCatchPattern":null,"preventionTips":["Check image dimensions before format-dispatching saves.","Use save_cimg/save_tiff for volumetric data.","Avoid generic save() with data-format extensions on 3D images."],"tags":["dlm","saving","volume","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"}