React Native not able to draw image on canvas from file

Viewed 12

I am having trouble getting a iOS asset file drawn to react-native-canvas.

I am loading the image with Expo Image Picker, and that is working (since it is working on the website as well)

Somewhere in this code, there is an exception being thrown, and I believe it is because the image src is not valid.

CanvasImage is imported from {Image} from react-native-canvas

#setImage2[0] is the current image, loaded from expo image picker, starts with file://, is a png
imageDraw = new CanvasImage(canv,setImage2[0].width,setImage2[0].height);
var imageinfo = await FileSystem.readAsStringAsync(setImage2[0].uri,{ encoding: FileSystem.EncodingType.Base64 });
imageDraw.src = "data:image/png;base64, "+imageinfo
imageDraw.height = setImage2[0].height
imageDraw.width = setImage2[0].width
var image_drawn = await can_context.drawImage(imageDraw,0,0,new_width,new_height);
const gID = await can_context.getImageData(0,0,new_width,new_height);

I am looking to draw the image to the canvas (context is can_context), and then get the pixels after drawing on the image.

Any help is greatly appreciated, even a different route to the same solution works.

Thanks in advance.

0 Answers
Related