Skip to content

Commit

Permalink
HotCocoa Graphics optimizations provided by Alan Skipp
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3081 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
mattetti committed Dec 8, 2009
1 parent 775b7d8 commit bb3294e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/hotcocoa/graphics/image.rb 100755 → 100644
Expand Up @@ -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'
Expand All @@ -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

Expand Down

0 comments on commit bb3294e

Please sign in to comment.