In my application I have to use UPNG to compress a large quantity of images - specifically, given an ImageData, I need to reduce the colors to the provided value then output another ImageData. The way I'm currently doing this involves encoding the data as a PNG then decoding it again:
However, from some testing it appears the decoding of the PNG on the second line of the function creates a significant performance bottleneck. Is it possible to avoid creating a PNG in the first place so I don't have to decode it, and just reduce the number of colors of the raw pixel data and output that?
In my application I have to use UPNG to compress a large quantity of images - specifically, given an
ImageData
, I need to reduce the colors to the provided value then output anotherImageData
. The way I'm currently doing this involves encoding the data as a PNG then decoding it again:However, from some testing it appears the decoding of the PNG on the second line of the function creates a significant performance bottleneck. Is it possible to avoid creating a PNG in the first place so I don't have to decode it, and just reduce the number of colors of the raw pixel data and output that?