Class: Vips::Region
- Inherits:
-
Object
- Object
- GObject::GObject
- Object
- Vips::Region
- Defined in:
- lib/vips/region.rb
Overview
A region on an image. Create one, then use fetch
to quickly get a region of pixels.
For example:
ruby region = Vips::Region.new(image) pixels = region.fetch(10, 10, 100, 100)
Defined Under Namespace
Modules: RegionLayout Classes: ManagedStruct , Struct
Instance Attribute Summary
Attributes inherited from GObject::GObject
Instance Method Summary collapse
-
#fetch(left, top, width, height) ⇒ Object
Fetch a region filled with pixel data.
- #height ⇒ Object
-
#initialize(name) ⇒ Region
constructor
A new instance of Region.
- #width ⇒ Object
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
Constructor Details
Instance Method Details
#fetch(left, top, width, height) ⇒ Object
Fetch a region filled with pixel data.
Raises:
- (Vips::Error )
62 63 64 65 66 67 68 69 70 71
# File 'lib/vips/region.rb', line 62 def fetch(left, top, width, height) len = Vips ::SizeStruct .new ptr = Vips .vips_region_fetch self, left, top, width, height, len raise Vips ::Error if ptr.null? # wrap up as an autopointer ptr = FFI::AutoPointer.new(ptr, GLib ::G_FREE ) ptr.get_bytes 0, len[:value] end