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

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

#include <TextReader.h>

Inheritance diagram for openshot::TextReader:
openshot::ReaderBase

Public Member Functions

void Close () override
 Close Reader. More...
 
openshot::CacheMemoryGetCache () override
 Get the cache object used by this reader (always returns NULL for this object) More...
 
std::shared_ptr< openshot::FrameGetFrame (int64_t requested_frame) override
 
bool IsOpen () override
 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 () override
 Return the type name of the class. More...
 
void Open () override
 Open Reader - which is called by the constructor automatically. More...
 
void SetJson (const std::string value) override
 Load JSON string into this object. More...
 
void SetJsonValue (const Json::Value root) override
 Load Json::Value into this object. More...
 
void SetTextBackgroundColor (std::string color)
 
 TextReader ()
 Default constructor (blank text) More...
 
 TextReader (int width, int height, int x_offset, int y_offset, GravityType gravity, std::string text, std::string font, double size, std::string text_color, std::string background_color)
 Constructor for TextReader with all parameters. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
openshot::ClipBaseParentClip ()
 Parent clip object of this reader (which can be unparented and NULL) More...
 
void ParentClip (openshot::ClipBase *new_clip)
 Set parent clip object of this reader. More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. 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
openshot::ClipBaseclip
 Pointer to the parent clip instance (if any) More...
 
juce::CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
juce::CriticalSection processingCriticalSection
 

Detailed Description

This class uses the ImageMagick++ 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...

// Create a reader to generate an openshot::Frame containing text
TextReader r(720, // width
480, // height
5, // x_offset
5, // y_offset
GRAVITY_CENTER, // gravity
"Check out this Text!", // text
"Arial", // font
15.0, // 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 85 of file TextReader.h.

Constructor & Destructor Documentation

◆ TextReader() [1/2]

TextReader::TextReader ( )

Default constructor (blank text)

Definition at line 39 of file TextReader.cpp.

◆ TextReader() [2/2]

TextReader::TextReader ( int  width,
int  height,
int  x_offset,
int  y_offset,
GravityType  gravity,
std::string  text,
std::string  font,
double  size,
std::string  text_color,
std::string  background_color 
)

Constructor for TextReader 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
sizeThe size of the text
text_colorThe color of the text
background_colorThe background color of the text frame image (also supports Transparent)

Definition at line 46 of file TextReader.cpp.

Member Function Documentation

◆ Close()

void TextReader::Close ( )
overridevirtual

Close Reader.

Implements openshot::ReaderBase.

Definition at line 154 of file TextReader.cpp.

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

◆ GetCache()

openshot::CacheMemory* openshot::TextReader::GetCache ( )
inlineoverridevirtual

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

Implements openshot::ReaderBase.

Definition at line 129 of file TextReader.h.

◆ GetFrame()

std::shared_ptr< Frame > TextReader::GetFrame ( int64_t  requested_frame)
overridevirtual

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 165 of file TextReader.cpp.

Referenced by GetCache().

◆ IsOpen()

bool openshot::TextReader::IsOpen ( )
inlineoverridevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 139 of file TextReader.h.

◆ Json()

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

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 193 of file TextReader.cpp.

Referenced by Name().

◆ JsonValue()

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

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 200 of file TextReader.cpp.

Referenced by Json(), and Name().

◆ Name()

std::string openshot::TextReader::Name ( )
inlineoverridevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 142 of file TextReader.h.

◆ Open()

void TextReader::Open ( )
overridevirtual

Open Reader - which is called by the constructor automatically.

Implements openshot::ReaderBase.

Definition at line 63 of file TextReader.cpp.

Referenced by Name(), SetJsonValue(), SetTextBackgroundColor(), and TextReader().

◆ SetJson()

void TextReader::SetJson ( const std::string  value)
overridevirtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 222 of file TextReader.cpp.

Referenced by Name().

◆ SetJsonValue()

void TextReader::SetJsonValue ( const Json::Value  root)
overridevirtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 237 of file TextReader.cpp.

Referenced by Name(), and SetJson().

◆ SetTextBackgroundColor()

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

Draw a box under rendered text using the specified color.

Parameters
colorThe background color behind the text

Definition at line 54 of file TextReader.cpp.


The documentation for this class was generated from the following files: