lib/jpeg/image.rb in jpeg-0.7.0 vs lib/jpeg/image.rb in jpeg-0.7.1

- old
+ new

@@ -1,11 +1,24 @@ module Jpeg class Image + def at(x, y) + raise 'invalid position' unless inside? x, y + dot = raw_data[y][x] + color? ? Color.new(*dot) : Color.new(dot, dot, dot) + end + def rgb? color_info == :rgb end + alias color? rgb? def gray? color_info == :gray + end + + private + + def inside?(x, y) + x < width && x >= 0 && y < height && y >= 0 end end end