class Vips::Region

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)
```

Public Class Methods

new(name) click to toggle source
Calls superclass method GObject::GObject::new
# File lib/vips/region.rb, line 46
def initialize(name)
  ptr = Vips::vips_region_new name
  raise Vips::Error if ptr.null?

  super ptr
end

Public Instance Methods

fetch(left, top, width, height) click to toggle source

Fetch a region filled with pixel data.

# 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
height() click to toggle source
# File lib/vips/region.rb, line 57
def height
  Vips::vips_region_height self
end
width() click to toggle source
# File lib/vips/region.rb, line 53
def width
  Vips::vips_region_width self
end