Traneptora / jxlatte

Java JPEG XL decoder
MIT License
44 stars 5 forks source link

Decompress 16-bit image back into 16 bit? #23

Closed siiinc closed 1 year ago

siiinc commented 1 year ago

Is there an option that will enable me to convert a compressed 16bit image (short) back to 16bits and not float?

Traneptora commented 1 year ago

JXLImage only supports floats. If you have a 16-bit RGB BufferedImage you can always do something like:

JXLImage jxlImage = decoder.decode();
BufferedImage my16bitImage = foo;
Graphics g = my16BitImage.createGraphics();
g.drawImage(jxlImage.asBufferedImage(), 0, 0, null);
siiinc commented 1 year ago

I am not worried about the data type but is there a way to stop data rescaling? The image looks fine when displayed, just the pixel values, which mean something to me, are changed.

i.e., jxl pixels (via libjxl) as [245, 302, 394] becomes jxlatte decompressed [0.000289578107185662, 0.000356883567292243, 0.000465500168502331]

Traneptora commented 1 year ago

libjxl is using floats and it's just scaling it before giving it to you in an opaque way.

siiinc commented 1 year ago

Using com.thebombzen.jxlatte.io.PNGWriter as an example I was able to scale back to 16bit vals.