ruby-vips
ruby-vips copied to clipboard
Add `data_ptr` method to `Vips::Image`
Hi, this PR adds support for vips_image_get_data to Ruby with a new data_ptr method that returns a sized FFI::Pointer. This provides similar functionality as write_to_memory but without additional copying.
With the current implementation, it would be the user's responsibility to ensure the pointer has not been invalidated (but we could add a reference to the pointer to ensure the image is not garbage collected while the pointer is active - I'm not sure if there are other operations that invalidate the pointer).
Ref: FFI enum docs