OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
QtTextReader.h
Go to the documentation of this file.
1
10
11
// Copyright (c) 2008-2019 OpenShot Studios, LLC
12
//
13
// SPDX-License-Identifier: LGPL-3.0-or-later
14
15
#ifndef OPENSHOT_QT_TEXT_READER_H
16
#define OPENSHOT_QT_TEXT_READER_H
17
18
#include "
ReaderBase.h
"
19
20
#include <atomic>
21
#include <list>
22
#include <memory>
23
#include <string>
24
#include <utility>
25
26
#include "
Enums.h
"
27
28
#include <QFont>
29
30
class
QImage;
31
32
namespace
openshot
33
{
34
// Forward decls
35
class
CacheBase
;
36
class
Frame
;
37
73
class
QtTextReader
:
public
ReaderBase
74
{
75
private
:
76
// Opt-in document layout keeps existing readers' drawText behavior intact.
77
// These settings round-trip through JSON; sizes are pixels. Style names match
78
// the Caption effect where they mean the same thing (stroke, background_padding,
79
// background_corner, line_spacing). text_animation keyframes only the styles that
80
// keep the image size: color, background, stroke, border, stroke_width,
81
// border_width and background_corner.
82
Json::Value text_animation;
83
Json::Value rendered_style;
84
int64_t render_frame = 1;
85
double
render_scale = 1.0;
86
std::atomic<double> detail_scale{1.0};
87
double
RasterScale(
double
& detail);
88
openshot::Fraction
source_fps =
openshot::Fraction
(30, 1);
90
std::list<std::pair<std::string, std::shared_ptr<QImage>>> render_cache;
91
std::shared_ptr<QImage> Render(
const
Json::Value& style);
92
void
UseStyle(
const
Json::Value& style);
93
void
UpdateInfo();
94
Json::Value EvaluateStyle(int64_t frame)
const
;
95
bool
document_layout =
false
;
96
double
background_padding = 12.0;
97
double
stroke_width = 0.0;
98
std::string stroke =
"#000000"
;
99
double
border_width = 0.0;
100
std::string border =
"#ffffff"
;
101
double
letter_spacing = 0.0;
102
double
line_spacing = 1.0;
103
double
background_corner = 0.0;
104
int
width;
105
int
height;
106
int
x_offset;
107
int
y_offset;
108
std::string text;
109
QFont font;
110
std::string text_color;
111
std::string background_color;
112
std::string text_background_color;
113
std::shared_ptr<QImage> image;
114
bool
is_open;
115
openshot::GravityType
gravity;
116
117
public
:
118
120
QtTextReader
();
121
132
QtTextReader
(
int
width,
int
height,
int
x_offset,
int
y_offset,
GravityType
gravity, std::string text, QFont font, std::string text_color, std::string background_color);
133
136
double
DetailScale
()
const
{
return
detail_scale; }
137
140
void
SetTextBackgroundColor
(std::string color);
141
143
void
Close
()
override
;
144
146
CacheBase
*
GetCache
()
override
{
return
NULL; };
147
153
std::shared_ptr<openshot::Frame>
GetFrame
(int64_t requested_frame)
override
;
154
156
bool
IsOpen
()
override
{
return
is_open; };
157
159
std::string
Name
()
override
{
return
"QtTextReader"
; };
160
161
// Get and Set JSON methods
162
std::string
Json
()
const override
;
163
void
SetJson
(
const
std::string value)
override
;
164
Json::Value
JsonValue
()
const override
;
165
void
SetJsonValue
(
const
Json::Value root)
override
;
166
168
void
Open
()
override
;
169
};
170
171
}
172
173
#endif
Enums.h
Header file for TextReader class.
ReaderBase.h
Header file for ReaderBase class.
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition
CacheBase.h:35
openshot::Fraction
This class represents a fraction.
Definition
Fraction.h:30
openshot::Frame
This class represents a single frame of video (i.e. image & audio data).
Definition
Frame.h:90
openshot::QtTextReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition
QtTextReader.cpp:435
openshot::QtTextReader::SetTextBackgroundColor
void SetTextBackgroundColor(std::string color)
Definition
QtTextReader.cpp:47
openshot::QtTextReader::Close
void Close() override
Close Reader.
Definition
QtTextReader.cpp:335
openshot::QtTextReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition
QtTextReader.cpp:397
openshot::QtTextReader::GetCache
CacheBase * GetCache() override
Get the cache object used by this reader (always returns NULL for this object).
Definition
QtTextReader.h:146
openshot::QtTextReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition
QtTextReader.cpp:452
openshot::QtTextReader::QtTextReader
QtTextReader()
Default constructor (blank text).
Definition
QtTextReader.cpp:34
openshot::QtTextReader::Name
std::string Name() override
Return the type name of the class.
Definition
QtTextReader.h:159
openshot::QtTextReader::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
Definition
QtTextReader.cpp:353
openshot::QtTextReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition
QtTextReader.cpp:404
openshot::QtTextReader::DetailScale
double DetailScale() const
Definition
QtTextReader.h:136
openshot::QtTextReader::Open
void Open() override
Open Reader - which is called by the constructor automatically.
Definition
QtTextReader.cpp:317
openshot::QtTextReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition
QtTextReader.h:156
openshot::ReaderBase::ReaderBase
ReaderBase()
Constructor for the base reader, where many things are initialized.
Definition
ReaderBase.cpp:27
openshot
This namespace is the default namespace for all code in the openshot library.
Definition
AnimatedCurve.h:24
openshot::GravityType
GravityType
This enumeration determines how clips are aligned to their parent container.
Definition
Enums.h:22
QtTextReader.h
Generated by
1.17.0