-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PutImageData draws only part of the image #158
Comments
first image is actual result which doesn't cover the entire purple rectangle |
After looking at this closer, it seems that getImageData is only getting 1/9th of the data (the top left corner). This issue was resolved by multiplying the canvas.width and canvas.height by 3.
|
I'm guessing the bug has to do with the code for fixing the resolution of the canvas to match the resolution factor of the device. PRs are welcome |
+1 |
However, when I try it on the Android simulator, it does not capture the full image. The fix above was on iPhone 11 Pro Max (it also works on the iPad simulator) but when I switch over to Pixel 3 XL, I get the image below. However, it works fine on Pixel 3. Any ideas on how to make it work for all devices? Would I need to know the resolution of the canvas to the resolution factor of the device? |
Edit-Edit: Okay, seemed to have figured it out. Just used PixelRatio.get() instead. It just so happens that for iPhones the PixelRatio is 3 which is why the original comment of x3 was working. https://reactnative.dev/docs/pixelratio
|
hi,
when i use getImageData manipulate pixels and then putImageData
the result that is that a smaller version of the image is drawn even though i want to the entire canvas.
you can reproduce this in your example file where the purple rectangle is not covered completely by a black one.
example code:
handleImageData(canvas) {
canvas.width = 100;
canvas.height = 100;
}
to my understanding this should cover the original purple rectangle with a black one since you change all the pixels to black.
Note: that this code works as expected on web.
The text was updated successfully, but these errors were encountered: