Sha256: 93802b9de0be95e030fbcb39572574d8a3d4fef6972195ddc55b52b7720a9228

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

module OSX
  class CIImage      
    def save(target, format = OSX::NSJPEGFileType, properties = nil)
      bitmapRep = OSX::NSBitmapImageRep.alloc.initWithCIImage(self)
      blob = bitmapRep.representationUsingType_properties(format, properties)
      blob.writeToFile_atomically(File.expand_path(target), false)
    end

    def cgimage
      OSX::NSBitmapImageRep.alloc.initWithCIImage(self).CGImage()
    end

    def self.from(filepath)
      raise Errno::ENOENT, "No such file or directory - #{filepath}" unless File.exists?(filepath)
      OSX::CIImage.imageWithContentsOfURL(OSX::NSURL.fileURLWithPath(File.expand_path(filepath)))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capture-0.0.1 lib/capture/extensions.rb
capture-0.0.2 lib/capture/extensions.rb