OpenShot Library | libopenshot  0.2.3
QtImageReader.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for QtImageReader class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef OPENSHOT_QIMAGE_READER_H
29 #define OPENSHOT_QIMAGE_READER_H
30 
31 #include <cmath>
32 #include <ctime>
33 #include <iostream>
34 #include <omp.h>
35 #include <stdio.h>
36 #include <memory>
37 #include "Exceptions.h"
38 #include "ReaderBase.h"
39 
40 using namespace std;
41 
42 namespace openshot
43 {
44 
45  /**
46  * @brief This class uses the Qt library, to open image files, and return
47  * openshot::Frame objects containing the image.
48  *
49  * @code
50  * // Create a reader for a video
51  * QtImageReader r("MyAwesomeImage.jpeg");
52  * r.Open(); // Open the reader
53  *
54  * // Get frame number 1 from the video
55  * std::shared_ptr<Frame> f = r.GetFrame(1);
56  *
57  * // Now that we have an openshot::Frame object, lets have some fun!
58  * f->Display(); // Display the frame on the screen
59  *
60  * // Close the reader
61  * r.Close();
62  * @endcode
63  */
64  class QtImageReader : public ReaderBase
65  {
66  private:
67  string path;
68  std::shared_ptr<QImage> image; ///> Original image (full quality)
69  std::shared_ptr<QImage> cached_image; ///> Scaled for performance
70  bool is_open;
71 
72  public:
73 
74  /// Constructor for QtImageReader. This automatically opens the media file and loads
75  /// frame 1, or it throws one of the following exceptions.
76  QtImageReader(string path);
77 
78  /// Constructor for QtImageReader. This only opens the media file to inspect it's properties
79  /// if inspect_reader=true. When not inspecting the media file, it's much faster, and useful
80  /// when you are inflating the object using JSON after instantiating it.
81  QtImageReader(string path, bool inspect_reader);
82 
83  /// Close File
84  void Close();
85 
86  /// Get the cache object used by this reader (always returns NULL for this object)
87  CacheMemory* GetCache() { return NULL; };
88 
89  /// Get an openshot::Frame object for a specific frame number of this reader. All numbers
90  /// return the same Frame, since they all share the same image data.
91  ///
92  /// @returns The requested frame (containing the image)
93  /// @param requested_frame The frame number that is requested.
94  std::shared_ptr<Frame> GetFrame(int64_t requested_frame);
95 
96  /// Determine if reader is open or closed
97  bool IsOpen() { return is_open; };
98 
99  /// Return the type name of the class
100  string Name() { return "QtImageReader"; };
101 
102  /// Get and Set JSON methods
103  string Json(); ///< Generate JSON string of this object
104  void SetJson(string value); ///< Load JSON string into this object
105  Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
106  void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
107 
108  /// Open File - which is called by the constructor automatically
109  void Open();
110  };
111 
112 }
113 
114 #endif
Header file for ReaderBase class.
CacheMemory * GetCache()
Get the cache object used by this reader (always returns NULL for this object)
Definition: QtImageReader.h:87
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
Header file for all Exception classes.
string Name()
Return the type name of the class.
bool IsOpen()
Determine if reader is open or closed.
Definition: QtImageReader.h:97
This class uses the Qt library, to open image files, and return openshot::Frame objects containing th...
Definition: QtImageReader.h:64
This class is a memory-based cache manager for Frame objects.
Definition: CacheMemory.h:48