class Magick::Image::View

Magick::Image::View class

Attributes

dirty[RW]
height[R]
width[R]
x[R]
y[R]

Public Class Methods

new(img, x, y, width, height) click to toggle source
# File lib/rmagick_internal.rb, line 1080
def initialize(img, x, y, width, height)
  img.check_destroyed
  Kernel.raise ArgumentError, "invalid geometry (#{width}x#{height}+#{x}+#{y})" if width <= 0 || height <= 0
  Kernel.raise RangeError, "geometry (#{width}x#{height}+#{x}+#{y}) exceeds image boundary" if x < 0 || y < 0 || (x + width) > img.columns || (y + height) > img.rows
  @view = img.get_pixels(x, y, width, height)
  @img = img
  @x = x
  @y = y
  @width = width
  @height = height
  @dirty = false
end

Public Instance Methods

[](*args) click to toggle source
# File lib/rmagick_internal.rb, line 1093
def [](*args)
  rows = Rows.new(@view, @width, @height, args)
  rows.add_observer(self)
  rows
end
sync(force = false) click to toggle source

Store changed pixels back to image

# File lib/rmagick_internal.rb, line 1100
def sync(force = false)
  @img.store_pixels(x, y, width, height, @view) if @dirty || force
  @dirty || force
end
update(rows) click to toggle source

Get update from Rows - if @dirty ever becomes true, don't change it back to false!

# File lib/rmagick_internal.rb, line 1107
def update(rows)
  @dirty = true
  rows.delete_observer(self) # No need to tell us again.
  nil
end