diff --git a/lib/hotcocoa/graphics/image.rb b/lib/hotcocoa/graphics/image.rb old mode 100755 new mode 100644 index fdbe9706f..4246c67fc --- a/lib/hotcocoa/graphics/image.rb +++ b/lib/hotcocoa/graphics/image.rb @@ -58,11 +58,10 @@ def initialize(img, verbose=false) @path = img File.exists?(@path) or raise "ERROR: file not found: #{@path}" - nsimage = NSImage.alloc.initWithContentsOfFile(img) - nsdata = nsimage.TIFFRepresentation - @nsbitmapimage = NSBitmapImageRep.imageRepWithData(nsdata) - # cgimagesource = CGImageSourceCreateWithData(nsdata) # argh, doesn't work - @ciimage = CIImage.alloc.initWithBitmapImageRep(@nsbitmapimage) + image_source = CGImageSourceCreateWithURL(NSURL.fileURLWithPath(@path), nil) + @cgimage = CGImageSourceCreateImageAtIndex(image_source, 0, nil) + @ciimage = CIImage.imageWithCGImage(@cgimage) + when Canvas puts "Image.new with canvas" if @verbose @path = 'canvas' @@ -80,7 +79,7 @@ def initialize(img, verbose=false) # reload the bitmap image def reset - @ciimage = CIImage.alloc.initWithBitmapImageRep(@nsbitmapimage) + @ciimage = CIImage.imageWithCGImage(@cgimage) self end