obs obs_transform_info數據結構解析

今天端午節,中午烙了好久沒喫到的韭菜餡兒盒子,晚上嘗試自己包了糉子,雖然翻車了,還是挺開心的,啊,好睏~

obs中有obs_sceneitem_set_info函數用來設置場景項信息,這個轉換信息就是今天學習的這個數據結構。

官方幫助手冊上的信息:

Scene Item Transform Structure (obs_transform_info)¶
struct obs_transform_info
Scene item transform structure.

struct vec2 obs_transform_info.pos
Position.

float obs_transform_info.rot
Rotation (degrees).

struct vec2 obs_transform_info.scale
Scale.

uint32_t obs_transform_info.alignment
The alignment of the scene item relative to its position.

Can be 0 or a bitwise OR combination of one of the following values:

OBS_ALIGN_CENTER
OBS_ALIGN_LEFT
OBS_ALIGN_RIGHT
OBS_ALIGN_TOP
OBS_ALIGN_BOTTOM
enum obs_bounds_type obs_transform_info.bounds_type
Can be one of the following values:

OBS_BOUNDS_NONE - No bounding box
OBS_BOUNDS_STRETCH - Stretch to the bounding box without preserving aspect ratio
OBS_BOUNDS_SCALE_INNER - Scales with aspect ratio to inner bounding box rectangle
OBS_BOUNDS_SCALE_OUTER - Scales with aspect ratio to outer bounding box rectangle
OBS_BOUNDS_SCALE_TO_WIDTH - Scales with aspect ratio to the bounding box width
OBS_BOUNDS_SCALE_TO_HEIGHT - Scales with aspect ratio to the bounding box height
OBS_BOUNDS_MAX_ONLY - Scales with aspect ratio, but only to the size of the source maximum
uint32_t obs_transform_info.bounds_alignment
The alignment of the source within the bounding box.

Can be 0 or a bitwise OR combination of one of the following values:

OBS_ALIGN_CENTER
OBS_ALIGN_LEFT
OBS_ALIGN_RIGHT
OBS_ALIGN_TOP
OBS_ALIGN_BOTTOM
struct vec2 obs_transform_info.bounds
The bounding box (if a bounding box is enabled).

.pos,.bounds好理解,即場景項在輸出output中佔據的矩陣位置,當然可能不是實際全都填充上。

.alignment咋眼看上去不好理解,它描述的其實是.pos這個起始位置相對於場景項的位置,最簡單的一種位置關係是left | top,示意圖如下:

如果設置這個值爲left | bottom,那麼位置就變成了這樣:

那麼sceneItem就有看不到的可能。

.rot即旋轉角度

.bounds_type 和  .bounds_alignment即通常意義上的填充規則的語義了。當源的寬高比例和這個矩形的寬高比例不一致時,這兩個選項就有了意義。

舉兩個例子吧。假如output和信號源的分辨率都是1280*720,但是場景設置的信號源rect是(0,0,1280,720*3/4),那麼當

.bounds_type爲scale_to_height,.bounds_alignment爲right時,佈局如下圖:

stretch是直接不保持比例進行填充。

.bounds_type爲scale_to_width,.bounds_alignment爲bottom時,佈局如下圖:

即信號源有一部分是處於output之上看不到的。此時如果設置alignment爲top的話,信號源會充滿整個output;center則是這兩種極端情況的中間位置。

難理解的情況應該是都說了,inner,outer和max_only的情況下次再說吧。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章