[macruby-changes] [716] MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 7 11:27:22 PST 2008
Revision: 716
http://trac.macosforge.org/projects/ruby/changeset/716
Author: rich at infoether.com
Date: 2008-11-07 11:27:22 -0800 (Fri, 07 Nov 2008)
Log Message:
-----------
add nsimage
Modified Paths:
--------------
MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb
Modified: MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb 2008-11-07 18:32:21 UTC (rev 715)
+++ MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb 2008-11-07 19:27:22 UTC (rev 716)
@@ -64,6 +64,13 @@
options[:type] = :context
Canvas.new(options, &block)
end
+
+ def for_current_context(options={}, &block)
+ options[:type] = :context
+ options[:context] = NSGraphicsContext.currentContext.graphicsPort
+ Canvas.new(options, &block)
+ end
+
end
# create a new canvas with the given width, height, and output filename (pdf, png, jpg, gif, or tif)
@@ -604,7 +611,13 @@
# SAVING/EXPORTING
-
+
+ def nsimage
+ image = NSImage.alloc.init
+ image.addRepresentation(NSBitmapImageRep.alloc.initWithCGImage(cgimage))
+ image
+ end
+
# return a CGImage of the canvas for reprocessing (only works if using a bitmap context)
def cgimage
CGBitmapContextCreateImage(@ctx) # => CGImageRef (works with bitmap context only)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081107/aeb4b208/attachment.html>
More information about the macruby-changes
mailing list