VTK
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 =========================================================================*/
36 #ifndef vtkDataEncoder_h
37 #define vtkDataEncoder_h
38 
39 #include "vtkObject.h"
40 #include "vtkWebCoreModule.h" // needed for exports
41 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
42 
44 class vtkImageData;
45 
46 class VTKWEBCORE_EXPORT vtkDataEncoder : public vtkObject
47 {
48 public:
49  static vtkDataEncoder* New();
50  vtkTypeMacro(vtkDataEncoder, vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
57  void SetMaxThreads(vtkTypeUInt32);
58  vtkGetMacro(MaxThreads, vtkTypeUInt32);
59 
64  void Initialize();
65 
75  void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData* &data, int quality, int encoding = 1);
76 
85 
92  void Flush(vtkTypeUInt32 key);
93 
97  const char* EncodeAsBase64Png(vtkImageData* img, int compressionLevel=5);
98 
102  const char* EncodeAsBase64Jpg(vtkImageData* img, int quality=50);
103 
107  void Finalize();
108 
109 protected:
111  ~vtkDataEncoder() override;
112 
113  vtkTypeUInt32 MaxThreads;
114 
115 private:
116  vtkDataEncoder(const vtkDataEncoder&) = delete;
117  void operator=(const vtkDataEncoder&) = delete;
118 
119  class vtkInternals;
120  vtkInternals* Internals;
121 
122 };
123 
124 #endif
vtkDataEncoder::EncodeAsBase64Jpg
const char * EncodeAsBase64Jpg(vtkImageData *img, int quality=50)
Take an image data and synchronously convert it to a base-64 encoded jpg.
vtkDataEncoder::vtkDataEncoder
vtkDataEncoder()
vtkDataEncoder::Flush
void Flush(vtkTypeUInt32 key)
Flushes the encoding pipe and blocks till the most recently pushed image for the particular key has b...
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:42
vtkSmartPointer< vtkUnsignedCharArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkDataEncoder
class used to compress/encode images using threads.
Definition: vtkDataEncoder.h:47
vtkDataEncoder::Initialize
void Initialize()
Re-initializes the encoder.
vtkDataEncoder::Finalize
void Finalize()
This method will wait for any running thread to terminate.
vtkDataEncoder::SetMaxThreads
void SetMaxThreads(vtkTypeUInt32)
Define the number of worker threads to use.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkSmartPointer.h
vtkDataEncoder::New
static vtkDataEncoder * New()
vtkDataEncoder::EncodeAsBase64Png
const char * EncodeAsBase64Png(vtkImageData *img, int compressionLevel=5)
Take an image data and synchronously convert it to a base-64 encoded png.
vtkDataEncoder::PushAndTakeReference
void PushAndTakeReference(vtkTypeUInt32 key, vtkImageData *&data, int quality, int encoding=1)
Push an image into the encoder.
vtkDataEncoder::GetLatestOutput
bool GetLatestOutput(vtkTypeUInt32 key, vtkSmartPointer< vtkUnsignedCharArray > &data)
Get access to the most-recent fully encoded result corresponding to the given key,...
vtkObject.h
vtkDataEncoder::~vtkDataEncoder
~vtkDataEncoder() override
vtkDataEncoder::MaxThreads
vtkTypeUInt32 MaxThreads
Definition: vtkDataEncoder.h:113
vtkDataEncoder::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.