VTK  9.2.6
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 =========================================================================*/
26 #ifndef vtkHDRReader_h
27 #define vtkHDRReader_h
28 
29 #include "vtkIOImageModule.h" // For export macro
30 #include "vtkImageReader.h"
31 #include <string> // for std::string
32 #include <vector> // for std::vector
33 
34 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
35 {
36 public:
37  static vtkHDRReader* New();
38  vtkTypeMacro(vtkHDRReader, vtkImageReader);
39 
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
43  {
44  FORMAT_32BIT_RLE_RGBE = 0,
45  FORMAT_32BIT_RLE_XYZE
46  };
47 
49 
52  vtkGetMacro(Format, int);
54 
56 
60  vtkGetMacro(Gamma, double);
62 
64 
68  vtkGetMacro(Exposure, double);
70 
72 
76  vtkGetMacro(PixelAspect, double);
78 
82  int CanReadFile(VTK_FILEPATH const char* fname) override;
83 
89  const char* GetFileExtensions() override { return ".hdr .pic"; }
90 
94  const char* GetDescriptiveName() override { return "Radiance HDR"; }
95 
96 protected:
97  vtkHDRReader();
98  ~vtkHDRReader() override;
99 
102  double Gamma;
103  double Exposure;
104  double PixelAspect;
105 
109  bool FlippedX = false;
110 
114  bool SwappedAxis = false;
115 
116  void ExecuteInformation() override;
117  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
118  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
119  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
120 
125  bool HasError(istream* is);
126 
127  int GetWidth() const;
128  int GetHeight() const;
129 
134  bool ReadHeaderData();
135 
136  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
137 
138  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
139  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
140 
145  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
146 
151  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
152 
156  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
157 
163  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
164 
165 private:
166  vtkHDRReader(const vtkHDRReader&) = delete;
167  void operator=(const vtkHDRReader&) = delete;
168 };
169 #endif
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:94
Store vtkAlgorithm input/output information.
double PixelAspect
Definition: vtkHDRReader.h:104
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:39
Superclass of transformable binary file readers.
FormatType Format
Definition: vtkHDRReader.h:101
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
std::string ProgramType
Definition: vtkHDRReader.h:100
double Exposure
Definition: vtkHDRReader.h:103
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:34
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:89
general representation of visualization data
Definition: vtkDataObject.h:65