setNativeSource() 方法需要 android.graphics.Bitmap 个实例
The method setNativeSource() expects android.graphics.Bitmap instance
在我的应用程序中,如果我从图库中选择一张图片,我必须被重定向到包含该图片的模态 window。问题是图像从服务下载到组件,但没有显示,反而我有一个错误信息。
我向图库发送请求的组件:
const imageAsset = await this.gallery.selectPhoto();
this.rediresct("loading");
const options: ModalDialogOptions = {
context: imageAsset,
viewContainerRef: this.vref,
fullscreen: false
};
setTimeout(async () => {
const response = await this.modal.showModal(
ConfirmImageComponent,
options
);
if (response == "success") {
}
});
}
服务:
source: any;
constructor() {}
async selectPhoto(): Promise<Array<any>> {
let context = imagepicker.create({
mode: "single"
});
await context.authorize();
let imageAsset = [];
const selection = await context.present();
imageAsset = selection;
return imageAsset;
}
}
从服务下载图片并显示的组件:
obraz: ImageAsset;
constructor(
private gallery: GalleryService,
private params: ModalDialogParams
) {
this.image = params.context;
var pict = new Image();
pict.src = this.image;
console.log(pict.src);
}
ngOnInit() {}
}
在最后的代码中,我使用控制台日志来显示选定的图像源并且它可以工作,但是没有显示图像。在 VS Code 中,我看到了这个错误:
对于 return 您可以做的单一资产,
async selectPhoto(): Promise<any> {
let context = imagepicker.create({
mode: "single"
});
await context.authorize();
const selection = await context.present();
return selection[0];
}
确保您发现了 select 照片中的错误。
在我的应用程序中,如果我从图库中选择一张图片,我必须被重定向到包含该图片的模态 window。问题是图像从服务下载到组件,但没有显示,反而我有一个错误信息。
我向图库发送请求的组件:
const imageAsset = await this.gallery.selectPhoto();
this.rediresct("loading");
const options: ModalDialogOptions = {
context: imageAsset,
viewContainerRef: this.vref,
fullscreen: false
};
setTimeout(async () => {
const response = await this.modal.showModal(
ConfirmImageComponent,
options
);
if (response == "success") {
}
});
}
服务:
source: any;
constructor() {}
async selectPhoto(): Promise<Array<any>> {
let context = imagepicker.create({
mode: "single"
});
await context.authorize();
let imageAsset = [];
const selection = await context.present();
imageAsset = selection;
return imageAsset;
}
}
从服务下载图片并显示的组件:
obraz: ImageAsset;
constructor(
private gallery: GalleryService,
private params: ModalDialogParams
) {
this.image = params.context;
var pict = new Image();
pict.src = this.image;
console.log(pict.src);
}
ngOnInit() {}
}
在最后的代码中,我使用控制台日志来显示选定的图像源并且它可以工作,但是没有显示图像。在 VS Code 中,我看到了这个错误:
对于 return 您可以做的单一资产,
async selectPhoto(): Promise<any> {
let context = imagepicker.create({
mode: "single"
});
await context.authorize();
const selection = await context.present();
return selection[0];
}
确保您发现了 select 照片中的错误。