- 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.
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface overrun.marshal.Upcall
overrun.marshal.Upcall.Type<T extends overrun.marshal.Upcall>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final overrun.marshal.Upcall.Type
<STBIRInputCallback> the type -
Method Summary
Modifier and TypeMethodDescription@NativeType("void const *") MemorySegment
invoke
(@NativeType("void *") MemorySegment optional_output, @NativeType("void const *") MemorySegment input_ptr, int num_pixels, int x, int y, @NativeType("void *") MemorySegment context) default MemorySegment
-
Field Details
-
TYPE
the type
-
-
Method Details
-
invoke
@NativeType("void const *") MemorySegment invoke(@NativeType("void *") MemorySegment optional_output, @NativeType("void const *") MemorySegment input_ptr, int num_pixels, int x, int y, @NativeType("void *") MemorySegment context) -
stub
- Specified by:
stub
in interfaceoverrun.marshal.Upcall
-