OpenShot Library | libopenshot  0.3.2
ImageWriter.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC, Fabrice Bellard
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_IMAGE_WRITER_H
14 #define OPENSHOT_IMAGE_WRITER_H
15 
16 #ifdef USE_IMAGEMAGICK
17 
18 #include <string>
19 #include <vector>
20 
21 #include "WriterBase.h"
22 #include "MagickUtilities.h"
23 
24 #include "Fraction.h"
25 
26 namespace openshot
27 {
28  // Forward decls
29  class Frame;
30  class ReaderBase;
31 
59  class ImageWriter : public WriterBase
60  {
61  private:
62  std::string path;
63  int cache_size;
64  bool is_open;
65  int64_t write_video_count;
66  std::vector<Magick::Image> frames;
67  int image_quality;
68  int number_of_loops;
69  bool combine_frames;
70 
71  std::shared_ptr<Frame> last_frame;
72 
73  public:
74 
77  ImageWriter(std::string path);
78 
81  void Close();
82 
84  int GetCacheSize() { return cache_size; };
85 
87  bool IsOpen() { return is_open; };
88 
90  void Open();
91 
94  void SetCacheSize(int new_size) { cache_size = new_size; };
95 
104  void SetVideoOptions(
105  std::string format, Fraction fps, int width, int height,
106  int quality, int loops, bool combine);
107 
110  void WriteFrame(std::shared_ptr<Frame> frame);
111 
116  void WriteFrame(ReaderBase* reader, int64_t start, int64_t length);
117 
118  };
119 
120 } // namespace
121 
122 #endif //USE_IMAGEMAGICK
123 #endif //OPENSHOT_IMAGE_WRITER_H
openshot::ImageWriter::GetCacheSize
int GetCacheSize()
Get the cache size.
Definition: ImageWriter.h:84
WriterBase.h
Header file for WriterBase class.
Fraction.h
Header file for Fraction class.
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Fraction
This class represents a fraction.
Definition: Fraction.h:30
openshot::ImageWriter::Open
void Open()
Open writer.
Definition: ImageWriter.cpp:79
openshot::ImageWriter::WriteFrame
void WriteFrame(std::shared_ptr< Frame > frame)
Add a frame to the stack waiting to be encoded.
Definition: ImageWriter.cpp:85
openshot::ImageWriter
This class uses the ImageMagick library to write image files (including animated GIFs)
Definition: ImageWriter.h:59
openshot::ImageWriter::IsOpen
bool IsOpen()
Determine if writer is open or closed.
Definition: ImageWriter.h:87
path
path
Definition: FFmpegWriter.cpp:1444
openshot::ImageWriter::SetCacheSize
void SetCacheSize(int new_size)
Set the cache size (number of frames to queue before writing)
Definition: ImageWriter.h:94
openshot::ImageWriter::Close
void Close()
Close the writer and encode/output final image to the disk. This is a requirement of ImageMagick,...
Definition: ImageWriter.cpp:140
openshot::ImageWriter::SetVideoOptions
void SetVideoOptions(std::string format, Fraction fps, int width, int height, int quality, int loops, bool combine)
Set the video export options.
Definition: ImageWriter.cpp:36
MagickUtilities.h
Header file for MagickUtilities (IM6/IM7 compatibility overlay)
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::ImageWriter::ImageWriter
ImageWriter(std::string path)
Constructor for ImageWriter. Throws one of the following exceptions.
Definition: ImageWriter.cpp:27
openshot::WriterBase
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
Definition: WriterBase.h:69