diff --git a/Modules/IO/GDCM/src/itkGDCMImageIO.cxx b/Modules/IO/GDCM/src/itkGDCMImageIO.cxx index 0ea22e8583c..344121f6d52 100644 --- a/Modules/IO/GDCM/src/itkGDCMImageIO.cxx +++ b/Modules/IO/GDCM/src/itkGDCMImageIO.cxx @@ -1022,7 +1022,11 @@ GDCMImageIO::Write(const void * buffer) if (hasIPP) { double origin3D[3]; + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(tempString.c_str(), "%lf\\%lf\\%lf", &(origin3D[0]), &(origin3D[1]), &(origin3D[2])); + // reset locale + std::locale::global(currentLocale); image.SetOrigin(0, origin3D[0]); image.SetOrigin(1, origin3D[1]); image.SetOrigin(2, origin3D[2]); @@ -1053,6 +1057,8 @@ GDCMImageIO::Write(const void * buffer) if (hasIOP) { double directions[6]; + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(tempString.c_str(), "%lf\\%lf\\%lf\\%lf\\%lf\\%lf", &(directions[0]), @@ -1061,6 +1067,8 @@ GDCMImageIO::Write(const void * buffer) &(directions[3]), &(directions[4]), &(directions[5])); + // reset locale + std::locale::global(currentLocale); image.SetDirectionCosines(0, directions[0]); image.SetDirectionCosines(1, directions[1]); image.SetDirectionCosines(2, directions[2]); diff --git a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx index 0e6da22f9b7..332a293930c 100644 --- a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx +++ b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx @@ -256,7 +256,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // the origin is not specified, but the fov is, then the image is assumed // to be centered: + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f %f %f", origin, origin + 1, origin + 2, origin + 3); + // reset locale + std::locale::global(currentLocale); for (unsigned int i = 0; i < m_NumberOfDimensions; i++) { m_Origin[i] = origin[i]; @@ -277,7 +281,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // not // specified it is calculated according to: fov = interval * dim + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f %f %f", fov, fov + 1, fov + 2, fov + 3); + // reset locale + std::locale::global(currentLocale); fov_specified = true; } else if (text.find("interval") < text.length()) @@ -288,7 +296,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // one value for each dimension. If the interval is not specified it is // calculated according to: interval = fov / dim + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f %f %f", spacing, spacing + 1, spacing + 2, spacing + 3); + // reset locale + std::locale::global(currentLocale); for (unsigned int i = 0; i < m_NumberOfDimensions; i++) { m_Spacing[i] = spacing[i]; @@ -337,7 +349,11 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // the // low_value and high_value. + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f", range, range + 1); + // reset locale + std::locale::global(currentLocale); m_DisplayRange[0] = range[0]; m_DisplayRange[1] = range[1]; } diff --git a/Modules/IO/VTK/src/itkVTKImageIO.cxx b/Modules/IO/VTK/src/itkVTKImageIO.cxx index ee66ead9d96..15c1753e2e4 100644 --- a/Modules/IO/VTK/src/itkVTKImageIO.cxx +++ b/Modules/IO/VTK/src/itkVTKImageIO.cxx @@ -237,7 +237,11 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file) if (text.find("spacing") < text.length() || text.find("aspect_ratio") < text.length()) { double spacing[3]; + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(text.c_str(), "%*s %lf %lf %lf", spacing, spacing + 1, spacing + 2); + // reset locale + std::locale::global(currentLocale); for (unsigned int i = 0; i < m_NumberOfDimensions; i++) { this->SetSpacing(i, spacing[i]); @@ -247,7 +251,11 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file) else if (text.find("origin") < text.length()) { double origin[3]; + // save and reset old locale + std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(text.c_str(), "%*s %lf %lf %lf", origin, origin + 1, origin + 2); + // reset locale + std::locale::global(currentLocale); for (unsigned int i = 0; i < m_NumberOfDimensions; i++) { this->SetOrigin(i, origin[i]);