-
I have been struggling a bit trying to read off pixel values from a png file using the ImageLoader. But for some reason the pixels values comes out a bit off. I know what the values in the png are. Lets say a png pixel has this value 50,61,71,77 for R,G,B,A respectively, The ImageLoader will resolve the image into a ImageData structure with a "data" member of type Uint8ClampedArray which should contain the raw pixel data. But the pixel comes as 50, 60, 70, 77. In other words slightly off. It does not help no matter which options I set on the ImageLoader. Anyone has a clue to why this is so. Is it not possible to use the ImageLoader to get exact pixel values from a png (or any other image format)? regards |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Thanks for reporting, wasn't aware of this. For image loading, loaders.gl relies on the browser's built in decoding. Perhaps the browser takes some shortcuts with rounding etc to parse faster? IIRC on a modern desktop browser loaders.gl parses images to ImageBitmap before calling getImageData and the ImageBitmap constructor has a few options that you should be able to pass through with |
Beta Was this translation helpful? Give feedback.
Thanks for reporting, wasn't aware of this. For image loading, loaders.gl relies on the browser's built in decoding. Perhaps the browser takes some shortcuts with rounding etc to parse faster?
IIRC on a modern desktop browser loaders.gl parses images to ImageBitmap before calling getImageData and the ImageBitmap constructor has a few options that you should be able to pass through with
options.image.imageBitmap: {...}
. But I can't see anything that would reasonably cause such off-by-one errors...