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
14 #ifndef vtkHDRReader_h
15 #define vtkHDRReader_h
16 
17 #include "vtkIOImageModule.h" // For export macro
18 #include "vtkImageReader.h"
19 #include <string> // for std::string
20 #include <vector> // for std::vector
21 
22 VTK_ABI_NAMESPACE_BEGIN
23 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
24 {
25 public:
26  static vtkHDRReader* New();
27  vtkTypeMacro(vtkHDRReader, vtkImageReader);
28 
29  void PrintSelf(ostream& os, vtkIndent indent) override;
30 
32  {
33  FORMAT_32BIT_RLE_RGBE = 0,
34  FORMAT_32BIT_RLE_XYZE
35  };
36 
38 
41  vtkGetMacro(Format, int);
43 
45 
49  vtkGetMacro(Gamma, double);
51 
53 
57  vtkGetMacro(Exposure, double);
59 
61 
65  vtkGetMacro(PixelAspect, double);
67 
71  int CanReadFile(VTK_FILEPATH const char* fname) override;
72 
78  const char* GetFileExtensions() override { return ".hdr .pic"; }
79 
83  const char* GetDescriptiveName() override { return "Radiance HDR"; }
84 
85 protected:
87  ~vtkHDRReader() override;
88 
91  double Gamma;
92  double Exposure;
93  double PixelAspect;
94 
98  bool FlippedX = false;
99 
103  bool SwappedAxis = false;
104 
105  void ExecuteInformation() override;
107  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
108  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
109 
114  bool HasError(istream* is);
115 
116  int GetWidth() const;
117  int GetHeight() const;
118 
124 
125  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
126 
127  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
128  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
129 
134  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
135 
140  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
141 
145  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
146 
152  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
153 
154 private:
155  vtkHDRReader(const vtkHDRReader&) = delete;
156  void operator=(const vtkHDRReader&) = delete;
157 };
158 VTK_ABI_NAMESPACE_END
159 #endif
general representation of visualization data
Definition: vtkDataObject.h:55
read Radiance HDR files
Definition: vtkHDRReader.h:24
int CanReadFile(VTK_FILEPATH const char *fname) override
Is the given file a HDR file?
FormatType Format
Definition: vtkHDRReader.h:90
double Gamma
Definition: vtkHDRReader.h:91
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:83
~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:93
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:78
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:89
double Exposure
Definition: vtkHDRReader.h:92
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:43
Superclass of transformable binary file readers.
a simple class to control print indentation
Definition: vtkIndent.h:29
Store vtkAlgorithm input/output information.
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH