Class: CIImage

Inherits:
Object show all
Defined in:
lib/ios/sugarcube-pipes/pipes.rb,
lib/ios/sugarcube-image/ciimage.rb

Instance Method Summary collapse

Instance Method Details

#apply_filter(filter) ⇒ Object


16
17
18
19
# File 'lib/ios/sugarcube-image/ciimage.rb', line 16

def apply_filter(filter)
  filter.setValue(self, forKey: 'inputImage')
  return filter.valueForKey('outputImage')
end

#ciimageObject


12
13
14
# File 'lib/ios/sugarcube-image/ciimage.rb', line 12

def ciimage
  return self
end

#uiimage(scale = nil, orientation = nil) ⇒ Object


3
4
5
6
7
8
9
10
# File 'lib/ios/sugarcube-image/ciimage.rb', line 3

def uiimage(scale=nil, orientation=nil)
  if scale
    orientation ||= UIImageOrientationUp
    return UIImage.imageWithCIImage(self, scale: scale, orientation: orientation)
  else
    return UIImage.imageWithCIImage(self)
  end
end

#|(filter) ⇒ Object


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ios/sugarcube-pipes/pipes.rb', line 48

def |(filter)
  if CIFilter === filter
    apply_filter(filter)
  elsif filter == UIImage
    self.uiimage
  elsif filter == UIView || filter == UIImageView
    self.uiimage.uiimageview
  elsif filter == CIImage
    self
  else
    raise "The `|` operator is not supported for the #{filter.is_a?(Class) ? filter.name : filter.class.to_s} class"
  end
end