-
Notifications
You must be signed in to change notification settings - Fork 259
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
16-bit per channel PNG to Uint16Array? #54
Comments
Hi, sure! The object returned by UPNG.decode() has a property "data" with 16-bit raster data of the image. If you want to use the same ArrayBuffer, you need to swap pairs of bytes from big endian to a little endian. See here: #30 |
Edit: If I do a >> 8 on all my 16-bit values after your endianness code then all the 8-bit values seem right. Maybe I hosed my webgl2 viewer...argh. I read through the comments on issue #30 but I have a RGBA image I need help with. Can you advise? I think I need to modify the endianness code your provided. Sorry to bother you again. http://www.schaik.com/pngsuite/basn6a16.png
|
BTW. the domain http://www.schaik.com/ does not work for me :( I opened the basn6a16.png in Photopea.com (which uses UPNG.js) and it seems to work correctly (as your example on the right). If you need to open any PNG image as a 8-channel RGBA image, use UPNG.toRGBA8(....). The images in your screenshot look different. I think it could be because of additional multiplying or dividing the RGB values by alpha value. |
Your comment was very helpful. It turns out I had to set {premultipliedAlpha: false} on my webgl2 context which fixed the visual differences. |
Is it possible to get values from a 16-bit per channel PNG as a Uint16Array?
The text was updated successfully, but these errors were encountered: