VTK  9.4.20250220
vtkDataEncoder.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
24#ifndef vtkDataEncoder_h
25#define vtkDataEncoder_h
26
27#include "vtkObject.h"
28#include "vtkSmartPointer.h" // needed for vtkSmartPointer
29#include "vtkWebCoreModule.h" // needed for exports
30#include <memory> // for std::unique_ptr
31
32VTK_ABI_NAMESPACE_BEGIN
34class vtkImageData;
35
36class VTKWEBCORE_EXPORT vtkDataEncoder : public vtkObject
37{
38public:
40 vtkTypeMacro(vtkDataEncoder, vtkObject);
41 void PrintSelf(ostream& os, vtkIndent indent) override;
42
44
48 void SetMaxThreads(vtkTypeUInt32);
49 vtkGetMacro(MaxThreads, vtkTypeUInt32);
51
56 void Initialize();
57
64 void Push(vtkTypeUInt32 key, vtkImageData* data, int quality, int encoding = 1);
65
74
81 void Flush(vtkTypeUInt32 key);
82
86 const char* EncodeAsBase64Png(vtkImageData* img, int compressionLevel = 5);
87
91 const char* EncodeAsBase64Jpg(vtkImageData* img, int quality = 50);
92
96 void Finalize();
97
98protected:
100 ~vtkDataEncoder() override;
101
102 vtkTypeUInt32 MaxThreads;
103
104private:
105 vtkDataEncoder(const vtkDataEncoder&) = delete;
106 void operator=(const vtkDataEncoder&) = delete;
107
108 class vtkInternals;
109 std::unique_ptr<vtkInternals> Internals;
110};
111
112VTK_ABI_NAMESPACE_END
113#endif
class used to compress/encode images using threads.
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,...
~vtkDataEncoder() override
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:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned char