Function libjxl_sys::JxlDecoderSetImageOutCallback[][src]

pub unsafe extern "C" fn JxlDecoderSetImageOutCallback(
    dec: *mut JxlDecoder,
    format: *const JxlPixelFormat,
    callback: JxlImageOutCallback,
    opaque: *mut c_void
) -> JxlDecoderStatus

Sets pixel output callback. This is an alternative to JxlDecoderSetImageOutBuffer. This can be set when the JXL_DEC_FRAME event occurs, must be set when the JXL_DEC_NEED_IMAGE_OUT_BUFFER event occurs, and applies only for the current frame. Only one of JxlDecoderSetImageOutBuffer or JxlDecoderSetImageOutCallback may be used for the same frame, not both at the same time.

The callback will be called multiple times, to receive the image data in small chunks. The callback receives a horizontal stripe of pixel data, 1 pixel high, xsize pixels wide, called a scanline. The xsize here is not the same as the full image width, the scanline may be a partial section, and xsize may differ between calls. The user can then process and/or copy the partial scanline to an image buffer. The callback bay be called simultaneously by different threads when using a threaded parallel runner, on different pixels.

If JxlDecoderFlushImage is not used, then each pixel will be visited exactly once by the different callback calls, during processing with one or more JxlDecoderProcessInput calls. These pixels are decoded to full detail, they are not part of a lower resolution or lower quality progressive pass, but the final pass.

If JxlDecoderFlushImage is used, then in addition each pixel will be visited zero or one times during the blocking JxlDecoderFlushImage call. Pixels visited as a result of JxlDecoderFlushImage may represent a lower resolution or lower quality intermediate progressive pass of the image. Any visited pixel will be of a quality at least as good or better than previous visits of this pixel. A pixel may be visited zero times if it cannot be decoded yet or if it was already decoded to full precision (this behavior is not guaranteed).

@param dec decoder object @param format format of the pixels. Object owned by user and its contents are copied internally. @param callback the callback function receiving partial scanlines of pixel data. @param opaque optional user data, which will be passed on to the callback, may be NULL. @return JXL_DEC_SUCCESS on success, JXL_DEC_ERROR on error, such as JxlDecoderSetImageOutBuffer already set.