class UnderOs::Image

creates a new image that fits the given size

Constants

VERSION

Attributes

_[RW]

Public Class Methods

new(raw_image) click to toggle source
# File lib/under_os/image.rb, line 19
def initialize(raw_image)
  @_ = raw_image
end
pick(&block) click to toggle source
# File lib/under_os/image.rb, line 13
def self.pick(&block)
  picker.pick(&block)
end
picker(options={}) click to toggle source
# File lib/under_os/image.rb, line 5
def self.picker(options={})
  @picker ||= Picker.new(options)
end
take(&block) click to toggle source
# File lib/under_os/image.rb, line 9
def self.take(&block)
  picker.take(&block)
end

Public Instance Methods

filter(params) click to toggle source
# File lib/under_os/image.rb, line 23
def filter(params)
  @filter ||= Filter.new.tap{ |f| f.image = self }
  @filter.params = params
  @filter.apply
end
resize(size) click to toggle source
# File lib/under_os/image/resize.rb, line 5
def resize(size)
  size      = UOS::Point.new(size)
  ratio     = size.x * 2 / @_.size.width
  new_size  = CGSizeMake(size.x * 2, @_.size.height * ratio)

  UIGraphicsBeginImageContext(new_size)
  @_.drawInRect(CGRectMake(0,0,new_size.width,new_size.height))
  new_image = UIGraphicsGetImageFromCurrentImageContext()
  UIGraphicsEndImageContext()

  self.class.new(new_image)
end