18 #ifndef itkImageFileWriter_h
19 #define itkImageFileWriter_h
20 #include "ITKIOImageBaseExport.h"
43 const char * message =
"Error in IO",
44 const char * loc =
"Unknown")
45 : ExceptionObject(file, line, message, loc)
51 const char * message =
"Error in IO",
52 const char * loc =
"Unknown")
53 : ExceptionObject(file, line, message, loc)
87 template <typename TInputImage>
112 using Superclass::SetInput;
120 GetInput(
unsigned int idx);
123 itkSetStringMacro(FileName);
124 itkGetStringMacro(FileName);
140 if (this->m_ImageIO != io)
143 this->m_ImageIO = io;
145 m_FactorySpecifiedImageIO =
false;
168 return m_PasteIORegion;
173 itkSetMacro(NumberOfStreamDivisions,
unsigned int);
174 itkGetConstReferenceMacro(NumberOfStreamDivisions,
unsigned int);
193 m_PasteIORegion =
ImageIORegion(TInputImage::ImageDimension);
194 m_UserSpecifiedIORegion =
false;
199 itkSetMacro(UseCompression,
bool);
200 itkGetConstReferenceMacro(UseCompression,
bool);
201 itkBooleanMacro(UseCompression);
206 itkSetMacro(CompressionLevel,
int);
207 itkGetConstReferenceMacro(CompressionLevel,
int);
216 itkSetMacro(UseInputMetaDataDictionary,
bool);
217 itkGetConstReferenceMacro(UseInputMetaDataDictionary,
bool);
218 itkBooleanMacro(UseInputMetaDataDictionary);
225 PrintSelf(std::ostream & os,
Indent indent)
const override;
229 GenerateData()
override;
235 bool m_UserSpecifiedImageIO{
false };
238 unsigned int m_NumberOfStreamDivisions{ 1 };
239 bool m_UserSpecifiedIORegion{
false };
241 bool m_FactorySpecifiedImageIO{
false };
242 bool m_UseCompression{
false };
243 int m_CompressionLevel{ -1 };
244 bool m_UseInputMetaDataDictionary{
true };
252 template <
typename TImagePo
inter>
253 ITK_TEMPLATE_EXPORT
void
254 WriteImage(TImagePointer && image,
const std::string & filename,
bool compress =
false)
256 using NonReferenceImagePointer =
typename std::remove_reference<TImagePointer>::type;
257 static_assert(std::is_pointer<NonReferenceImagePointer>::value ||
258 mpl::IsSmartPointer<NonReferenceImagePointer>::Value,
259 "WriteImage requires a raw pointer or SmartPointer.");
262 using ImageType =
typename std::remove_const<
typename std::remove_reference<decltype(*image)>::type>::type;
264 writer->SetInput(image);
265 writer->SetFileName(filename);
266 writer->SetUseCompression(compress);
272 #ifndef ITK_MANUAL_INSTANTIATION
273 # include "itkImageFileWriter.hxx"
276 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
277 # include "itkImageIOFactoryRegisterManager.h"
280 #endif // itkImageFileWriter_h