VTK  9.0.1
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 =========================================================================*/
23 #ifndef vtkHDRReader_h
24 #define vtkHDRReader_h
25 
26 #include "vtkIOImageModule.h" // For export macro
27 #include "vtkImageReader.h"
28 #include <string>
29 #include <vector>
30 
31 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
32 {
33 public:
34  static vtkHDRReader* New();
35  vtkTypeMacro(vtkHDRReader, vtkImageReader);
36 
37  void PrintSelf(ostream& os, vtkIndent indent) override;
38 
40  {
41  FORMAT_32BIT_RLE_RGBE = 0,
42  FORMAT_32BIT_RLE_XYZE
43  };
44 
46 
49  vtkGetMacro(Format, int);
51 
53 
57  vtkGetMacro(Gamma, double);
59 
61 
65  vtkGetMacro(Exposure, double);
67 
69 
73  vtkGetMacro(PixelAspect, double);
75 
79  int CanReadFile(const char* fname) override;
80 
86  const char* GetFileExtensions() override { return ".hdr .pic"; }
87 
91  const char* GetDescriptiveName() override { return "Radiance HDR"; }
92 
93 protected:
94  vtkHDRReader();
95  ~vtkHDRReader() override;
96 
99  double Gamma;
100  double Exposure;
101  double PixelAspect;
102 
106  bool FlippedX = false;
107 
111  bool SwappedAxis = false;
112 
113  void ExecuteInformation() override;
114  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
115  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
116  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
117 
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 
142  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
143 
148  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
149 
153  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
154 
160  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
161 
162 private:
163  vtkHDRReader(const vtkHDRReader&) = delete;
164  void operator=(const vtkHDRReader&) = delete;
165 };
166 #endif
vtkImageReader
Superclass of transformable binary file readers.
Definition: vtkImageReader.h:38
vtkImageReader::ExecuteDataWithInformation
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkHDRReader::Gamma
double Gamma
Definition: vtkHDRReader.h:99
vtkHDRReader::Exposure
double Exposure
Definition: vtkHDRReader.h:100
vtkImageReader::New
static vtkImageReader * New()
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkHDRReader::GetDescriptiveName
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:91
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkHDRReader::FormatType
FormatType
Definition: vtkHDRReader.h:39
vtkHDRReader::Format
FormatType Format
Definition: vtkHDRReader.h:98
vtkHDRReader::GetFileExtensions
const char * GetFileExtensions() override
Get the file extensions for this format.
Definition: vtkHDRReader.h:86
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkHDRReader::ProgramType
std::string ProgramType
Definition: vtkHDRReader.h:97
vtkHDRReader::PixelAspect
double PixelAspect
Definition: vtkHDRReader.h:101
vtkImageReader2::ExecuteInformation
virtual void ExecuteInformation()
vtkImageReader.h
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkImageReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageReader::CanReadFile
int CanReadFile(const char *) override
vtkImageReader itself can read raw binary files.
Definition: vtkImageReader.h:97
vtkHDRReader
read Radiance HDR files
Definition: vtkHDRReader.h:31