Skip to content

Commit

Permalink
Fix corrupted raw nrrd file output on Windows
Browse files Browse the repository at this point in the history
On Windows, when NRRD file was written into .nrrd format with raw pixels then the image was corrupted.

The root cause was that the file was opened in text mode and therefore each 0a byte was converted to 0d0a resulting in an incorrect byte stream.
  • Loading branch information
lassoan authored Jul 31, 2024
1 parent 7d62584 commit fe4021d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4452,7 +4452,7 @@ int nii_saveNRRD(char *niiFilename, struct nifti_1_header hdr, unsigned char *im
strcat(fname, ".nhdr"); //nrrd or nhdr
else
strcat(fname, ".nrrd"); //nrrd or nhdr
FILE *fp = fopen(fname, "w");
FILE *fp = fopen(fname, "wb");
fprintf(fp, "NRRD0005\n");
fprintf(fp, "# Complete NRRD file format specification at:\n");
fprintf(fp, "# http://teem.sourceforge.net/nrrd/format.html\n");
Expand Down

0 comments on commit fe4021d

Please sign in to comment.