Merge pull request #297 from Palakis/bugfix/242-getsceneitemproperties-item-size

GetSceneItemProperties: add width & height values
This commit is contained in:
Stéphane Lepin 2019-04-19 18:07:34 +02:00 committed by GitHub
commit 92938d2c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -592,8 +592,20 @@ bool Utils::SetFilenameFormatting(const char* filenameFormatting) {
* @property {int} `bounds.alignment` Alignment of the bounding box. * @property {int} `bounds.alignment` Alignment of the bounding box.
* @property {double} `bounds.x` Width of the bounding box. * @property {double} `bounds.x` Width of the bounding box.
* @property {double} `bounds.y` Height of the bounding box. * @property {double} `bounds.y` Height of the bounding box.
* @property {int} `sourceWidth` Base width (without scaling) of the source
* @property {int} `sourceHeight` Base source (without scaling) of the source
* @property {double} `width` Scene item width (base source width multiplied by the horizontal scaling factor)
* @property {double} `height` Scene item height (base source height multiplied by the vertical scaling factor)
*/ */
obs_data_t* Utils::GetSceneItemPropertiesData(obs_sceneitem_t* sceneItem) { obs_data_t* Utils::GetSceneItemPropertiesData(obs_sceneitem_t* sceneItem) {
if (!sceneItem) {
return nullptr;
}
OBSSource source = obs_sceneitem_get_source(sceneItem);
uint32_t baseSourceWidth = obs_source_get_width(source);
uint32_t baseSourceHeight = obs_source_get_height(source);
vec2 pos, scale, bounds; vec2 pos, scale, bounds;
obs_sceneitem_crop crop; obs_sceneitem_crop crop;
@ -639,5 +651,10 @@ obs_data_t* Utils::GetSceneItemPropertiesData(obs_sceneitem_t* sceneItem) {
obs_data_set_bool(data, "visible", isVisible); obs_data_set_bool(data, "visible", isVisible);
obs_data_set_obj(data, "bounds", boundsData); obs_data_set_obj(data, "bounds", boundsData);
obs_data_set_int(data, "sourceWidth", baseSourceWidth);
obs_data_set_int(data, "sourceHeight", baseSourceHeight);
obs_data_set_double(data, "width", baseSourceWidth * scale.x);
obs_data_set_double(data, "height", baseSourceHeight * scale.y);
return data; return data;
} }

View File

@ -25,6 +25,10 @@
* @return {int} `bounds.alignment` Alignment of the bounding box. * @return {int} `bounds.alignment` Alignment of the bounding box.
* @return {double} `bounds.x` Width of the bounding box. * @return {double} `bounds.x` Width of the bounding box.
* @return {double} `bounds.y` Height of the bounding box. * @return {double} `bounds.y` Height of the bounding box.
* @return {int} `sourceWidth` Base width (without scaling) of the source
* @return {int} `sourceHeight` Base source (without scaling) of the source
* @return {double} `width` Scene item width (base source width multiplied by the horizontal scaling factor)
* @return {double} `height` Scene item height (base source height multiplied by the vertical scaling factor)
* *
* @api requests * @api requests
* @name GetSceneItemProperties * @name GetSceneItemProperties