Laurent Sansonetti
lsans****@apple*****
Thu Jan 25 19:45:54 JST 2007
Hi Benjamin, Actually I don't think [NSBitmapImagerep -writeToFile:automatically:] exists. At a glance, according to the reference [1], you should do data = bitmap.bitmapData File.open('/path/bitmap', 'w') { |io| io.write data } Laurent [1]: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBitmapImageRep_Class/Reference/Reference.html On Jan 25, 2007, at 5:14 AM, Benjamin Jackson wrote: > Trying to save an image using the latest stable build: > > url = NSURL.fileURLWithPath(path) > image = CIImage.imageWithContentsOfURL(url) > bitmap = > NSBitmapImageRep > .alloc > .initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel > ( > nil, image.extent.size.width, image.extent.size.height, 8, 4, > true, false, NSDeviceRGBColorSpace, 0, 0) > > context = NSGraphicsContext.graphicsContextWithBitmapImageRep > bitmap > NSGraphicsContext.saveGraphicsState > NSGraphicsContext.setCurrentContext context > context.CIContext.drawImage_atPoint_fromRect image, > CGPoint.new(0,0), image.extent > NSGraphicsContext.restoreGraphicsState > bitmap.writeToFile_atomically("/Users/bjackson/Desktop/ > test.bmp", true) > > > /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/ > osx/objc/oc_wrapper.rb:48:in > `NSApplicationMain': NSApplicationMain - > RBException_OSX::OCMessageSendException - > NSBitmapImageRep#writeToFile:atomically: - Can't get Objective-C > method signature for selector 'writeToFile:atomically:' of receiver > #<OSX::NSBitmapImageRep:0x154f7e class='NSBitmapImageRep' > id=0x1151420> (OSX::OCException) > > Tried using the method with a "hello world" NSString and an empty > NSData object, and both compiled without error. > _______________________________________________ > Rubycocoa-devel mailing list > Rubyc****@lists***** > http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel