lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.06k stars 421 forks source link

Trying to encode 16 bit RGB PNG but result is 8 bit #56

Closed dk-teknologisk-mlnn closed 7 years ago

dk-teknologisk-mlnn commented 7 years ago

Hi,

I cannot get it to work with saving a 16 bit RGB image. I end up with 8 bit RGB. Upon decoding the file again it gives me state.raw_info.bitdepth == 8 . I tried with : lodepng::encode(pstr, VImage, m_x, m_y, LCT_RGB, 16U); and also using state: lodepng::State state; state.info_raw.bitdepth = 16U; state.info_raw.colortype = LCT_RGB; state.encoder.auto_convert = 1; state.info_png.color.bitdepth = 16; state.info_png.color.colortype = LCT_RGB;

            std::vector<unsigned char> png;

            unsigned error = lodepng::encode(png, Vimage, m_x, m_y, state);

            if (!error) lodepng::save_file(png, pstr);
dk-teknologisk-mlnn commented 7 years ago

it is working now with "state". It was "autoconvert" that switched it back to 8bit.

lvandeve commented 7 years ago

Indeed, by default it converts to the smallest color model possible, but this can be disabled with the state, thank you for figuring it out :)