VTK  9.1.0
vtkDataEncoder.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataEncoder.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 =========================================================================*/
33 #ifndef vtkDataEncoder_h
34 #define vtkDataEncoder_h
35 
36 #include "vtkDeprecation.h" // needed for exports
37 #include "vtkObject.h"
38 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
39 #include "vtkWebCoreModule.h" // needed for exports
40 #include <memory> // for std::unique_ptr
41 
43 class vtkImageData;
44 
45 class VTKWEBCORE_EXPORT vtkDataEncoder : public vtkObject
46 {
47 public:
48  static vtkDataEncoder* New();
49  vtkTypeMacro(vtkDataEncoder, vtkObject);
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
53 
57  void SetMaxThreads(vtkTypeUInt32);
58  vtkGetMacro(MaxThreads, vtkTypeUInt32);
60 
65  void Initialize();
66 
76  VTK_DEPRECATED_IN_9_1_0("replaced by Push")
77  void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData*& data, int quality, int encoding = 1);
78 
85  void Push(vtkTypeUInt32 key, vtkImageData* data, int quality, int encoding = 1);
86 
94  bool GetLatestOutput(vtkTypeUInt32 key, vtkSmartPointer<vtkUnsignedCharArray>& data);
95 
102  void Flush(vtkTypeUInt32 key);
103 
107  const char* EncodeAsBase64Png(vtkImageData* img, int compressionLevel = 5);
108 
112  const char* EncodeAsBase64Jpg(vtkImageData* img, int quality = 50);
113 
117  void Finalize();
118 
119 protected:
121  ~vtkDataEncoder() override;
122 
123  vtkTypeUInt32 MaxThreads;
124 
125 private:
126  vtkDataEncoder(const vtkDataEncoder&) = delete;
127  void operator=(const vtkDataEncoder&) = delete;
128 
129  class vtkInternals;
130  std::unique_ptr<vtkInternals> Internals;
131 };
132 
133 #endif
class used to compress/encode images using threads.
static vtkDataEncoder * New()
void Initialize()
Re-initializes the encoder.
void SetMaxThreads(vtkTypeUInt32)
Define the number of worker threads to use.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
@ key
Definition: vtkX3D.h:263
@ data
Definition: vtkX3D.h:321
#define VTK_DEPRECATED_IN_9_1_0(reason)