• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_ComponentSnapshot
2
3
4## Overview
5
6Provides APIs for obtaining component snapshots.
7
8**Since**: 15
9
10## Summary
11
12### Structs
13
14| Name| Description|
15| -------- | -------- |
16| struct  [ArkUI_SnapshotOptions](native__type_8h.md#ArkUI_SnapshotOptions) | Defines a struct for snapshot options.|
17
18### Functions
19
20| Name| Description|
21| -------- | -------- |
22| int32_t [OH_ArkUI_GetNodeSnapshot](native__node_8h.md#OH_ArkUI_GetNodeSnapshot) () | Obtains a snapshot of a given component. If the node is not in the component tree or has not been rendered, the snapshot operation will fail. When the **Pixelmap** object created is no longer in use, it should be released by calling **OH_PixelmapNative_Release**.|
23| ArkUI_SnapshotOptions [OH_ArkUI_CreateSnapshotOptions](native__type_8h.md#OH_ArkUI_CreateSnapshotOptions) () | Creates a snapshot options object, which must be released using **OH_ArkUI_SnapshotOptions_Dispose** when no longer in use.|
24| void [OH_ArkUI_DestroySnapshotOptions](native__type_8h.md#OH_ArkUI_DestroySnapshotOptions) () | Destroys a snapshot options object.|
25| int32_t [OH_ArkUI_SnapshotOptions_SetScale](native__type_8h.md#OH_ArkUI_SnapshotOptions_SetScale) () | Sets the scale property in the snapshot options.|
26
27### Creates a snapshot options object.
28
29## Type Description
30
31### ArkUI_SnapshotOptions
32
33```
34typedef struct ArkUI_SnapshotOptions ArkUI_SnapshotOptions;
35```
36
37**Description**
38
39Defines a struct for snapshot options.
40
41**Since**: 15
42
43## Function Description
44
45### OH_ArkUI_GetNodeSnapshot()
46
47```
48int32_t OH_ArkUI_GetNodeSnapshot(ArkUI_NodeHandle node, ArkUI_SnapshotOptions* snapshotOptions,
49    OH_PixelmapNative** pixelMap)
50```
51
52**Description**
53
54Obtains a snapshot of the specified node.
55
56**Since**: 15
57
58**Parameters**
59
60| Name         |  Description                                                    |
61| --------------- | ------------------------------------------------------------ |
62| node            | Target node to capture a snapshot.                                            |
63| snapshotOptions | Snapshot settings. If the value is null, the default settings are used.             |
64| pixelmap        | Pointer to the Pixelmap created by the system.|
65
66**Returns**
67
68| Return Value                                       | Description          |
69| --------------------------------------------- | -------------- |
70| `ARKUI_ERROR_CODE_NO_ERROR`                   | Success.    |
71| `ARKUI_ERROR_CODE_PARAM_INVALID`              | Parameter error.   |
72| `ARKUI_ERROR_CODE_INTERNAL_ERROR`             | Snapshot failed. A null pointer is returned.    |
73| `ARKUI_ERROR_CODE_COMPONENT_SNAPSHOT_TIMEOUT` | Snapshot timed out.|
74
75
76### OH_ArkUI_CreateSnapshotOptions()
77
78```
79ArkUI_SnapshotOptions* OH_ArkUI_CreateSnapshotOptions()
80```
81
82**Description**
83
84Creates a snapshot options object, which must be released using **OH_ArkUI_SnapshotOptions_Dispose** when no longer in use.
85
86**Since**: 15
87
88**Returns**
89
90| Return Value                  | Description                                                        |
91| ------------------------ | ------------------------------------------------------------ |
92| `ArkUI_SnapshotOptions*` | Pointer to the created snapshot options object. If a null pointer is returned, creation failed, possibly due to insufficient memory.|
93
94
95### OH_ArkUI_DestroySnapshotOptions()
96
97```
98void OH_ArkUI_DestroySnapshotOptions(ArkUI_SnapshotOptions* snapshotOptions)
99```
100
101**Description**
102
103Destroys a snapshot options object.
104
105**Since**: 15
106
107**Parameters**
108
109| Name        | Description        |
110| --------------- | ---- |
111| snapshotOptions | Screenshot options.|
112
113### OH_ArkUI_SnapshotOptions_SetScale()
114
115```
116int32_t OH_ArkUI_SnapshotOptions_SetScale(ArkUI_SnapshotOptions* snapshotOptions, float scale)
117```
118
119**Description**
120
121Sets the scale property in the snapshot options.
122
123**Since**: 15
124
125**Parameters**
126
127| Name| Description|
128| -------- | -------- |
129| snapshotOptions | Screenshot options.|
130| scale           | Scale factor.|
131
132**Returns**
133
134| Return Value                          | Description      |
135| -------------------------------- | ---------- |
136| `ARKUI_ERROR_CODE_NO_ERROR`      | Success.|
137| `ARKUI_ERROR_CODE_PARAM_INVALID` | Parameter error.<br> A possible cause is that mandatory parameters are left unspecified.|
138