MediaProjection.Callback.OnCapturedContentResize(Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在擷取開始後或捕獲區域大小改變時立即呼叫,提供串流擷取的精確大小。
[Android.Runtime.Register("onCapturedContentResize", "(II)V", "GetOnCapturedContentResize_IIHandler", ApiSince=34)]
public virtual void OnCapturedContentResize(int width, int height);
[<Android.Runtime.Register("onCapturedContentResize", "(II)V", "GetOnCapturedContentResize_IIHandler", ApiSince=34)>]
abstract member OnCapturedContentResize : int * int -> unit
override this.OnCapturedContentResize : int * int -> unit
參數
- width
- Int32
捕捉區域的寬度,以像素為單位。
- height
- Int32
捕捉區域的高度,以像素為單位。
- 屬性
備註
在擷取開始後或捕獲區域大小改變時立即呼叫,提供串流擷取的精確大小。
給定的寬度與高度(像素數)對應於捕捉區域回傳 Bounds 的寬度與高度。
如果錄製的內容與輸出VirtualDisplay的長寬比Surface不同,擷取的串流會被黑邊(letterboxing)包圍。 應用程式可透過更新 與 VirtualDisplay 輸出 Surface大小,避免錄製內容周圍的信箱黑邊:
@Override
public void onCapturedContentResize(int width, int height) {
// VirtualDisplay instance from MediaProjection#createVirtualDisplay
virtualDisplay.resize(width, height, dpi);
// Create a new Surface with the updated size (depending on the application's use
// case, this may be through different APIs - see Surface documentation for
// options).
int texName; // the OpenGL texture object name
SurfaceTexture surfaceTexture = new SurfaceTexture(texName);
surfaceTexture.setDefaultBufferSize(width, height);
Surface surface = new Surface(surfaceTexture);
// Ensure the VirtualDisplay has the updated Surface to send the capture to.
virtualDisplay.setSurface(surface);
}
Java 文件 android.media.projection.MediaProjection.Callback.onCapturedContentResize(int, int)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。