docs: BufferedImage readImage(final List<Segment> segments, final ImageInputStream input) throws IOException {
          JPEGLosslessDecoder decoder = new JPEGLosslessDecoder(segments, createBufferedInput(input), listenerDelegate);
  
          // TODO: Allow 10/12/14 bit (using a ComponentColorModel with correct bits, as in TIFF)
          // TODO: Rewrite this to pass a pre-allocated buffer of correct type (byte/short)/correct bands
          // TODO: Progress callbacks
          // TODO: Warning callbacks
          // Callback can then do subsampling etc.
          int[][] decoded = decoder.decode();
          int width = decoder.getDimX();
          int height = decoder.getDimY();
  
          // Single component, assumed to be Gray
          if (decoder.getNumComponents() == 1) {
              switch (decoder.getPrecision()) {
                  case 8:
                      return to8Bit1ComponentGrayScale(decoded, width, height);
                  case 10:
                  case 12:
                  case 14:
                  case 16:
                      return to16Bit1ComponentGrayScale(decoded, decoder.getPrecision(), width, height);
              }
          }
          // 3 components, assumed to be RGB
          else if (decoder.getNumComponents() == 3) {
              switch (decoder.getPrecision()) {
                  case 8:
                      return to24Bit3ComponentRGB(decoded, width, height);
              }
          }
  
          throw new IIOException("JPEG Lossless with " + decoder.getPrecision() + " bit precision and " + decoder.getNumComponents() + " component(s) not supported");
      }