Vips::SourceCustom
Inherits Vips::Source / Vips::Connection / Vips::VipsObject / Vips::GObject / Reference / Object
A source you can attach action signal handlers to to implement custom input types.
For example:
file = File.open("some/file/name", "rb")
source = Vips::SourceCustom.new
source.on_read { |slice| file.read(slice) }
image = Vips::Image.new_from_source(source)
(just an example -- of course in practice you'd use Source#new_from_file
to read from a named file)
Constructors
Instance methods
The block is executed to read data from the source. The interface is
exactly as IO::read, ie. it takes a slice and reads atmost slice.size and
returns a number of bytes read from the source, or 0 if the source is already
at end of file.
The block is executed to seek the source. The interface is exactly as IO::seek, ie. it should take an offset and whence, and return the new read position.
This handler is optional -- if you do not attach a seek handler,
Source will treat your source like an unseekable pipe object and
do extra caching.