Package overrungl.stb

Interface STBIRInputCallback

All Superinterfaces:
overrun.marshal.Upcall
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface STBIRInputCallback extends overrun.marshal.Upcall
INPUT CALLBACK: this callback is used for input scanlines

The input callback is super flexible - it calls you with the input address (based on the stride and base pointer), it gives you an optional_output pointer that you can fill, or you can just return your own pointer into your own data.

You can also do conversion from non-supported data types if necessary - in this case, you ignore the input_ptr and just use the x and y parameters to calculate your own input_ptr based on the size of each non-supported pixel. (Something like the third example below.)

You can also install just an input or just an output callback by setting the callback that you don't want to zero.

First example, progress: (getting a callback that you can monitor the progress):

void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, int x, int y, void * context )
 {
    percentage_done = y / input_height;
    return input_ptr;  // use buffer from call
 }

Next example, copying: (copy from some other buffer or stream):

void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, int x, int y, void * context )
 {
    CopyOrStreamData( optional_output, other_data_src, num_pixels * pixel_width_in_bytes );
    return optional_output;  // return the optional buffer that we filled
 }

Third example, input another buffer without copying: (zero-copy from other buffer):

void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, int x, int y, void * context )
 {
    void * pixels = ( (char*) other_image_base ) + ( y * other_image_stride ) + ( x * other_pixel_width_in_bytes );
    return pixels;       // return pointer to your data without copying
 }
Since:
0.1.0
Author:
squid233