VTK  9.7.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
15 #ifndef vtkHDRReader_h
16 #define vtkHDRReader_h
17 
18 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_6_0
19 #include "vtkIOImageModule.h" // For export macro
20 #include "vtkImageReader.h"
21 #include <string> // for std::string
22 #include <vector> // for std::vector
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
26 {
27 public:
28  static vtkHDRReader* New();
29  vtkTypeMacro(vtkHDRReader, vtkImageReader);
30 
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32 
34  {
35  FORMAT_32BIT_RLE_RGBE = 0,
36  FORMAT_32BIT_RLE_XYZE
37  };
38 
40 
43  vtkGetMacro(Format, int);
45 
47 
51  vtkGetMacro(Gamma, double);
53 
55 
59  vtkGetMacro(Exposure, double);
61 
63 
67  vtkGetMacro(PixelAspect, double);
69 
71 
76  int CanReadFile(VTK_FILEPATH const char* fname) override;
77  int CanReadFile(vtkResourceStream* stream) override;
79 
85  const char* GetFileExtensions() override { return ".hdr .pic"; }
86 
90  const char* GetDescriptiveName() override { return "Radiance HDR"; }
91 
92 protected:
93  vtkHDRReader();
94  ~vtkHDRReader() override;
95 
98  double Gamma;
99  double Exposure;
100  double PixelAspect;
101 
105  bool FlippedX = false;
106 
110  bool SwappedAxis = false;
111 
112  void ExecuteInformation() override;
113  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
114  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
115  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
116 
121  VTK_DEPRECATED_IN_9_6_0("Do not use, use Streams instead")
122  bool HasError(istream* is);
123 
124  int GetWidth() const;
125  int GetHeight() const;
126 
131  bool ReadHeaderData();
132 
133  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
134 
135  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
136  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
137 
141  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
142 
148  static void XYZ2RGB(const float convertMatrix[3][3], double gamma, float& r, float& g, float& b);
149 
150 private:
151  vtkHDRReader(const vtkHDRReader&) = delete;
152  void operator=(const vtkHDRReader&) = delete;
153 
158  bool ReadAllFileNoRLE(vtkResourceStream* stream, float* outPtr, int decrPtr, int* outExt);
159 
164  bool ReadLineRLE(vtkResourceStream* stream, unsigned char* lineBufferPtr);
165 
166  // Internal ExecuteInformation() validation flag
167  bool Validated = false;
168 };
169 VTK_ABI_NAMESPACE_END
170 #endif
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:90
Abstract class used for custom streams.
Store vtkAlgorithm input/output information.
double Gamma
Definition: vtkHDRReader.h:98
double PixelAspect
Definition: vtkHDRReader.h:100
static vtkImageReader * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_DEPRECATED_IN_9_6_0(reason)
a simple class to control print indentation
Definition: vtkIndent.h:28
Superclass of transformable binary file readers.
FormatType Format
Definition: vtkHDRReader.h:97
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
std::string ProgramType
Definition: vtkHDRReader.h:96
double Exposure
Definition: vtkHDRReader.h:99
virtual void ExecuteInformation()
int CanReadFile(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:25
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:85
general representation of visualization data
Definition: vtkDataObject.h:55