Skip to content

Commit

Permalink
BUG: MRC write full machine stamp
Browse files Browse the repository at this point in the history
The MRC2014 specification updated/clarifed the spec that the first two
bytes should contain the specified value to determine endian. This
appears to be enforced with Python mrcfile. This patch enables
compatibility.
  • Loading branch information
blowekamp committed Apr 21, 2023
1 parent e7ffba6 commit 8ca5d1f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Modules/IO/MRC/include/itkMRCHeaderObject.h
Expand Up @@ -164,8 +164,8 @@ class ITKIOMRC_EXPORT MRCHeaderObject : public LightObject
float zorg;

char cmap[4]; /**< Contains "MAP " */
char stamp[4]; /**< First byte has 17 for big- or 68 for
little-endian */
char stamp[4]; /**< First two bytes have 17 and 17 for big-endian or
68 and 68 for little-endian */
float rms;

// ALL HEADERS:
Expand Down
2 changes: 2 additions & 0 deletions Modules/IO/MRC/src/itkMRCImageIO.cxx
Expand Up @@ -358,10 +358,12 @@ MRCImageIO::UpdateHeaderFromImageIO()
if (ByteSwapper<void *>::SystemIsBigEndian())
{
header.stamp[0] = 17;
header.stamp[1] = 17;
}
else
{
header.stamp[0] = 68;
header.stamp[1] = 68;
}

header.alpha = 90;
Expand Down
3 changes: 3 additions & 0 deletions Modules/IO/MRC/test/itkMRCImageIOTest2.cxx
Expand Up @@ -24,6 +24,9 @@
#include "itkMetaDataObject.h"
#include "itkTestingHashImageFilter.h"


static_assert(sizeof(itk::MRCHeaderObject::Header) == 1024, " Ill defined MRC Header struct");

namespace
{

Expand Down

0 comments on commit 8ca5d1f

Please sign in to comment.