Skip to content

nativescript-bitmap-factory crop() API throws error on iOS #10

@pyou10622

Description

@pyou10622

In my project, I use the nativescript-bitmap-factory (version 1,8.1) to crop an image:

public cropImage(image : ImageSource) : ImageSource {
    let mutable = BitmapFactory.makeMutable(image);
    return BitmapFactory.asBitmap(mutable).dispose((bmp) => {
        let croppedImage = bmp.crop({x:10,y:10}, {width:300,height:300});
       console.log("Image cropped!")
       return croppedImage.toImageSource();
    });
}

This works beautifully on Android emulators and devices, but throws the following exception on iPhone:

CONSOLE ERROR file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:676:30: Unhandled Promise rejection: The method setNativeSource() expects UIImage instance. ; Zone: ; Task: Promise.then ; Value: Error: The method setNativeSource() expects UIImage instance. setNativeSource@file:///app/tns_modules/tns-core-modules/image-source/image-source.js:112:28 [angular]
toImageSource@file:///app/tns_modules/nativescript-bitmap-factory/BitmapFactory.commons.js:374:31 [angular]
dispose@file:///app/tns_modules/nativescript-bitmap-factory/BitmapFactory.commons.js:87:30 [angular]
......
onInvoke@file:///app/tns_modules/@angular/core/bundles/core.umd.js:17344:43 [angular]
file:///app/pages/capture-image/capture-image.component.js:64:30 []
file:///app/tns_modules/nativescript<\M-b\M^@\M-&>

Googled the error message found this:

mkloubert/nativescript-bitmap-factory#19

but there is no solution there.

Is there a fix? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions