iddan / react-native-canvas

A Canvas component for React Native
MIT License
981 stars 172 forks source link

why Why did I use getImageData() for more than 1 minute? #302

Open aajiejie opened 1 year ago

aajiejie commented 1 year ago

When I use getImageData(), I have to wait for a long time to get data, which is unbearable. Why is this? ImgWH=360,pixelRatio=3 and the image pixel is 360 360 `const wh = imgWH pixelRatio;

context.getImageData(0, 0, wh, wh).then(imageData => {

....

}`

SvetlozarValchev commented 1 year ago

Same issue, it takes about a minute for getImageData to resolve with a 300x600 canvas

aajiejie commented 1 year ago

Same issue, it takes about a minute for getImageData to resolve with a 300x600 canvas

I have two solutions to solve it

  1. Further reduce until you can tolerate the time
  2. Divide the pixels of the canvas into blocks and process them one by one