5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <dali/public-api/actors/camera-actor.h>
32 * @addtogroup dali_adaptor_framework
36 namespace Internal DALI_INTERNAL
45 * @brief Capture snapshots the current scene and save as a file.
49 * Applications should follow the example below to create capture :
52 * Capture capture = Capture::New();
55 * If required, you can also connect class member function to a signal :
58 * capture.FinishedSignal().Connect(this, &CaptureSceneExample::OnCaptureFinished);
61 * At the connected class member function, you can know whether capture finish state.
64 * void CaptureSceneExample::OnCaptureFinished( Capture capture, Capture::FinishState state )
66 * if ( state == Capture::FinishState::SUCCEEDED )
77 class DALI_IMPORT_API Capture : public BaseHandle
83 * @brief The enumerations used for checking capture success
86 enum class FinishState
88 SUCCEEDED, ///< Succeeded in saving the result after capture
89 FAILED ///< Failed to capture by time out or to save the result
93 * @brief Typedef for finished signals sent by this class.
97 typedef Signal< void ( Capture, Capture::FinishState ) > CaptureFinishedSignalType;
100 * @brief Create an uninitialized Capture; this can be initialized with Actor::New().
104 * Calling member functions with an uninitialized Dali::Object is not allowed.
109 * @PRIVLEVEL_PLATFORM
110 * @brief Create an initialized Capture.
115 * @return A handle to a newly allocated Dali resource.
116 * @note Projection mode of default cameraActor is Dali::Camera::PERSPECTIVE_PROJECTION
117 * @note If permission denied by privilege occurs, a uninitialized handle is returned
119 static Capture New();
122 * @PRIVLEVEL_PLATFORM
123 * @brief Create an initialized Capture.
128 * @param[in] cameraActor An initialized CameraActor.
129 * @return A handle to a newly allocated Dali resource.
130 * @note If permission denied by privilege occurs, a uninitialized handle is returned
132 static Capture New( Dali::CameraActor cameraActor );
135 * @brief Downcast an Object handle to Capture handle.
139 * If handle points to a Capture object the downcast produces valid
140 * handle. If not the returned handle is left uninitialized.
142 * @param[in] handle to An object.
143 * @return handle to a Capture object or an uninitialized handle.
145 static Capture DownCast( BaseHandle handle );
148 * @brief Dali::Actor is intended as a base class.
152 * This is non-virtual since derived Handle types must not contain data or virtual methods.
157 * @brief This copy constructor is required for (smart) pointer semantics.
161 * @param[in] copy A reference to the copied handle.
163 Capture( const Capture& copy );
166 * @brief This assignment operator is required for (smart) pointer semantics.
170 * @param[in] rhs A reference to the copied handle.
171 * @return A reference to this.
173 Capture& operator=( const Capture& rhs );
176 * @brief Start capture and save the image as a file.
180 * @param[in] source source actor to be used for capture.
181 * @param[in] size captured size.
182 * @param[in] path image file path to be saved as a file.
183 * @param[in] clearColor background color of captured scene
185 void Start( Actor source, const Vector2& size, const std::string &path, const Vector4& clearColor );
188 * @brief Start capture and save the image as a file.
192 * @param[in] source source actor to be used for capture.
193 * @param[in] size captured size.
194 * @param[in] path image file path to be saved as a file.
195 * @note Clear color is transparent.
197 void Start( Actor source, const Vector2& size, const std::string &path );
200 * @brief Get finished signal.
204 * @return finished signal instance.
206 CaptureFinishedSignalType& FinishedSignal();
208 public: // Not intended for application developers
210 * @brief This constructor is used by New() methods.
214 * @param[in] internal A pointer to a newly allocated Dali resource.
216 explicit DALI_INTERNAL Capture( Internal::Adaptor::Capture* internal );
225 #endif // DALI_CAPTURE_H