OpenShot Library | libopenshot  0.3.3
Public Member Functions | List of all members
openshot::QtHtmlReader Class Reference

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

#include <QtHtmlReader.h>

Inheritance diagram for openshot::QtHtmlReader:
[legend]
Collaboration diagram for openshot::QtHtmlReader:
[legend]

Public Member Functions

void Close () override
 Close Reader. More...
 
CacheBaseGetCache () 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
 Generate JSON string of this object. 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...
 
 QtHtmlReader ()
 Default constructor (blank text) More...
 
 QtHtmlReader (int width, int height, int x_offset, int y_offset, GravityType gravity, std::string html, std::string css, std::string background_color)
 Constructor for QtHtmlReader with all parameters. 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...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo (std::ostream *out=&std::cout)
 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...
 
std::recursive_mutex getFrameMutex
 Mutex for multiple threads. More...
 

Detailed Description

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

Supports HTML/CSS subset available via Qt libraries, see: https://doc.qt.io/qt-5/richtext-html-subset.html

// 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
QtHtmlReader r(720, // width
480, // height
5, // x_offset
5, // y_offset
GRAVITY_CENTER, // gravity
"<b>Check out</b> this Text!", // html
"b { color: #ff0000 }", // css
"#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 69 of file QtHtmlReader.h.

Constructor & Destructor Documentation

◆ QtHtmlReader() [1/2]

QtHtmlReader::QtHtmlReader ( )

Default constructor (blank text)

Definition at line 28 of file QtHtmlReader.cpp.

◆ QtHtmlReader() [2/2]

QtHtmlReader::QtHtmlReader ( int  width,
int  height,
int  x_offset,
int  y_offset,
GravityType  gravity,
std::string  html,
std::string  css,
std::string  background_color 
)

Constructor for QtHtmlReader 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
htmlThe HTML you want to render / display
cssThe CSS you want to apply to style the HTML
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 35 of file QtHtmlReader.cpp.

Member Function Documentation

◆ Close()

void QtHtmlReader::Close ( )
overridevirtual

Close Reader.

Implements openshot::ReaderBase.

Definition at line 129 of file QtHtmlReader.cpp.

Referenced by QtHtmlReader(), and SetJsonValue().

◆ GetCache()

CacheBase* openshot::QtHtmlReader::GetCache ( )
inlineoverridevirtual

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

Implements openshot::ReaderBase.

Definition at line 102 of file QtHtmlReader.h.

◆ GetFrame()

std::shared_ptr< Frame > QtHtmlReader::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 146 of file QtHtmlReader.cpp.

◆ IsOpen()

bool openshot::QtHtmlReader::IsOpen ( )
inlineoverridevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 112 of file QtHtmlReader.h.

◆ Json()

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

Generate JSON string of this object.

Implements openshot::ReaderBase.

Definition at line 176 of file QtHtmlReader.cpp.

◆ JsonValue()

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

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 183 of file QtHtmlReader.cpp.

Referenced by Json().

◆ Name()

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

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 115 of file QtHtmlReader.h.

◆ Open()

void QtHtmlReader::Open ( )
overridevirtual

Open Reader - which is called by the constructor automatically.

Implements openshot::ReaderBase.

Definition at line 44 of file QtHtmlReader.cpp.

Referenced by QtHtmlReader(), and SetJsonValue().

◆ SetJson()

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

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 202 of file QtHtmlReader.cpp.

◆ SetJsonValue()

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

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 219 of file QtHtmlReader.cpp.

Referenced by SetJson().


The documentation for this class was generated from the following files:
openshot::QtHtmlReader::QtHtmlReader
QtHtmlReader()
Default constructor (blank text)
Definition: QtHtmlReader.cpp:28
openshot::GRAVITY_CENTER
@ GRAVITY_CENTER
Align clip to the center of its parent (middle aligned)
Definition: Enums.h:27