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

This class uses the ImageMagick++ libraries, to open image files, and return openshot::Frame objects containing the image. More...

#include <ImageReader.h>

Inheritance diagram for openshot::ImageReader:
openshot::ReaderBase

Public Member Functions

void Close () override
 Close File. More...
 
CacheBaseGetCache () override
 Get the cache object used by this reader (always returns NULL for this object) More...
 
std::shared_ptr< FrameGetFrame (int64_t requested_frame) override
 
 ImageReader (const std::string &path, bool inspect_reader=true)
 Constructor for ImageReader. More...
 
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 File - 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...
 
- 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 open image files, and return openshot::Frame objects containing the image.

// Create a reader for a video
ImageReader r("MyAwesomeImage.jpeg");
r.Open(); // Open the reader
// Get frame number 1 from the video
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 73 of file ImageReader.h.

Constructor & Destructor Documentation

◆ ImageReader()

ImageReader::ImageReader ( const std::string &  path,
bool  inspect_reader = true 
)

Constructor for ImageReader.

Opens the media file to inspect its properties and loads frame 1, iff inspect_reader == true (the default). Pass a false value in the optional parameter to defer this initial Open()/Close() cycle.

When not inspecting the media file, it's much faster, and useful when you are inflating the object using JSON after instantiation.

Definition at line 38 of file ImageReader.cpp.

Member Function Documentation

◆ Close()

void ImageReader::Close ( )
overridevirtual

Close File.

Implements openshot::ReaderBase.

Definition at line 101 of file ImageReader.cpp.

Referenced by ImageReader(), and SetJsonValue().

◆ GetCache()

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

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

Implements openshot::ReaderBase.

Definition at line 95 of file ImageReader.h.

◆ GetFrame()

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

Referenced by GetCache().

◆ IsOpen()

bool openshot::ImageReader::IsOpen ( )
inlineoverridevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 105 of file ImageReader.h.

◆ Json()

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

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 134 of file ImageReader.cpp.

Referenced by Name().

◆ JsonValue()

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

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 141 of file ImageReader.cpp.

Referenced by Json(), and Name().

◆ Name()

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

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 108 of file ImageReader.h.

◆ Open()

void ImageReader::Open ( )
overridevirtual

Open File - which is called by the constructor automatically.

Implements openshot::ReaderBase.

Definition at line 48 of file ImageReader.cpp.

Referenced by ImageReader(), Name(), and SetJsonValue().

◆ SetJson()

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

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 153 of file ImageReader.cpp.

Referenced by Name().

◆ SetJsonValue()

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

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 170 of file ImageReader.cpp.

Referenced by Name(), and SetJson().


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