Magick::Image::View class
# File lib/rmagick_internal.rb, line 1048 def initialize(img, x, y, width, height) img.check_destroyed if width <= 0 || height <= 0 Kernel.raise ArgumentError, "invalid geometry (#{width}x#{height}+#{x}+#{y})" end if x < 0 || y < 0 || (x+width) > img.columns || (y+height) > img.rows Kernel.raise RangeError, "geometry (#{width}x#{height}+#{x}+#{y}) exceeds image boundary" end @view = img.get_pixels(x, y, width, height) @img = img @x = x @y = y @width = width @height = height @dirty = false end
# File lib/rmagick_internal.rb, line 1065 def [](*args) rows = Rows.new(@view, @width, @height, args) rows.add_observer(self) rows end
Store changed pixels back to image
# File lib/rmagick_internal.rb, line 1072 def sync(force=false) @img.store_pixels(x, y, width, height, @view) if @dirty || force @dirty || force end
Get update from Rows - if @dirty ever becomes true, don't change it back to false!
# File lib/rmagick_internal.rb, line 1079 def update(rows) @dirty = true rows.delete_observer(self) # No need to tell us again. nil end