• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.wallpaper (Wallpaper) (System API)
2
3The **wallpaper** module provides APIs for switching between wallpapers. Since API version 9, the APIs of this module function as system APIs, and only system applications are allowed to switch between wallpapers. Applications that use the wallpaper, for example, the home screen, need to subscribe to wallpaper changes and update the wallpaper accordingly.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md).
9
10
11## Modules to Import
12
13
14```ts
15import wallpaper from '@ohos.wallpaper';
16```
17## WallpaperResourceType<sup>10+</sup>
18
19Enumerates the types of wallpaper resources.
20
21**System capability**: SystemCapability.MiscServices.Wallpaper
22
23**System API**: This is a system API.
24
25| Name| Value|Description|
26| -------- | -------- |-------- |
27| DEFAULT | 0 |Default type (image resource).|
28| PICTURE | 1 |Image resource.|
29| VIDEO | 2 |Video resource.|
30| PACKAGE | 3 |Package resource.|
31
32## wallpaper.setVideo<sup>10+</sup>
33
34setVideo(source: string, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
35
36Sets a video resource as the home screen wallpaper or lock screen wallpaper. This API uses an asynchronous callback to return the result.
37
38**Required permissions**: ohos.permission.SET_WALLPAPER
39
40**System capability**: SystemCapability.MiscServices.Wallpaper
41
42**System API**: This is a system API.
43
44**Parameters**
45
46| Name| Type| Mandatory| Description|
47| -------- | -------- | -------- | -------- |
48| source | string | Yes| URI of an MP4 file.|
49| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
50| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
51
52**Example**
53
54```ts
55import { BusinessError } from '@ohos.base';
56
57let wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.mp4";
58try {
59    wallpaper.setVideo(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
60        if (error) {
61            console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
62            return;
63        }
64        console.log(`success to setVideo.`);
65    });
66} catch (error) {
67    console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
68}
69
70```
71
72## wallpaper.setVideo<sup>10+</sup>
73
74setVideo(source: string, wallpaperType: WallpaperType): Promise&lt;void&gt;
75
76Sets a video resource as the home screen wallpaper or lock screen wallpaper. This API uses a promise to return the result.
77
78**Required permissions**: ohos.permission.SET_WALLPAPER
79
80**System capability**: SystemCapability.MiscServices.Wallpaper
81
82**System API**: This is a system API.
83
84**Parameters**
85
86| Name| Type| Mandatory| Description|
87| -------- | -------- | -------- | -------- |
88| source | string | Yes| URI of an MP4 file.|
89| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
90
91**Return value**
92
93| Type| Description|
94| -------- | -------- |
95| Promise&lt;void&gt; | Promise that returns no value.|
96
97**Example**
98
99```ts
100import { BusinessError } from '@ohos.base';
101
102let wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.mp4";
103try {
104    wallpaper.setVideo(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
105        console.log(`success to setVideo.`);
106    }).catch((error: BusinessError) => {
107        console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
108    });
109} catch (error) {
110    console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
111}
112```
113
114## wallpaper.setCustomWallpaper<sup>10+</sup>
115
116setCustomWallpaper(source: string, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
117
118Sets a specific ZIP file as the wallpaper. This API works only when **com.ohos.sceneboard** is set. Applications with the **ohos.permission.GET_WALLPAPER** permission have access to the **/data/wallpaper/** directory. This API uses an asynchronous callback to return the result.
119
120**Required permissions**: ohos.permission.SET_WALLPAPER
121
122**System capability**: SystemCapability.MiscServices.Wallpaper
123
124**System API**: This is a system API.
125
126**Parameters**
127
128| Name| Type| Mandatory| Description|
129| -------- | -------- | -------- | -------- |
130| source | string | Yes| ZIP file to set as the wallpaper.|
131| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
132| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
133
134**Example**
135
136```ts
137import { BusinessError } from '@ohos.base';
138
139let wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.zip";
140try {
141    wallpaper.setCustomWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
142        if (error) {
143            console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
144            return;
145        }
146        console.log(`success to setCustomWallpaper.`);
147    });
148} catch (error) {
149    console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
150}
151
152```
153
154## wallpaper.setCustomWallpaper<sup>10+</sup>
155
156setCustomWallpaper(source: string, wallpaperType: WallpaperType): Promise&lt;void&gt;
157
158Sets a specific ZIP file as the wallpaper. This API works only when **com.ohos.sceneboard** is set. Applications with the **ohos.permission.GET_WALLPAPER** permission have access to the **/data/wallpaper/** directory. This API uses a promise to return the result.
159
160**Required permissions**: ohos.permission.SET_WALLPAPER
161
162**System capability**: SystemCapability.MiscServices.Wallpaper
163
164**System API**: This is a system API.
165
166**Parameters**
167
168| Name| Type| Mandatory| Description|
169| -------- | -------- | -------- | -------- |
170| source | string | Yes| ZIP file to set as the wallpaper.|
171| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
172
173**Return value**
174
175| Type| Description|
176| -------- | -------- |
177| Promise&lt;void&gt; | Promise that returns no value.|
178
179**Example**
180
181```ts
182import { BusinessError } from '@ohos.base';
183
184let wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.zip";
185try {
186    wallpaper.setCustomWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
187        console.log(`success to setCustomWallpaper.`);
188    }).catch((error: BusinessError) => {
189        console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
190    });
191} catch (error) {
192    console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
193}
194```
195
196## wallpaper.on('wallpaperChange')<sup>10+</sup>
197
198on(type: 'wallpaperChange', callback: (wallpaperType: WallpaperType, resourceType: WallpaperResourceType, uri?: string) =&gt; void): void
199
200Subscribes to wallpaper change events.
201
202**System capability**: SystemCapability.MiscServices.Wallpaper
203
204**System API**: This is a system API.
205
206**Parameters**
207
208| Name| Type| Mandatory| Description|
209| -------- | -------- | -------- | -------- |
210| type | string | Yes| Event type. The value is fixed at **'wallpaperChange'**.|
211| callback | function | Yes| Callback used to return the wallpaper type and wallpaper resource type.<br>- **wallpaperType**: wallpaper type.<br>- **resourceType**: wallpaper resource type.<br>- **uri**: URI of the wallpaper resource.|
212
213**Example**
214
215```ts
216try {
217    let listener = (wallpaperType: wallpaper.WallpaperType, resourceType: wallpaper.WallpaperResourceType): void => {
218        console.log(`wallpaper color changed.`);
219    };
220    wallpaper.on('wallpaperChange', listener);
221} catch (error) {
222    console.error(`failed to on because: ${JSON.stringify(error)}`);
223}
224```
225
226## wallpaper.off('wallpaperChange')<sup>10+</sup>
227
228off(type: 'wallpaperChange', callback?: (wallpaperType: WallpaperType, resourceType: WallpaperResourceType, uri?: string) =&gt; void): void
229
230Unsubscribes from wallpaper change events.
231
232**System capability**: SystemCapability.MiscServices.Wallpaper
233
234**System API**: This is a system API.
235
236**Parameters**
237
238| Name| Type| Mandatory| Description|
239| -------- | -------- | -------- | -------- |
240| type | string | Yes| Event type. The value is fixed at **'wallpaperChange'**.|
241| callback | function | No|   Callback used for unsubscription. If this parameter is not set, this API unsubscribes from all callbacks of the specified event type.<br>- **wallpaperType**: wallpaper type.<br>- **resourceType**: wallpaper resource type.<br>- **uri**: URI of the wallpaper resource.|
242
243**Example**
244
245```ts
246let listener = (wallpaperType: wallpaper.WallpaperType, resourceType: wallpaper.WallpaperResourceType): void => {
247    console.log(`wallpaper color changed.`);
248};
249try {
250    wallpaper.on('wallpaperChange', listener);
251} catch (error) {
252    console.error(`failed to on because: ${JSON.stringify(error)}`);
253}
254
255try {
256    // Unsubscribe from the listener.
257    wallpaper.off('wallpaperChange', listener);
258} catch (error) {
259    console.error(`failed to off because: ${JSON.stringify(error)}`);
260}
261
262try {
263    // Unsubscribe from all callbacks of the 'wallpaperChange' event type.
264    wallpaper.off('wallpaperChange');
265} catch (error) {
266    console.error(`failed to off because: ${JSON.stringify(error)}`);
267}
268```
269
270## wallpaper.getColorsSync<sup>9+</sup>
271
272getColorsSync(wallpaperType: WallpaperType): Array&lt;RgbaColor&gt;
273
274Obtains the main color information of the wallpaper of the specified type.
275
276**System capability**: SystemCapability.MiscServices.Wallpaper
277
278**System API**: This is a system API.
279
280**Parameters**
281
282| Name| Type| Mandatory| Description|
283| -------- | -------- | -------- | -------- |
284| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
285
286**Return value**
287
288| Type| Description|
289| -------- | -------- |
290| Array&lt;[RgbaColor](js-apis-wallpaper.md#rgbacolordeprecated)&gt; | Promise used to return the main color information of the wallpaper.|
291
292**Example**
293
294```ts
295try {
296    let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM);
297    console.log(`success to getColorsSync: ${JSON.stringify(colors)}`);
298} catch (error) {
299    console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`);
300}
301```
302
303## wallpaper.getMinHeightSync<sup>9+</sup>
304
305getMinHeightSync(): number
306
307Obtains the minimum height of this wallpaper.
308
309**System capability**: SystemCapability.MiscServices.Wallpaper
310
311**System API**: This is a system API.
312
313**Return value**
314
315| Type| Description|
316| -------- | -------- |
317| number | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead.|
318
319**Example**
320
321```ts
322let minHeight = wallpaper.getMinHeightSync();
323```
324
325## wallpaper.getMinWidthSync<sup>9+</sup>
326
327getMinWidthSync(): number
328
329Obtains the minimum width of this wallpaper.
330
331**System capability**: SystemCapability.MiscServices.Wallpaper
332
333**System API**: This is a system API.
334
335**Return value**
336
337| Type| Description|
338| -------- | -------- |
339| number | Promise used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead.|
340
341**Example**
342
343```ts
344let minWidth = wallpaper.getMinWidthSync();
345```
346
347## wallpaper.restore<sup>9+</sup>
348
349restore(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
350
351Resets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result.
352
353**Required permissions**: ohos.permission.SET_WALLPAPER
354
355**System capability**: SystemCapability.MiscServices.Wallpaper
356
357**System API**: This is a system API.
358
359**Parameters**
360
361| Name| Type| Mandatory| Description|
362| -------- | -------- | -------- | -------- |
363| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
364| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is reset, **err** is **undefined**. Otherwise, **err** is an error object.|
365
366**Example**
367
368```ts
369import { BusinessError } from '@ohos.base';
370
371wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
372    if (error) {
373        console.error(`failed to restore because: ${JSON.stringify(error)}`);
374        return;
375    }
376    console.log(`success to restore.`);
377});
378```
379
380## wallpaper.restore<sup>9+</sup>
381
382restore(wallpaperType: WallpaperType): Promise&lt;void&gt;
383
384Resets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result.
385
386**Required permissions**: ohos.permission.SET_WALLPAPER
387
388**System capability**: SystemCapability.MiscServices.Wallpaper
389
390**System API**: This is a system API.
391
392**Parameters**
393
394| Name| Type| Mandatory| Description|
395| -------- | -------- | -------- | -------- |
396| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
397
398**Return value**
399
400| Type| Description|
401| -------- | -------- |
402| Promise&lt;void&gt; | Promise that returns no value.|
403
404**Example**
405
406```ts
407import { BusinessError } from '@ohos.base';
408
409wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
410    console.log(`success to restore.`);
411  }).catch((error: BusinessError) => {
412    console.error(`failed to restore because: ${JSON.stringify(error)}`);
413});
414```
415
416## wallpaper.setImage<sup>9+</sup>
417
418setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
419
420Sets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result.
421
422**Required permissions**: ohos.permission.SET_WALLPAPER
423
424**System capability**: SystemCapability.MiscServices.Wallpaper
425
426**System API**: This is a system API.
427
428**Parameters**
429
430| Name| Type| Mandatory| Description|
431| -------- | -------- | -------- | -------- |
432| source | string \| [image.PixelMap](../apis-image-kit/js-apis-image.md) | Yes| URI of a JPEG or PNG file, or pixel map of a PNG file.|
433| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
434| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
435
436**Example**
437
438```ts
439import { BusinessError } from '@ohos.base';
440import image from '@ohos.multimedia.image';
441
442// The source type is string.
443let wallpaperPath = "/data/storage/el2/base/haps/entry/files/js.jpeg";
444wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
445    if (error) {
446        console.error(`failed to setImage because: ${JSON.stringify(error)}`);
447        return;
448     }
449    console.log(`success to setImage.`);
450});
451
452// The source type is image.PixelMap.
453let imageSource = image.createImageSource("file://" + wallpaperPath);
454let opts: image.DecodingOptions = {
455    desiredSize: {
456        height: 3648,
457        width: 2736
458    }
459};
460imageSource.createPixelMap(opts).then((pixelMap: image.PixelMap) => {
461    wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
462        if (error) {
463            console.error(`failed to setImage because: ${JSON.stringify(error)}`);
464            return;
465        }
466        console.log(`success to setImage.`);
467    });
468}).catch((error: BusinessError) => {
469    console.error(`failed to createPixelMap because: ${JSON.stringify(error)}`);
470});
471```
472
473## wallpaper.setImage<sup>9+</sup>
474
475setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise&lt;void&gt;
476
477Sets a specified source as the wallpaper of a specified type. This API uses a promise to return the result.
478
479**Required permissions**: ohos.permission.SET_WALLPAPER
480
481**System capability**: SystemCapability.MiscServices.Wallpaper
482
483**System API**: This is a system API.
484
485**Parameters**
486
487| Name| Type| Mandatory| Description|
488| -------- | -------- | -------- | -------- |
489| source | string \| [image.PixelMap](../apis-image-kit/js-apis-image.md) | Yes| URI of a JPEG or PNG file, or pixel map of a PNG file.|
490| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
491
492**Return value**
493
494| Type| Description|
495| -------- | -------- |
496| Promise&lt;void&gt; | Promise that returns no value.|
497
498**Example**
499
500```ts
501import { BusinessError } from '@ohos.base';
502import image from '@ohos.multimedia.image';
503
504// The source type is string.
505let wallpaperPath = "/data/storage/el2/base/haps/entry/files/js.jpeg";
506wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
507    console.log(`success to setImage.`);
508}).catch((error: BusinessError) => {
509    console.error(`failed to setImage because: ${JSON.stringify(error)}`);
510});
511
512// The source type is image.PixelMap.
513let imageSource = image.createImageSource("file://" + wallpaperPath);
514let opts: image.DecodingOptions = {
515    desiredSize: {
516        height: 3648,
517        width: 2736
518    }
519};
520imageSource.createPixelMap(opts).then((pixelMap: image.PixelMap) => {
521    wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
522        console.log(`success to setImage.`);
523    }).catch((error: BusinessError) => {
524        console.error(`failed to setImage because: ${JSON.stringify(error)}`);
525    });
526}).catch((error: BusinessError) => {
527    console.error(`failed to createPixelMap because: ${JSON.stringify(error)}`);
528});
529```
530
531## wallpaper.getImage<sup>9+</sup>
532
533getImage(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
534
535Obtains the pixel map for the wallpaper of the specified type. This API only works for the static wallpaper set using **setImage**. This API uses an asynchronous callback to return the result.
536
537**Required permissions**: ohos.permission.GET_WALLPAPER
538
539**System capability**: SystemCapability.MiscServices.Wallpaper
540
541**System API**: This is a system API.
542
543**Parameters**
544
545| Name| Type| Mandatory| Description|
546| -------- | -------- | -------- | -------- |
547| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
548| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md)&gt; | Yes| Callback used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
549
550**Example**
551
552```ts
553import { BusinessError } from '@ohos.base';
554import image from '@ohos.multimedia.image';
555
556wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError, data: image.PixelMap) => {
557    if (error) {
558        console.error(`failed to getImage because: ${JSON.stringify(error)}`);
559        return;
560    }
561    console.log(`success to getImage: ${JSON.stringify(data)}`);
562});
563```
564
565
566## wallpaper.getImage<sup>9+</sup>
567
568getImage(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
569
570Obtains the pixel map for the wallpaper of the specified type. This API only works for the static wallpaper set using **setImage**. This API uses a promise to return the result.
571
572**Required permissions**: ohos.permission.GET_WALLPAPER
573
574**System capability**: SystemCapability.MiscServices.Wallpaper
575
576**System API**: This is a system API.
577
578**Parameters**
579
580| Name| Type| Mandatory| Description|
581| -------- | -------- | -------- | -------- |
582| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
583
584**Return value**
585
586| Type| Description|
587| -------- | -------- |
588| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md)&gt; | Promise used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
589
590**Example**
591
592```ts
593import { BusinessError } from '@ohos.base';
594import image from '@ohos.multimedia.image';
595
596wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data: image.PixelMap) => {
597    console.log(`success to getImage: ${JSON.stringify(data)}`);
598  }).catch((error: BusinessError) => {
599    console.error(`failed to getImage because: ${JSON.stringify(error)}`);
600});
601```
602
603
604
605## wallpaper.getPixelMap<sup>(deprecated)</sup>
606
607getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
608
609Obtains the pixel map for the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
610
611> **NOTE**
612>
613> This API is supported since API version 7 and deprecated since API version 9.
614
615**Required permissions**: ohos.permission.GET_WALLPAPER
616
617**System capability**: SystemCapability.MiscServices.Wallpaper
618
619**System API**: This is a system API.
620
621**Parameters**
622
623| Name| Type| Mandatory| Description|
624| -------- | -------- | -------- | -------- |
625| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
626| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes| Callback used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
627
628**Example**
629
630```ts
631import { BusinessError } from '@ohos.base';
632import image from '@ohos.multimedia.image';
633
634wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError, data: image.PixelMap) => {
635    if (error) {
636        console.error(`failed to getPixelMap because: ${JSON.stringify(error)}`);
637        return;
638    }
639    console.log(`success to getPixelMap : ${JSON.stringify(data)}`);
640  });
641```
642
643## wallpaper.getPixelMap<sup>(deprecated)</sup>
644
645getPixelMap(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
646
647Obtains the pixel map for the wallpaper of the specified type. This API uses a promise to return the result.
648
649> **NOTE**
650>
651> This API is supported since API version 7 and deprecated since API version 9.
652
653**Required permissions**: ohos.permission.GET_WALLPAPER
654
655**System capability**: SystemCapability.MiscServices.Wallpaper
656
657**System API**: This is a system API.
658
659**Parameters**
660
661| Name| Type| Mandatory| Description|
662| -------- | -------- | -------- | -------- |
663| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
664
665**Return value**
666
667| Type| Description|
668| -------- | -------- |
669| Promise&lt;image.PixelMap&gt; | Promise used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
670
671**Example**
672
673```ts
674import { BusinessError } from '@ohos.base';
675import image from '@ohos.multimedia.image';
676
677wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data: image.PixelMap) => {
678    console.log(`success to getPixelMap : ${JSON.stringify(data)}`);
679  }).catch((error: BusinessError) => {
680    console.error(`failed to getPixelMap because: ${JSON.stringify(error)}`);
681});
682```
683