iddan / react-native-canvas

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

Can't draw image greater than 2048x2048 #320

Closed winhowes closed 11 months ago

winhowes commented 11 months ago

Whenever I set the canvas size such that the width * height > 2048 * 2048 (such as 1985 * 2113 which equals 2048 * 2048 + 1) the await canvas.toDataURL('image/png'); returns "data:," (i.e. no data). When it's 2048 * 2048, I get all the data back. Could you help me understand where this limit is coming from and/or provide a work around? I've dug through the code and it's dependencies, but can't seem to find where this 4mb limit originates. Thanks!

winhowes commented 11 months ago

I've figured it out. Safari imposes a limit of 4096 * 4096, and because the devicePixelRatio is 2, my 2048 * 2048 gets multiplied out to 4096 * 4096.