-// Write Image Information
-void clitk::HisImageIO::WriteImageInformation(bool keepOfStream)
-{
- std::ofstream file(m_FileName.c_str(), std::ios::out | std::ios::binary);
- if ( file.fail() )
- itkGenericExceptionMacro(<< "Could not open file (for writing): " << m_FileName);
-
- m_HeaderSize = HEADER_INFO_SIZE + 32;\r
- char szHeader[HEADER_INFO_SIZE + 32] = {\r
- 0x00, 0x70, 0x44, 0x00, 0x64, 0x00, 0x64, 0x00, 0x20, 0x00, 0x20, 0x00, 0x01, 0x00, 0x01, 0x00,\r
- 0x00, 0x04, 0x00, 0x04, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6A, 0x18, 0x41,\r
- 0x04, 0x00, 0x40, 0x5F, 0x48, 0x01, 0x40, 0x00, 0x86, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,\r
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x63, 0x13, 0x00, 0xE8, 0x51, 0x13, 0x00, 0x5C, 0xE7, 0x12, 0x00,\r
- 0xFE, 0x2A, 0x49, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
- 0x00, 0x00, 0x00, 0x00};\r
-\r
- /* Fill into the header the essentials\r
- The 'iheader' in previous module is fixed to 0x20, and is included in szHeader.\r
- The 'ulx' and 'uly' are fixed to 0x01, so that 'brx' and 'bry' reflect the dimensions of\r
- the image.\r
- */\r
- const unsigned int ndim = GetNumberOfDimensions();\r
- if ((ndim < 2) || (ndim > 3))\r
- itkExceptionMacro( <<"Only 2D or 3D support");\r
-\r
- szHeader[16] = (char)(GetDimensions(0) % 256); // X-size lsb\r
- szHeader[17] = (char)(GetDimensions(0) / 256); // X-size msb\r
- szHeader[18] = (char)(GetDimensions(1) % 256); // Y-size lsb\r
- szHeader[19] = (char)(GetDimensions(1) / 256); // Y-size msb\r
- if (ndim == 3)\r
- { szHeader[20] = (char)(GetDimensions(0) % 256); // NbFrames lsb\r
- szHeader[21] = (char)(GetDimensions(0) / 256); // NbFrames msb\r
- }\r
-\r
- switch (GetComponentType())\r
- { case itk::ImageIOBase::USHORT:\r
- szHeader[32] = 4;\r
- break;\r
- //case AVS_TYPE_INTEGER:\r
- // szHeader[32] = 8;\r
- // break;\r
- //case AVS_TYPE_REAL:\r
- // szHeader[32] = 16;\r
- // break;\r
- default:\r
- itkExceptionMacro(<< "Unsupported field type");\r
- break;\r
- }\r
- file.write(szHeader, m_HeaderSize);\r
- file.close();\r
-}
-
-//--------------------------------------------------------------------
-// Write Image Information