ruby-vips icon indicating copy to clipboard operation
ruby-vips copied to clipboard

Add `data_ptr` method to `Vips::Image`

Open ankane opened this issue 7 months ago • 11 comments

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

ankane avatar Apr 11 '25 21:04 ankane