• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import StartupTask from '@ohos.app.appstartup.StartupTask';
2import common from '@ohos.app.ability.common';
3import image from '@ohos.multimedia.image';
4
5
6@Sendable
7export default class ResourceManagerTask extends StartupTask {
8  constructor() {
9    super();
10  }
11
12  async init(context: common.AbilityStageContext) {
13    try {
14      let value = context.resourceManager.getMediaContentSync($r('app.media.startIcon').id); // 默认屏幕密度
15      let imageSource: image.ImageSource = image.createImageSource(value.buffer);
16      let pixelMap = imageSource.createPixelMapSync();
17      pixelMap.rotateSync(45);
18      AppStorage.setAndLink<PixelMap>('image', pixelMap);
19    } catch (error) {
20    }
21  }
22
23  onDependencyCompleted(dependence: string): void {
24  }
25}
26
27