| 73 | // ---------------------------------------------------------------------------------------- |
| 74 | |
| 75 | void jxl_loader::get_info() |
| 76 | { |
| 77 | JxlSignature signature = JxlSignatureCheck(data.data(), data.size()); |
| 78 | if (signature != JXL_SIG_CODESTREAM && signature != JXL_SIG_CONTAINER) |
| 79 | { |
| 80 | throw image_load_error("jxl_loader: JxlSignatureCheck failed"); |
| 81 | } |
| 82 | |
| 83 | auto dec = JxlDecoderMake(nullptr); |
| 84 | if (JXL_DEC_SUCCESS != JxlDecoderSubscribeEvents(dec.get(), JXL_DEC_BASIC_INFO)) |
| 85 | { |
| 86 | throw image_load_error("jxl_loader: JxlDecoderSubscribeEvents failed"); |
| 87 | } |
| 88 | |
| 89 | JxlDecoderSetInput(dec.get(), data.data(), data.size()); |
| 90 | JxlDecoderCloseInput(dec.get()); |
| 91 | if (JXL_DEC_BASIC_INFO != JxlDecoderProcessInput(dec.get())) { |
| 92 | throw image_load_error("jxl_loader: JxlDecoderProcessInput failed"); |
| 93 | } |
| 94 | |
| 95 | JxlBasicInfo basic_info; |
| 96 | if (JXL_DEC_SUCCESS != JxlDecoderGetBasicInfo(dec.get(), &basic_info)) |
| 97 | { |
| 98 | throw image_load_error("jxl_loader: JxlDecoderGetBasicInfo failed"); |
| 99 | } |
| 100 | width = basic_info.xsize; |
| 101 | height = basic_info.ysize; |
| 102 | depth = basic_info.num_color_channels + basic_info.num_extra_channels; |
| 103 | bits_per_sample = basic_info.bits_per_sample; |
| 104 | } |
| 105 | // ---------------------------------------------------------------------------------------- |
| 106 | |
| 107 | void jxl_loader::decode(unsigned char* out, const size_t out_size) const |
nothing calls this directly
no test coverage detected