VTK  9.1.0
vtkHDRReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHDRReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
72 #ifndef vtkHDRReader_h
73 #define vtkHDRReader_h
74 
75 #include "vtkIOImageModule.h" // For export macro
76 #include "vtkImageReader.h"
77 #include <string> // for std::string
78 #include <vector> // for std::vector
79 
80 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
81 {
82 public:
83  static vtkHDRReader* New();
84  vtkTypeMacro(vtkHDRReader, vtkImageReader);
85 
86  void PrintSelf(ostream& os, vtkIndent indent) override;
87 
89  {
90  FORMAT_32BIT_RLE_RGBE = 0,
91  FORMAT_32BIT_RLE_XYZE
92  };
93 
95 
98  vtkGetMacro(Format, int);
100 
102 
106  vtkGetMacro(Gamma, double);
108 
110 
114  vtkGetMacro(Exposure, double);
116 
118 
122  vtkGetMacro(PixelAspect, double);
124 
128  int CanReadFile(VTK_FILEPATH const char* fname) override;
129 
135  const char* GetFileExtensions() override { return ".hdr .pic"; }
136 
140  const char* GetDescriptiveName() override { return "Radiance HDR"; }
141 
142 protected:
144  ~vtkHDRReader() override;
145 
148  double Gamma;
149  double Exposure;
150  double PixelAspect;
151 
155  bool FlippedX = false;
156 
160  bool SwappedAxis = false;
161 
162  void ExecuteInformation() override;
164  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
165  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
166 
171  bool HasError(istream* is);
172 
173  int GetWidth() const;
174  int GetHeight() const;
175 
181 
182  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
183 
184  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
185  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
186 
191  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
192 
197  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
198 
202  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
203 
209  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
210 
211 private:
212  vtkHDRReader(const vtkHDRReader&) = delete;
213  void operator=(const vtkHDRReader&) = delete;
214 };
215 #endif
vtkImageReader
Superclass of transformable binary file readers.
Definition: vtkImageReader.h:58
vtkHDRReader::New
static vtkHDRReader * New()
vtkHDRReader::ReadLineRLE
bool ReadLineRLE(istream *is, unsigned char *lineBufferPtr)
Read a line of the file from is into lineBuffer with RLE encoding.
vtkHDRReader::HDRReaderUpdateSlice
bool HDRReaderUpdateSlice(float *outPtr, int *outExt)
VTK_FILEPATH
#define VTK_FILEPATH
Definition: vtkWrappingHints.h:46
vtkHDRReader::RGBE2Float
void RGBE2Float(unsigned char rgbe[4], float &r, float &g, float &b)
Standard conversion from rgbe to float pixels.
vtkHDRReader::CanReadFile
int CanReadFile(VTK_FILEPATH const char *fname) override
Is the given file a HDR file?
vtkHDRReader::FillOutPtrRLE
void FillOutPtrRLE(int *outExt, float *&outPtr, std::vector< unsigned char > &lineBuffer)
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkHDRReader::vtkHDRReader
vtkHDRReader()
vtkHDRReader::GetWidth
int GetWidth() const
vtkHDRReader::HasError
bool HasError(istream *is)
If the stream has an error, close the file and return true.
vtkHDRReader::ConvertAllDataFromRGBToXYZ
void ConvertAllDataFromRGBToXYZ(float *outPtr, int size)
vtkHDRReader::Gamma
double Gamma
Definition: vtkHDRReader.h:148
vtkHDRReader::Exposure
double Exposure
Definition: vtkHDRReader.h:149
vtkHDRReader::HDRReaderUpdate
void HDRReaderUpdate(vtkImageData *data, float *outPtr)
vtkHDRReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkHDRReader::ReadHeaderData
bool ReadHeaderData()
Read the header data and fill attributes of HDRReader, as well as DataExtent.
vtkHDRReader::ReadAllFileNoRLE
bool ReadAllFileNoRLE(istream *is, float *outPtr, int decrPtr, int *outExt)
Read the file from is into outPtr with no RLE encoding.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkHDRReader::GetDescriptiveName
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:140
vtkHDRReader::~vtkHDRReader
~vtkHDRReader() override
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkHDRReader::FormatType
FormatType
Definition: vtkHDRReader.h:89
vtkHDRReader::Format
FormatType Format
Definition: vtkHDRReader.h:147
vtkHDRReader::GetFileExtensions
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:135
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkHDRReader::ProgramType
std::string ProgramType
Definition: vtkHDRReader.h:146
vtkHDRReader::XYZ2RGB
static void XYZ2RGB(const float convertMatrix[3][3], float &r, float &g, float &b)
Conversion from xyz to rgb float using the 3x3 convert matrix.
vtkHDRReader::ExecuteInformation
void ExecuteInformation() override
vtkHDRReader::FillOutPtrNoRLE
void FillOutPtrNoRLE(int *outExt, float *&outPtr, std::vector< unsigned char > &lineBuffer)
vtkHDRReader::PixelAspect
double PixelAspect
Definition: vtkHDRReader.h:150
vtkHDRReader::GetHeight
int GetHeight() const
vtkImageReader.h
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkHDRReader::ExecuteDataWithInformation
void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
vtkHDRReader
read Radiance HDR files
Definition: vtkHDRReader.h:81