VTK  9.2.6
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=========================================================================*/
35
36#ifndef vtkDataEncoder_h
37#define vtkDataEncoder_h
38
39#include "vtkDeprecation.h" // needed for exports
40#include "vtkObject.h"
41#include "vtkSmartPointer.h" // needed for vtkSmartPointer
42#include "vtkWebCoreModule.h" // needed for exports
43#include <memory> // for std::unique_ptr
44
46class vtkImageData;
47
48class VTKWEBCORE_EXPORT vtkDataEncoder : public vtkObject
49{
50public:
52 vtkTypeMacro(vtkDataEncoder, vtkObject);
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
56
60 void SetMaxThreads(vtkTypeUInt32);
61 vtkGetMacro(MaxThreads, vtkTypeUInt32);
63
68 void Initialize();
69
79 VTK_DEPRECATED_IN_9_1_0("replaced by Push")
80 void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData*& data, int quality, int encoding = 1);
81
88 void Push(vtkTypeUInt32 key, vtkImageData* data, int quality, int encoding = 1);
89
97 bool GetLatestOutput(vtkTypeUInt32 key, vtkSmartPointer<vtkUnsignedCharArray>& data);
98
105 void Flush(vtkTypeUInt32 key);
106
110 const char* EncodeAsBase64Png(vtkImageData* img, int compressionLevel = 5);
111
115 const char* EncodeAsBase64Jpg(vtkImageData* img, int quality = 50);
116
120 void Finalize();
121
122protected:
124 ~vtkDataEncoder() override;
125
126 vtkTypeUInt32 MaxThreads;
127
128private:
129 vtkDataEncoder(const vtkDataEncoder&) = delete;
130 void operator=(const vtkDataEncoder&) = delete;
131
132 class vtkInternals;
133 std::unique_ptr<vtkInternals> Internals;
134};
135
136#endif
void Finalize()
This method will wait for any running thread to terminate.
vtkTypeUInt32 MaxThreads
const char * EncodeAsBase64Jpg(vtkImageData *img, int quality=50)
Take an image data and synchronously convert it to a base-64 encoded jpg.
static vtkDataEncoder * New()
bool GetLatestOutput(vtkTypeUInt32 key, vtkSmartPointer< vtkUnsignedCharArray > &data)
Get access to the most-recent fully encoded result corresponding to the given key,...
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.
const char * EncodeAsBase64Png(vtkImageData *img, int compressionLevel=5)
Take an image data and synchronously convert it to a base-64 encoded png.
void SetMaxThreads(vtkTypeUInt32)
Define the number of worker threads to use.
void Push(vtkTypeUInt32 key, vtkImageData *data, int quality, int encoding=1)
Push an image into the encoder.
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
a simple class to control print indentation
Definition vtkIndent.h:40
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char
#define VTK_DEPRECATED_IN_9_1_0(reason)