画像の保存
前に書いたコードを移植して、画像の保存も実装したのでなんか描いてみた。
画像の保存には NSBitmapImageRep - representationUsingType:properties: が使える。NSImage から NSCachedImageRep じゃなくて NSBitmapImageRep を取り出すには、oomori.com - このウェブサイトは販売用です! - リソースおよび情報 を参考にして、こんなコードで。
- (NSData*) dataRepresentationOfType: (NSString*) type { NSBitmapImageRep* rep; rep = [[NSBitmapImageRep alloc] initWithData: [[self image] TIFFRepresentation]]; return [rep representationUsingType: [[IMAGE_TYPES objectForKey: type] intValue] properties: [NSDictionary dictionary]]; }