1 /*========================================================================= 2 * 3 * Copyright Insight Software Consortium 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0.txt 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *=========================================================================*/ 18 #ifndef itkJPEGImageIO_h 19 #define itkJPEGImageIO_h 20 #include "ITKIOJPEGExport.h" 21 22 23 #include "itkImageIOBase.h" 24 25 namespace itk 26 { 27 /** \class JPEGImageIO 28 * 29 * \brief ImageIO object for reading and writing JPEG images 30 * 31 * Compression is supported with only the default compressor. The 32 * compression level option is supported in the range 0-100. 33 * 34 * \ingroup IOFilters 35 * 36 * \ingroup ITKIOJPEG 37 */ 38 class ITKIOJPEG_EXPORT JPEGImageIO:public ImageIOBase 39 { 40 public: 41 ITK_DISALLOW_COPY_AND_ASSIGN(JPEGImageIO); 42 43 /** Standard class type aliases. */ 44 using Self = JPEGImageIO; 45 using Superclass = ImageIOBase; 46 using Pointer = SmartPointer< Self >; 47 48 /** Method for creation through the object factory. */ 49 itkNewMacro(Self); 50 51 /** Run-time type information (and related methods). */ 52 itkTypeMacro(JPEGImageIO, ImageIOBase); 53 54 /** Set/Get the level of quality for the output images. */ SetQuality(int _JPEGQuality)55 virtual void SetQuality(int _JPEGQuality) { this->SetCompressionLevel(_JPEGQuality); } GetQuality()56 virtual int GetQuality() const { return this->GetCompressionLevel(); } 57 58 /** */ 59 itkSetMacro(Progressive, bool); 60 itkGetConstMacro(Progressive, bool); 61 62 /*-------- This part of the interface deals with reading data. ------ */ 63 64 /** Determine the file type. Returns true if this ImageIO can read the 65 * file specified. */ 66 bool CanReadFile(const char *) override; 67 68 /** Set the spacing and diemention information for the set filename. */ 69 void ReadImageInformation() override; 70 71 /** Reads the data from disk into the memory buffer provided. */ 72 void Read(void *buffer) override; 73 74 /** Reads 3D data from multiple files assuming one slice per file. */ 75 virtual void ReadVolume(void *buffer); 76 77 /*-------- This part of the interfaces deals with writing data. ----- */ 78 79 /** Determine the file type. Returns true if this ImageIO can read the 80 * file specified. */ 81 bool CanWriteFile(const char *) override; 82 83 /** Writes the spacing and dimensions of the image. 84 * Assumes SetFileName has been called with a valid file name. */ 85 void WriteImageInformation() override; 86 87 /** Writes the data to disk from the memory buffer provided. Make sure 88 * that the IORegion has been set properly. */ 89 void Write(const void *buffer) override; 90 91 protected: 92 JPEGImageIO(); 93 ~JPEGImageIO() override; 94 void PrintSelf(std::ostream & os, Indent indent) const override; 95 96 void WriteSlice(std::string & fileName, const void *buffer); 97 98 /** Default = true*/ 99 bool m_Progressive; 100 }; 101 } // end namespace itk 102 103 #endif // itkJPEGImageIO_h 104