Screenshot
Since: BlackBerry 10.2.0
#include <bb/system/Screenshot>
To link against this class, add the following line to your .pro file: LIBS += -lbbsystem
Allows an application to capture the contents of the display or the application window and save it to a file.
When capturing the display, the image is saved to the camera roll (a sequentially numbered image available in the Pictures application, just like taking a picture with the camera) in any one of the formats specified by ScreenshotFormat.
Overview
Public Functions Index
Screenshot (QObject *parent=0) | |
virtual | ~Screenshot () |
Q_INVOKABLE QString | captureDisplay () |
Q_INVOKABLE QString | captureDisplay (const QUrl &filePath) |
Q_INVOKABLE QString | captureDisplay (bb::system::ScreenshotFormat::Type format) |
Q_INVOKABLE QString | captureWindow (const QUrl &filename, screen_window_t window) |
Q_INVOKABLE bb::system::ScreenshotError::Type | error () const |
Public Functions
Creates a new Screenshot object.
Parameters | |
---|---|
parent |
If not 0, the supplied parent will be responsible for deleting this instance. |
BlackBerry 10.2.0
virtual
Destructor.
BlackBerry 10.2.0
Q_INVOKABLE QString
Captures the display to the camera roll.
Captures the display to a file with an autogenerated name in PNG format.
The absolute path to the file containing the image that was captured. If an error occurs, the method returns an empty string and the error method must be called to determine the reason for the failure.
bb::system::Screenshot screenshot; QString filename = screenshot.captureDisplay(); if (filename.isEmpty()) { // Something went wrong bb::system::ScreenshotError::Type error = screenshot.error(); }Capturing screenshot in QML:
import bb.cascades 1.0 import bb.system 1.2 Page { attachedObjects: [ Screenshot { id: screenshot } ] content: Container { Label { id: filenameLabel } Button { id: captureButton text: "Capture" onClicked: { filenameLabel.text = screenshot.captureDisplay(); } } } }
The application must have the use_camera_desktop and access_shared permissions to use this feature.
BlackBerry 10.2.0
Q_INVOKABLE QString
Captures the display to the camera roll.
Captures the display to a file with the supplied name. The format of the image is inferred from the filename. The filePath can be supplied as an absolute filename, or using a schema, such as "file:data/screenshot.png".
Parameters | |
---|---|
filePath |
The target filename to which the captured image will be written. The extension of this filename will determine the image format of the screen capture. |
The absolute path to the file containing the image that was captured. If an error occurs, the method returns an empty string and the error method must be called to determine the reason for the failure.
bb::system::Screenshot screenshot; QString filename = screenshot.captureDisplay( "file:data/screenshot.png" ); if (filename.isEmpty()) { // Something went wrong bb::system::ScreenshotError::Type error = screenshot.error(); }Capturing screenshot in QML:
import bb.cascades 1.0 import bb.system 1.2 Page { attachedObjects: [ Screenshot { id: screenshot } ] content: Container { Label { id: filenameLabel } Button { id: captureButton text: "Capture" onClicked: { filenameLabel.text = screenshot.captureDisplay( "file:data/screenshot.png" ); } } } }
The application must have the use_camera_desktop and access_shared permissions to use this feature.
BlackBerry 10.2.0
Q_INVOKABLE QString
Captures the display to the camera roll in the supplied format.
Captures the display to a file with an autogenerated name in the supplied image format. See bb::system::ScreenshotFormat for the list of supported formats.
Parameters | |
---|---|
format |
The format of the resulting file, such as PNG or JPEG. One of bb::system::ScreenshotFormat. |
The absolute path to the file containing the image that was captured. If an error occurs, the method returns an empty string and the error method must be called to determine the reason for the failure.
bb::system::Screenshot screenshot; QString filename = screenshot.captureDisplay( bb::system::ScreenshotFormat::Jpeg ); if (filename.isEmpty()) { // Something went wrong bb::system::ScreenshotError::Type error = screenshot.error(); }Capturing screenshot in QML:
import bb.cascades 1.0 import bb.system 1.2 Page { attachedObjects: [ Screenshot { id: screenshot } ] content: Container { Label { id: filenameLabel } Button { id: captureButton text: "Capture" onClicked: { filenameLabel.text = screenshot.captureDisplay( ScreenshotFormat.Jpeg ); } } } }
The application must have the use_camera_desktop and access_shared permissions to use this feature.
BlackBerry 10.2.0
Q_INVOKABLE QString
Captures the application window to the supplied filename.
The captured image will be written in the format specified by the filename. (For example, if the filename was "file:data/screenshot.png" the file would be written as a PNG format image.)
Parameters | |
---|---|
filename |
The path to which the file will be captured. |
window |
The handle of the application window to be captured. |
The absolute path to the file containing the image that was captured. If an error occurs, the method returns an empty string and the error method must be called to determine the reason for the failure.
bb::system::Screenshot screenshot; QString filename = screenshot.captureWindow( "file:data/screenshot.png", Application::instance()->mainWindow()->handle() ); if (filename.isEmpty()) { // Something went wrong bb::system::ScreenshotError::Type error = screenshot.error(); }Capturing screenshot in QML:
import bb.cascades 1.0 import bb.system 1.2 Page { attachedObjects: [ Screenshot { id: screenshot } ] content: Container { Label { id: filenameLabel } Button { id: captureButton text: "Capture" onClicked: { filenameLabel.text = screenshot.captureWindow( "file:data/screenshot.png", Application.mainWindow.handle ); } } } }
BlackBerry 10.2.0
Q_INVOKABLE bb::system::ScreenshotError::Type
Gets the result for the last captureDisplay or captureWindow request.
The result of the last captureDisplay or captureWindow request. See bb::system::ScreenshotError for a list of possible results.
BlackBerry 10.2.0