• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (Macro)
2<!--Kit: Camera Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @qano-->
5<!--SE: @leo_ysl-->
6<!--TSE: @xchaosioda-->
7
8> **NOTE**
9>
10> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
11> - The initial APIs of this interface are supported since API version 19.
12
13Macro inherits from [MacroQuery](arkts-apis-camera-MacroQuery.md).
14
15It provides the API to enable macro photography.
16
17## Modules to Import
18
19```ts
20import { camera } from '@kit.CameraKit';
21```
22
23## enableMacro<sup>19+</sup>
24
25enableMacro(enabled: boolean): void
26
27Enables or disables macro photography. This API can be called only when macro photography is supported.
28
29**Atomic service API**: This API can be used in atomic services since API version 19.
30
31**System capability**: SystemCapability.Multimedia.Camera.Core
32
33**Parameters**
34
35| Name    | Type                  | Mandatory| Description                 |
36| -------- | -------------------- | ---- | -------------------- |
37| enabled | boolean | Yes  | Whether to enable macro photography. **true** to enable, **false** otherwise.|
38
39**Error codes**
40
41For details about the error codes, see [Camera Error Codes](errorcode-camera.md).
42
43| ID   | Error Message                    |
44|----------|--------------------------|
45| 7400102  | Operation not allowed.   |
46| 7400103  | Session not config.      |
47
48**Example**
49
50```ts
51function enableMacro(photoSession: camera.PhotoSession): void {
52  let isSupported: boolean = photoSession.isMacroSupported();
53  if (isSupported) {
54    photoSession.enableMacro(true);
55  }
56}
57```
58