OpenShot Library | libopenshot  0.2.5
Public Member Functions | List of all members
openshot::QtTextReader Class Reference

This class uses Qt libraries, to create frames with "Text", and return openshot::Frame objects. More...

#include <QtTextReader.h>

Inheritance diagram for openshot::QtTextReader:
openshot::ReaderBase

Public Member Functions

void Close ()
 Close Reader. More...
 
openshot::CacheMemoryGetCache ()
 Get the cache object used by this reader (always returns NULL for this object) More...
 
std::shared_ptr< openshot::FrameGetFrame (int64_t requested_frame)
 
bool IsOpen ()
 Determine if reader is open or closed. More...
 
std::string Json () const override
 Get and Set JSON methods. More...
 
Json::Value JsonValue () const override
 Generate Json::Value for this object. More...
 
std::string Name ()
 Return the type name of the class. More...
 
void Open ()
 Open Reader - which is called by the constructor automatically. More...
 
 QtTextReader ()
 Default constructor (blank text) More...
 
 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)
 Constructor for QtTextReader with all parameters. More...
 
void SetJson (const std::string value)
 Load JSON string into this object. More...
 
void SetJsonValue (const Json::Value root)
 Load Json::Value into this object. More...
 
void SetTextBackgroundColor (std::string color)
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
openshot::ClipBaseGetClip ()
 Parent clip object of this reader (which can be unparented and NULL) More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. More...
 
void SetClip (openshot::ClipBase *clip)
 Set parent clip object of this reader. More...
 
virtual ~ReaderBase ()=default
 

Additional Inherited Members

- Public Attributes inherited from openshot::ReaderBase
openshot::ReaderInfo info
 Information about the current media file. More...
 
- Protected Attributes inherited from openshot::ReaderBase
juce::CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
openshot::ClipBaseparent
 
juce::CriticalSection processingCriticalSection
 

Detailed Description

This class uses Qt libraries, to create frames with "Text", and return openshot::Frame objects.

All system fonts are supported, including many different font properties, such as size, color, alignment, padding, etc...

// Any application using this class must instantiate either QGuiApplication or QApplication
QApplication a(argc, argv);
// Create a reader to generate an openshot::Frame containing text
QtTextReader r(720, // width
480, // height
5, // x_offset
5, // y_offset
GRAVITY_CENTER, // gravity
"Check out this Text!", // text
"Arial", // font
15.0, // font size
"#fff000", // text_color
"#000000" // background_color
);
r.Open(); // Open the reader
// Get frame number 1 from the video (in fact, any frame # you request will return the same frame)
std::shared_ptr<Frame> f = r.GetFrame(1);
// Now that we have an openshot::Frame object, lets have some fun!
f->Display(); // Display the frame on the screen
// Close the reader
r.Close();

Definition at line 88 of file QtTextReader.h.

Constructor & Destructor Documentation

◆ QtTextReader() [1/2]

QtTextReader::QtTextReader ( )

Default constructor (blank text)

Definition at line 40 of file QtTextReader.cpp.

◆ QtTextReader() [2/2]

QtTextReader::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 
)

Constructor for QtTextReader with all parameters.

Parameters
widthThe width of the requested openshot::Frame (not the size of the text)
heightThe height of the requested openshot::Frame (not the size of the text)
x_offsetThe number of pixels to offset the text on the X axis (horizontal)
y_offsetThe number of pixels to offset the text on the Y axis (vertical)
gravityThe alignment / gravity of the text
textThe text you want to generate / display
fontThe font of the text
text_colorThe color of the text (valid values are a color string in #RRGGBB or #AARRGGBB notation or a CSS color name)
background_colorThe background color of the frame image (valid values are a color string in #RRGGBB or #AARRGGBB notation, a CSS color name, or 'transparent')

Definition at line 47 of file QtTextReader.cpp.

Member Function Documentation

◆ Close()

void QtTextReader::Close ( )
virtual

Close Reader.

Implements openshot::ReaderBase.

Definition at line 160 of file QtTextReader.cpp.

Referenced by QtTextReader(), SetJsonValue(), and SetTextBackgroundColor().

◆ GetCache()

openshot::CacheMemory* openshot::QtTextReader::GetCache ( )
inlinevirtual

Get the cache object used by this reader (always returns NULL for this object)

Implements openshot::ReaderBase.

Definition at line 129 of file QtTextReader.h.

◆ GetFrame()

std::shared_ptr< Frame > QtTextReader::GetFrame ( int64_t  requested_frame)
virtual

Get an openshot::Frame object for a specific frame number of this reader. All numbers return the same Frame, since they all share the same image data.

Returns
The requested frame (containing the image)
Parameters
requested_frameThe frame number that is requested.

Implements openshot::ReaderBase.

Definition at line 177 of file QtTextReader.cpp.

◆ IsOpen()

bool openshot::QtTextReader::IsOpen ( )
inlinevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 139 of file QtTextReader.h.

◆ Json()

std::string QtTextReader::Json ( ) const
overridevirtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 200 of file QtTextReader.cpp.

◆ JsonValue()

Json::Value QtTextReader::JsonValue ( ) const
overridevirtual

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 207 of file QtTextReader.cpp.

Referenced by Json().

◆ Name()

std::string openshot::QtTextReader::Name ( )
inlinevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 142 of file QtTextReader.h.

◆ Open()

void QtTextReader::Open ( )
virtual

Open Reader - which is called by the constructor automatically.

Implements openshot::ReaderBase.

Definition at line 64 of file QtTextReader.cpp.

Referenced by QtTextReader(), SetJsonValue(), and SetTextBackgroundColor().

◆ SetJson()

void QtTextReader::SetJson ( const std::string  value)
virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 228 of file QtTextReader.cpp.

◆ SetJsonValue()

void QtTextReader::SetJsonValue ( const Json::Value  root)
virtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 245 of file QtTextReader.cpp.

Referenced by SetJson().

◆ SetTextBackgroundColor()

void QtTextReader::SetTextBackgroundColor ( std::string  color)

Draw a box under rendered text using the specified color.

Parameters
colorThe background color behind the text (valid values are a color string in #RRGGBB or #AARRGGBB notation or a CSS color name)

Definition at line 55 of file QtTextReader.cpp.


The documentation for this class was generated from the following files:
a
#define a
openshot::GRAVITY_CENTER
@ GRAVITY_CENTER
Align clip to the center of its parent (middle aligned)
Definition: Enums.h:44
openshot::QtTextReader::QtTextReader
QtTextReader()
Default constructor (blank text)
Definition: QtTextReader.cpp:40