18 #ifndef itkImageIOBase_h
19 #define itkImageIOBase_h
20 #include "ITKIOImageBaseExport.h"
22 #include "itkIOConfigure.h"
35 #include "vnl/vnl_vector.h"
36 #include "vcl_compiler.h"
44 template <
typename TValue>
45 class VariableLengthVector;
90 itkSetStringMacro(FileName);
91 itkGetStringMacro(FileName);
106 #if !defined(ITK_LEGACY_REMOVE)
125 #if !defined(ITK_LEGACY_REMOVE)
144 #if !defined(ITK_LEGACY_REMOVE)
152 #if !defined(ITK_LEGACY_REMOVE)
164 SetNumberOfDimensions(
unsigned int);
166 itkGetConstMacro(NumberOfDimensions,
unsigned int);
178 return m_Dimensions[i];
184 SetOrigin(
unsigned int i,
double origin);
195 SetSpacing(
unsigned int i,
double spacing);
206 SetDirection(
unsigned int i,
const std::vector<double> & direction);
209 SetDirection(
unsigned int i,
const vnl_vector<double> & direction);
211 virtual std::vector<double>
214 return m_Direction[i];
219 virtual std::vector<double>
220 GetDefaultDirection(
unsigned int i)
const;
251 virtual const std::type_info &
252 GetComponentTypeInfo()
const;
258 itkSetMacro(NumberOfComponents,
unsigned int);
259 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
263 itkSetMacro(UseCompression,
bool);
264 itkGetConstMacro(UseCompression,
bool);
265 itkBooleanMacro(UseCompression);
274 itkSetClampMacro(CompressionLevel,
int, 1, this->GetMaximumCompressionLevel());
275 itkGetConstMacro(CompressionLevel,
int);
288 SetCompressor(std::string _c);
289 itkGetConstReferenceMacro(Compressor, std::string);
292 itkSetMacro(UseStreamedReading,
bool);
293 itkGetConstMacro(UseStreamedReading,
bool);
294 itkBooleanMacro(UseStreamedReading);
298 itkSetMacro(UseStreamedWriting,
bool);
299 itkGetConstMacro(UseStreamedWriting,
bool);
300 itkBooleanMacro(UseStreamedWriting);
307 itkSetMacro(ExpandRGBPalette,
bool);
308 itkGetConstMacro(ExpandRGBPalette,
bool);
309 itkBooleanMacro(ExpandRGBPalette);
314 itkSetMacro(WritePalette,
bool);
315 itkGetConstMacro(WritePalette,
bool);
316 itkBooleanMacro(WritePalette);
323 itkGetConstMacro(IsReadAsScalarPlusPalette,
bool);
331 GetComponentTypeFromString(
const std::string & typeString);
335 static std::string GetPixelTypeAsString(
IOPixelEnum);
339 GetPixelTypeFromString(
const std::string & pixelString);
386 std::string GetFileTypeAsString(
IOFileEnum)
const;
406 GetPixelStride()
const;
410 GetImageSizeInPixels()
const;
414 GetImageSizeInBytes()
const;
419 GetImageSizeInComponents()
const;
426 GetComponentSize()
const;
433 CanReadFile(
const char *) = 0;
448 ReadImageInformation() = 0;
452 Read(
void * buffer) = 0;
459 CanWriteFile(
const char *) = 0;
476 WriteImageInformation() = 0;
482 Write(
const void * buffer) = 0;
509 GenerateStreamableReadRegionFromRequestedRegion(
const ImageIORegion & requested)
const;
526 GetActualNumberOfSplitsForWriting(
unsigned int numberOfRequestedSplits,
537 GetSplitRegionForWriting(
unsigned int ithPiece,
538 unsigned int numberOfActualSplits,
550 GetSupportedReadExtensions()
const;
557 GetSupportedWriteExtensions()
const;
559 template <
typename TPixel>
561 SetTypeInfo(
const TPixel *);
564 template <
typename TPixel>
569 template <
typename TPixel>
573 this->SetNumberOfComponents(1);
577 template <
typename TPixel>
581 this->SetNumberOfComponents(3);
585 template <
typename TPixel>
589 this->SetNumberOfComponents(4);
593 template <
typename TPixel,
unsigned VLength>
597 this->SetNumberOfComponents(VLength);
601 template <
typename TPixel>
605 this->SetNumberOfComponents(1);
609 template <
typename TPixel,
unsigned VLength>
613 this->SetNumberOfComponents(VLength);
617 template <
typename TPixel,
unsigned VLength>
621 this->SetNumberOfComponents(VLength);
627 template <
typename TPixel,
unsigned VLength>
631 this->SetNumberOfComponents(VLength * (VLength + 1) / 2);
636 template <
typename TPixel>
640 this->SetNumberOfComponents(6);
645 template <
typename TPixel,
unsigned VLength>
649 this->SetNumberOfComponents(VLength * VLength);
654 template <
typename TPixel>
658 this->SetNumberOfComponents(2);
663 template <
unsigned VLength>
667 this->SetNumberOfComponents(VLength);
676 PrintSelf(std::ostream & os,
Indent indent)
const override;
679 GetImageRegionSplitter()
const;
686 HasSupportedReadExtension(
const char *
fileName,
bool ignoreCase =
true);
688 HasSupportedWriteExtension(
const char *
fileName,
bool ignoreCase =
true);
714 unsigned int m_NumberOfDimensions{ 0 };
717 bool m_UseCompression{
false };
720 int m_CompressionLevel{ 30 };
721 int m_MaximumCompressionLevel{ 100 };
722 std::string m_Compressor{
"uninitialized" };
726 SetMaximumCompressionLevel(
int);
727 itkGetConstMacro(MaximumCompressionLevel,
int);
734 InternalSetCompressor(
const std::string & COMPRESSOR);
775 Reset(
const bool freeDynamic =
true);
779 Resize(
const unsigned int numDimensions,
const unsigned int * dimensions);
784 GetPixelSize()
const;
798 GetComponentStride()
const;
803 GetRowStride()
const;
808 GetSliceStride()
const;
822 OpenFileForReading(std::ifstream & inputStream,
const std::string & filename,
bool ascii =
false);
840 OpenFileForWriting(std::ofstream & outputStream,
841 const std::string & filename,
842 bool truncate =
true,
847 WriteBufferAsASCII(std::ostream & os,
const void * buffer,
IOComponentEnum ctype,
SizeType numberOfBytesToWrite);
855 ReadBufferAsBinary(std::istream & os,
void * buffer,
SizeType numberOfBytesToBeRead);
859 AddSupportedReadExtension(
const char * extension);
863 AddSupportedWriteExtension(
const char * extension);
874 GetActualNumberOfSplitsForWritingCanStreamWrite(
unsigned int numberOfRequestedSplits,
880 GetSplitRegionForWritingCanStreamWrite(
unsigned int ithPiece,
881 unsigned int numberOfActualSplits,
893 extern ITKIOImageBase_EXPORT
void
896 std::ofstream & file,
902 extern ITKIOImageBase_EXPORT
void
908 #define IMAGEIOBASE_TYPEMAP(type, ctype) \
910 struct ImageIOBase::MapPixelType<type> \
912 static constexpr IOComponentEnum CType = ctype; \
929 #undef IMAGIOBASE_TYPEMAP
933 #endif // itkImageIOBase_h