TakeSourceScreenshot: direct file save

This commit is contained in:
Stéphane Lepin 2019-05-03 19:14:17 +02:00
parent d46c1f8687
commit 53b9a46feb

View File

@ -1345,6 +1345,7 @@ HandlerResponse WSRequestHandler::HandleSetSourceFilterSettings(WSRequestHandler
*
* @param {String} `sourceName` Source name
* @param {String} `pictureFormat` Format of the encoded picture. Can be "png", "jpg", "jpeg" or "bmp" (or any other value supported by Qt's Image module)
* @param {String (optional)} `saveToFilePath` Full file path (file extension included) where the captured image is to be saved. Can be in a format different from `pictureFormat`.
* @param {int (optional)} `width` Screenshot width. Defaults to the source's base width.
* @param {int (optional)} `height` Screenshot height. Defaults to the source's base height.
*
@ -1454,6 +1455,11 @@ HandlerResponse WSRequestHandler::HandleTakeSourceScreenshot(WSRequestHandler* r
sourceImage.save(&buffer, pictureFormat);
buffer.close();
if (req->hasField("saveToFilePath")) {
QString imageFilePath = obs_data_get_string(req->data, "saveToFilePath");
sourceImage.save(imageFilePath);
}
QString imgBase64(encodedImgBytes.toBase64());
imgBase64.prepend(
QString("data:image/%1;base64,").arg(pictureFormat)