修复图片编辑后显示蓝色背景

Signed-off-by: ywx1281445 <yuandongping@huawei.com>
This commit is contained in:
ywx1281445 2024-08-20 11:43:00 +08:00
parent e82b54c73a
commit 7bbc5dd71b
4 changed files with 8 additions and 7 deletions

View File

@ -49,7 +49,7 @@ export default class GetPictures {
select.push(item);
})
}
let imageList:Array<string> = AppStorage.Get('imageList') as Array<string>;
let imageList:Array<string> = AppStorage.get('imageList') as Array<string>;
AppStorage.setOrCreate<Array<string>>('imageList', imageList.concat(select));
}
}

View File

@ -41,14 +41,15 @@ struct Index {
aboutToAppear(): void {
logger.info(TAG, 'enter aboutToAppear');
if (AppStorage.Get<string[]>('pixelMaps')) {
if (AppStorage.get<string[]>('pixelMaps')) {
this.pixelMaps.push(undefined);
}
let rawFile = getContext().resourceManager.getRawFdSync("commodity.png");
let imageSourceApi = image.createImageSource(rawFile);
imageSourceApi.createPixelMap().then((pixelMap) => {
this.commodityPixelMap = pixelMap;
})
});
this.imageListChange();
}
async imageListChange(): Promise<void> {

View File

@ -86,8 +86,8 @@ export struct UpdatePage {
.width($r('app.float.size_100'))
.onClick(() => {
// 删除图片
let imageList: Array<string> = AppStorage.Get('imageList') as Array<string>;
let index: number = AppStorage.Get('selectIndex') as number;
let imageList: Array<string> = AppStorage.get('imageList') as Array<string>;
let index: number = AppStorage.get('selectIndex') as number;
imageList.splice(index, 1);
AppStorage.setOrCreate<Array<string>>('imageList', imageList);
// 返回

View File

@ -74,8 +74,8 @@ async function saveFile(context: Context, data: ArrayBuffer): Promise<string> {
function setImageList(uri: string) {
let imageList: Array<string> | undefined = AppStorage.Get('imageList');
const index: number | undefined = AppStorage.Get('selectIndex');
let imageList: Array<string> | undefined = AppStorage.get('imageList');
const index: number | undefined = AppStorage.get('selectIndex');
if (imageList !== undefined && index !== undefined) {
imageList[index] = uri;
}