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 =========================================================================*/
35 #ifndef vtkHDRReader_h
36 #define vtkHDRReader_h
37 
38 #include "vtkIOImageModule.h" // For export macro
39 #include "vtkImageReader.h"
40 #include <string> // for std::string
41 #include <vector> // for std::vector
42 
43 class VTKIOIMAGE_EXPORT vtkHDRReader : public vtkImageReader
44 {
45 public:
46  static vtkHDRReader* New();
47  vtkTypeMacro(vtkHDRReader, vtkImageReader);
48 
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52  {
53  FORMAT_32BIT_RLE_RGBE = 0,
54  FORMAT_32BIT_RLE_XYZE
55  };
56 
58 
61  vtkGetMacro(Format, int);
63 
65 
69  vtkGetMacro(Gamma, double);
71 
73 
77  vtkGetMacro(Exposure, double);
79 
81 
85  vtkGetMacro(PixelAspect, double);
87 
91  int CanReadFile(VTK_FILEPATH const char* fname) override;
92 
98  const char* GetFileExtensions() override { return ".hdr .pic"; }
99 
103  const char* GetDescriptiveName() override { return "Radiance HDR"; }
104 
105 protected:
107  ~vtkHDRReader() override;
108 
111  double Gamma;
112  double Exposure;
113  double PixelAspect;
114 
118  bool FlippedX = false;
119 
123  bool SwappedAxis = false;
124 
125  void ExecuteInformation() override;
127  bool HDRReaderUpdateSlice(float* outPtr, int* outExt);
128  void HDRReaderUpdate(vtkImageData* data, float* outPtr);
129 
134  bool HasError(istream* is);
135 
136  int GetWidth() const;
137  int GetHeight() const;
138 
144 
145  void ConvertAllDataFromRGBToXYZ(float* outPtr, int size);
146 
147  void FillOutPtrRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
148  void FillOutPtrNoRLE(int* outExt, float*& outPtr, std::vector<unsigned char>& lineBuffer);
149 
154  bool ReadAllFileNoRLE(istream* is, float* outPtr, int decrPtr, int* outExt);
155 
160  bool ReadLineRLE(istream* is, unsigned char* lineBufferPtr);
161 
165  void RGBE2Float(unsigned char rgbe[4], float& r, float& g, float& b);
166 
172  static void XYZ2RGB(const float convertMatrix[3][3], float& r, float& g, float& b);
173 
174 private:
175  vtkHDRReader(const vtkHDRReader&) = delete;
176  void operator=(const vtkHDRReader&) = delete;
177 };
178 #endif
general representation of visualization data
Definition: vtkDataObject.h:75
read Radiance HDR files
Definition: vtkHDRReader.h:44
int CanReadFile(VTK_FILEPATH const char *fname) override
Is the given file a HDR file?
FormatType Format
Definition: vtkHDRReader.h:110
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkHDRReader.h:103
~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:113
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:98
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:109
double Exposure
Definition: vtkHDRReader.h:112
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:63
Superclass of transformable binary file readers.
a simple class to control print indentation
Definition: vtkIndent.h:49
Store vtkAlgorithm input/output information.
@ size
Definition: vtkX3D.h:259
@ data
Definition: vtkX3D.h:321
@ string
Definition: vtkX3D.h:496
#define VTK_FILEPATH