class Vips::SourceCustom
Overview
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)
Direct Known Subclasses
Defined in:
vips/source.crConstructors
Instance Method Summary
- #finalize
-
#on_read(&block : Bytes -> Int32)
The block is executed to read data from the source.
-
#on_seek(&block : Int64, IO::Seek -> Int64)
The block is executed to seek the source.
Instance methods inherited from class Vips::Source
finalize
finalize
Class methods inherited from class Vips::Source
new_from_descriptor(descriptor : Int)
new_from_descriptor,
new_from_file(filename : String)
new_from_file,
new_from_memory(data : String | Bytes | IO)
new_from_memory
Instance methods inherited from class Vips::Connection
filename : String | Nil
filename,
nick : String | Nil
nick
Instance methods inherited from class Vips::VipsObject
get(name : String)
get,
get_blurb(name : String)
get_blurb,
get_description
get_description,
get_pspec(name : String) : LibVips::GParamSpec | Nil
get_pspec,
get_typeof(name : String)
get_typeof,
post_close(&block : -> )
post_close,
print_all
print_all,
set(gtype, name, value)set(options : String) set
Instance methods inherited from class Vips::GObject
finalize
finalize,
get(name : String, gval : GValue)
get,
object_ref
object_ref,
ref_count
ref_count,
release_handle
release_handle,
set(name : String, gval : GValue)
set,
signal_connect(signal : String, callback : Proc, data : Pointer(Void) = Pointer(Void).null) : LibVips::Gulong
signal_connect,
signal_disconnect(handler_id : LibVips::Gulong)signal_disconnect(func : Proc, data : Pointer(Void) = Pointer(Void).null)
signal_disconnect(data : LibVips::Gpointer) signal_disconnect
Constructor Detail
Instance Method Detail
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.