Revision
3081
Author
mattaimonetti@gmail.com
Date
2009-12-07 18:20:31 -0800 (Mon, 07 Dec 2009)

Log Message

HotCocoa Graphics optimizations provided by Alan Skipp

Modified Paths

Property Changed

Diff

Modified: MacRuby/trunk/lib/hotcocoa/graphics/image.rb (3080 => 3081)


--- MacRuby/trunk/lib/hotcocoa/graphics/image.rb	2009-12-07 03:32:54 UTC (rev 3080)
+++ MacRuby/trunk/lib/hotcocoa/graphics/image.rb	2009-12-08 02:20:31 UTC (rev 3081)
@@ -58,11 +58,10 @@
         @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 @@
   
     # reload the bitmap image
     def reset
-      @ciimage = CIImage.alloc.initWithBitmapImageRep(@nsbitmapimage)
+      @ciimage = CIImage.imageWithCGImage(@cgimage)
       self
     end
   
Property changes on: MacRuby/trunk/lib/hotcocoa/graphics/image.rb
___________________________________________________________________

Deleted: svn:executable