VTK  9.3.1
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:
86  vtkHDRReader();
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;
106  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) 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 
123  bool ReadHeaderData();
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
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:83
Store vtkAlgorithm input/output information.
double Gamma
Definition: vtkHDRReader.h:91
double PixelAspect
Definition: vtkHDRReader.h:93
static vtkImageReader * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
Superclass of transformable binary file readers.
FormatType Format
Definition: vtkHDRReader.h:90
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
std::string ProgramType
Definition: vtkHDRReader.h:89
double Exposure
Definition: vtkHDRReader.h:92
virtual void ExecuteInformation()
int CanReadFile(VTK_FILEPATH const char *) override
vtkImageReader itself can read raw binary files.
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
#define VTK_FILEPATH
read Radiance HDR files
Definition: vtkHDRReader.h:23
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:78
general representation of visualization data
Definition: vtkDataObject.h:54