VTK  9.0.2
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 "vtkObject.h"
37 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
38 #include "vtkWebCoreModule.h" // needed for exports
39 
41 class vtkImageData;
42 
43 class VTKWEBCORE_EXPORT vtkDataEncoder : public vtkObject
44 {
45 public:
46  static vtkDataEncoder* New();
47  vtkTypeMacro(vtkDataEncoder, vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
54  void SetMaxThreads(vtkTypeUInt32);
55  vtkGetMacro(MaxThreads, vtkTypeUInt32);
56 
61  void Initialize();
62 
72  void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData*& data, int quality, int encoding = 1);
73 
82 
89  void Flush(vtkTypeUInt32 key);
90 
94  const char* EncodeAsBase64Png(vtkImageData* img, int compressionLevel = 5);
95 
99  const char* EncodeAsBase64Jpg(vtkImageData* img, int quality = 50);
100 
104  void Finalize();
105 
106 protected:
108  ~vtkDataEncoder() override;
109 
110  vtkTypeUInt32 MaxThreads;
111 
112 private:
113  vtkDataEncoder(const vtkDataEncoder&) = delete;
114  void operator=(const vtkDataEncoder&) = delete;
115 
116  class vtkInternals;
117  vtkInternals* Internals;
118 };
119 
120 #endif
class used to compress/encode images using threads.
const char * EncodeAsBase64Jpg(vtkImageData *img, int quality=50)
Take an image data and synchronously convert it to a base-64 encoded jpg.
void Finalize()
This method will wait for any running thread to terminate.
vtkTypeUInt32 MaxThreads
const char * EncodeAsBase64Png(vtkImageData *img, int compressionLevel=5)
Take an image data and synchronously convert it to a base-64 encoded png.
bool GetLatestOutput(vtkTypeUInt32 key, vtkSmartPointer< vtkUnsignedCharArray > &data)
Get access to the most-recent fully encoded result corresponding to the given key,...
~vtkDataEncoder() override
static vtkDataEncoder * New()
void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData *&data, int quality, int encoding=1)
Push an image into the encoder.
void Flush(vtkTypeUInt32 key)
Flushes the encoding pipe and blocks till the most recently pushed image for the particular key has b...
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:42
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
dynamic, self-adjusting array of unsigned char
@ key
Definition: vtkX3D.h:263
@ data
Definition: vtkX3D.h:321