Blue Brain BioExplorer
ImageGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License version 3.0 as published
11  * by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
26 
27 #include <turbojpeg.h>
28 
29 namespace core
30 {
35 {
36 public:
37  ImageGenerator() = default;
39 
40  struct ImageBase64
41  {
42  std::string data;
43  };
44 
57  ImageBase64 createImage(FrameBuffer& frameBuffer, const std::string& format,
58  uint8_t quality);
59  ImageBase64 createImage(const std::vector<FrameBufferPtr>& frameBuffers,
60  const std::string& format, uint8_t quality);
61 
62  struct ImageJPEG
63  {
64  struct tjDeleter
65  {
66  void operator()(uint8_t* ptr) { tjFree(ptr); }
67  };
68  using JpegData = std::unique_ptr<uint8_t, tjDeleter>;
70  unsigned long size{0};
71  };
72 
80  ImageJPEG createJPEG(FrameBuffer& frameBuffer, uint8_t quality);
81 
82 private:
83  tjhandle _compressor{tjInitCompress()};
84 
85  ImageJPEG::JpegData _encodeJpeg(uint32_t width, uint32_t height,
86  const uint8_t* rawData, int32_t pixelFormat,
87  uint8_t quality, unsigned long& dataSize);
88 };
89 } // namespace core
This class represents a frame buffer for an engine specific code. It provides an API for utilizing an...
Definition: FrameBuffer.h:39
ImageJPEG createJPEG(FrameBuffer &frameBuffer, uint8_t quality)
ImageGenerator()=default
ImageBase64 createImage(FrameBuffer &frameBuffer, const std::string &format, uint8_t quality)
std::unique_ptr< uint8_t, tjDeleter > JpegData