Skip to content
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

Pixel RGB value is larger than 255 with iOS screenShot Image #689

Open
cuishijie1991 opened this issue Oct 23, 2024 · 2 comments
Open

Pixel RGB value is larger than 255 with iOS screenShot Image #689

cuishijie1991 opened this issue Oct 23, 2024 · 2 comments

Comments

@cuishijie1991
Copy link

Hello, I am using image v4.2.0 to binarize images. But when testing iOS app, I encountered a headache: when I selected a screenshot from the album, I tried to use pixel to get the r, g, b value, but found that its value was not 0-255, which made it impossible for me to binarize it.
If it is not an iOS screenshot picture, the rgb value obtained is correct. In addition, I sent this picture to my android 14 phone, and it also had a similar problem.
This problem did not occur when using image v3, and after testing, the same iOS screenshot, v3 can correctly obtain r, g, b values ​​between 0-255.
I don't know what v4 does, but I hope you can help check this problem, or tell me how to use v4's api correctly, thank you very much!
In addition, I am using flutter v3.16.9, image v4.2.0, and the iOS test machine is iphoneX (16.1.2)

for (int y = 0; y < image.height; y++) { for (int x = 0; x < image.width; x++) { imgLib.Pixel pixel = image.getPixel(x, y); if (x == 0 && y == 0) { print("@@@${pixel.r},${pixel.g},${pixel.b}"); } } }

log=> flutter: @@@54434,42598,20770

IMG_0230

@brendan-duncan
Copy link
Owner

brendan-duncan commented Oct 23, 2024

Probably a 16-bit image. You can convert it to an 8-bit image first. Image u8 = image.convert(format: Format.uint8);

@cuishijie1991
Copy link
Author

Probably a 16-bit image. You can convert it to an 8-bit image first. Image u8 = image.convert(format: Format.uint8);

Thank u, it works for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants