VTK  9.3.0
vtkHDRReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
23 #ifndef vtkHDRReader_h
24 #define vtkHDRReader_h
25 
26 #include "vtkIOImageModule.h" // For export macro
27 #include "vtkImageReader.h"
28 #include <string> // for std::string
29 #include <vector> // for std::vector
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
33 {
34 public:
35  static vtkHDRReader* New();
36  vtkTypeMacro(vtkHDRReader, vtkImageReader);
37 
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
41  {
42  FORMAT_32BIT_RLE_RGBE = 0,
43  FORMAT_32BIT_RLE_XYZE
44  };
45 
47 
50  vtkGetMacro(Format, int);
52 
54 
58  vtkGetMacro(Gamma, double);
60 
62 
66  vtkGetMacro(Exposure, double);
68 
70 
74  vtkGetMacro(PixelAspect, double);
76 
80  int CanReadFile(VTK_FILEPATH const char* fname) override;
81 
87  const char* GetFileExtensions() override { return ".hdr .pic"; }
88 
92  const char* GetDescriptiveName() override { return "Radiance HDR"; }
93 
94 protected:
96  ~vtkHDRReader() override;
97 
100  double Gamma;
101  double Exposure;
102  double PixelAspect;
103 
107  bool FlippedX = false;
108 
112  bool SwappedAxis = false;
113 
114  void ExecuteInformation() override;
116  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
117  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
118 
123  bool HasError(istream* is);
124 
125  int GetWidth() const;
126  int GetHeight() const;
127 
133 
134  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
135 
136  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
137  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
138 
143  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
144 
149  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
150 
154  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
155 
161  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
162 
163 private:
164  vtkHDRReader(const vtkHDRReader&) = delete;
165  void operator=(const vtkHDRReader&) = delete;
166 };
167 VTK_ABI_NAMESPACE_END
168 #endif
general representation of visualization data
Definition: vtkDataObject.h:64
read Radiance HDR files
Definition: vtkHDRReader.h:33
int CanReadFile(VTK_FILEPATH const char *fname) override
Is the given file a HDR file?
FormatType Format
Definition: vtkHDRReader.h:99
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:92
~vtkHDRReader() override
void FillOutPtrNoRLE(int *outExt, float *&outPtr, std::vector< unsigned char > &lineBuffer)
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.
void FillOutPtrRLE(int *outExt, float *&outPtr, std::vector< unsigned char > &lineBuffer)
void ConvertAllDataFromRGBToXYZ(float *outPtr, int size)
double PixelAspect
Definition: vtkHDRReader.h:102
void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
bool ReadLineRLE(istream *is, unsigned char *lineBufferPtr)
Read a line of the file from is into lineBuffer with RLE encoding.
bool ReadAllFileNoRLE(istream *is, float *outPtr, int decrPtr, int *outExt)
Read the file from is into outPtr with no RLE encoding.
bool HDRReaderUpdateSlice(float *outPtr, int *outExt)
static vtkHDRReader * New()
void RGBE2Float(unsigned char rgbe[4], float &r, float &g, float &b)
Standard conversion from rgbe to float pixels.
void HDRReaderUpdate(vtkImageData *data, float *outPtr)
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:87
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetWidth() const
void ExecuteInformation() override
bool ReadHeaderData()
Read the header data and fill attributes of HDRReader, as well as DataExtent.
int GetHeight() const
std::string ProgramType
Definition: vtkHDRReader.h:98
double Exposure
Definition: vtkHDRReader.h:101
bool HasError(istream *is)
If the stream has an error, close the file and return true.
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
Superclass of transformable binary file readers.
a simple class to control print indentation
Definition: vtkIndent.h:38
Store vtkAlgorithm input/output information.
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH