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 1051
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

Public Instance Methods

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

Store changed pixels back to image

# File lib/rmagick_internal.rb, line 1075
def sync(force=false)
    @img.store_pixels(x, y, width, height, @view) if (@dirty || force)
    return (@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 1082
def update(rows)
    @dirty = true
    rows.delete_observer(self)      # No need to tell us again.
    nil
end