18 #ifndef itkImageFileWriter_h
19 #define itkImageFileWriter_h
20 #include "ITKIOImageBaseExport.h"
45 const char * message =
"Error in IO",
46 const char * loc =
"Unknown")
53 const char * message =
"Error in IO",
54 const char * loc =
"Unknown")
89 template <typename TInputImage>
114 using Superclass::SetInput;
122 GetInput(
unsigned int idx);
125 itkSetStringMacro(FileName);
126 itkGetStringMacro(FileName);
142 if (this->m_ImageIO != io)
145 this->m_ImageIO = io;
147 m_FactorySpecifiedImageIO =
false;
170 return m_PasteIORegion;
175 itkSetMacro(NumberOfStreamDivisions,
unsigned int);
176 itkGetConstReferenceMacro(NumberOfStreamDivisions,
unsigned int);
195 m_PasteIORegion =
ImageIORegion(TInputImage::ImageDimension);
196 m_UserSpecifiedIORegion =
false;
201 itkSetMacro(UseCompression,
bool);
202 itkGetConstReferenceMacro(UseCompression,
bool);
203 itkBooleanMacro(UseCompression);
208 itkSetMacro(CompressionLevel,
int);
209 itkGetConstReferenceMacro(CompressionLevel,
int);
218 itkSetMacro(UseInputMetaDataDictionary,
bool);
219 itkGetConstReferenceMacro(UseInputMetaDataDictionary,
bool);
220 itkBooleanMacro(UseInputMetaDataDictionary);
227 PrintSelf(std::ostream & os,
Indent indent)
const override;
231 GenerateData()
override;
234 std::string m_FileName{};
237 bool m_UserSpecifiedImageIO{
false };
240 unsigned int m_NumberOfStreamDivisions{ 1 };
241 bool m_UserSpecifiedIORegion{
false };
243 bool m_FactorySpecifiedImageIO{
false };
244 bool m_UseCompression{
false };
245 int m_CompressionLevel{ -1 };
246 bool m_UseInputMetaDataDictionary{
true };
254 template <
typename TImagePo
inter>
255 ITK_TEMPLATE_EXPORT
void
256 WriteImage(TImagePointer && image,
const std::string & filename,
bool compress =
false)
258 using NonReferenceImagePointer = std::remove_reference_t<TImagePointer>;
259 static_assert(std::is_pointer_v<NonReferenceImagePointer> || mpl::IsSmartPointer<NonReferenceImagePointer>::Value,
260 "WriteImage requires a raw pointer or SmartPointer.");
263 using ImageType = std::remove_const_t<std::remove_reference_t<decltype(*image)>>;
265 writer->SetInput(image);
266 writer->SetFileName(filename);
267 writer->SetUseCompression(compress);
273 #ifndef ITK_MANUAL_INSTANTIATION
274 # include "itkImageFileWriter.hxx"
277 #if defined ITK_IMAGEIO_FACTORY_REGISTER_MANAGER || defined ITK_IO_FACTORY_REGISTER_MANAGER
278 # include "itkImageIOFactoryRegisterManager.h"
281 #endif // itkImageFileWriter_h