# TakeSnapshot [2/2] (/zh-CN/api-reference/rtc/csharp-windows/api-irtcengine-takesnapshot2)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

<a id="api_irtcengine_takesnapshot2__prototype"></a>

```csharp
 public abstract int TakeSnapshot(uint uid, SnapshotConfig config);
```

<a id="api_irtcengine_takesnapshot2__detailed_desc"></a>

该方法用于对指定用户的视频流进行截图，生成一张 JPG 格式的图片，并保存至指定的路径。

<a id="api_irtcengine_takesnapshot2__timing"></a>

## 调用时机 [#调用时机]

该方法需要在加入频道后调用。

<a id="api_irtcengine_takesnapshot2__restriction"></a>

## 调用限制 [#调用限制]

- 该方法是异步操作，调用返回时 SDK 并没有真正获取截图。
- 该方法用于本地视频截图时，是对 [ChannelMediaOptions](/zh-CN/api-reference/rtc/csharp-windows/class-channelmediaoptions) 中指定发布的视频流进行截图。

<a id="api_irtcengine_takesnapshot2__related"></a>

## 相关回调 [#相关回调]

成功调用该方法后，SDK 会触发 [OnSnapshotTaken](/zh-CN/api-reference/rtc/csharp-windows/video/video-prenpro/snapshot#callback_irtcengineeventhandler_onsnapshottaken) 回调，报告截图是否成功和获取截图的详情。

<a id="api_irtcengine_takesnapshot2__parameters"></a>

## 参数 [#参数]

<ParameterList>
<a id="uid"></a>
<Parameter name="uid">

用户 ID。如果要对本地用户的视频截图，则设为 0。

</Parameter>
<a id="config"></a>
<Parameter name="config">

截图设置，详见 [SnapshotConfig](/zh-CN/api-reference/rtc/csharp-windows/class-snapshotconfig)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_takesnapshot2__return_values"></a>

## 返回值 [#返回值]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。
