Class: Vips::Source
- Inherits:
-
Connection
- Object
- GObject::GObject
- Object
- Connection
- Vips::Source
- Defined in:
- lib/vips/source.rb
Overview
A source. For example:
source = Vips ::Source.new_from_file ("k2.jpg")
image = Vips ::Image .new_from_source (source)
Direct Known Subclasses
Defined Under Namespace
Modules: SourceLayout Classes: ManagedStruct , Struct
Instance Attribute Summary
Attributes inherited from GObject::GObject
Class Method Summary collapse
-
.new_from_descriptor(descriptor) ⇒ Source
Create a new source from a file descriptor.
-
.new_from_file(filename) ⇒ Source
Create a new source from a file name.
-
.new_from_memory(data) ⇒ Source
Create a new source from an area of memory.
Methods inherited from Connection
Methods inherited from Object
#get , #get_pspec , #get_typeof , #get_typeof_error , print_all , #set , #signal_connect
Methods inherited from GObject::GObject
ffi_managed_struct , #ffi_managed_struct , #ffi_struct , ffi_struct , #initialize
Constructor Details
This class inherits a constructor from GObject::GObject
Class Method Details
.new_from_descriptor(descriptor) ⇒ Source
Create a new source from a file descriptor. File descriptors are small integers, for example 0 is stdin.
Pass sources to Image.new_from_source to load images from them.
Parameters:
-
descriptor
(Integer)
—
the file descriptor
Returns:
-
(Source )
—
the new Vips::Source
Raises:
- (Vips::Error )
.new_from_file(filename) ⇒ Source
Create a new source from a file name.
Pass sources to Image.new_from_source to load images from them.
Parameters:
-
filename
(String)
—
the name of the file
Returns:
-
(Source )
—
the new Vips::Source
Raises:
- (Vips::Error )
.new_from_memory(data) ⇒ Source
Create a new source from an area of memory. Memory areas can be strings, arrays and so forth -- anything that supports bytesize.
Pass sources to Image.new_from_source to load images from them.
Parameters:
-
data
(String)
—
memory area
Returns:
-
(Source )
—
the new Vips::Source
Raises:
- (Vips::Error )
78 79 80 81 82 83 84 85 86
# File 'lib/vips/source.rb', line 78 def self.new_from_memory(data) ptr = Vips .vips_source_new_from_memory data, data.bytesize raise Vips ::Error if ptr.null? # FIXME do we need to keep a ref to the underlying memory area? what # about Image.new_from_buffer? Does that need a secret ref too? Vips ::Source .new ptr end