NSEPSImageRep:imageRepWithData:
Home 目次>ApplicationKit>NSEPSImageRep

imageRepWithData:

データでNSEPSImageRepを作って返します


+(id) imageRepWithData:(NSData *)epsData


【返り値】
   idNSEPSImageRep
【パラメータ】
   epsDataEPSデータ


【解説】

データでNSEPSImageRepを作って返します。
EPSヘッダコメントで指定されるバウンディングボックスからオブジェクトサイズをセットします。



【例文】


#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
//開けるファイル拡張子の配列
NSArray *imgTypes = [ NSArray arrayWithObject : @"eps" ];
//OpenPanelを作る
NSOpenPanel *opImage = [ NSOpenPanel openPanel ];
//Imageを作る
NSImage *img = [[[NSImage alloc] initWithSize:NSMakeSize(100,100)] autorelease];
NSEPSImageRep *epsRep;
NSData *dat;
//OpenPanelの結果のボタン番号
int opRet;

//OpenPanelでファイル選択
opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
file : @"Pictures" //どのどのファイルを選択しておくか
types : imgTypes ];//選べるファイルタイプ

if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら
//NSDataを作ってファイルから読み込む
dat = [NSData dataWithContentsOfFile: [ opImage filename ] ];
epsRep = [NSEPSImageRep imageRepWithData:dat];
[img addRepresentation:epsRep];


NSLog([NSString stringWithFormat:@"w=%.1f",[epsRep boundingBox].size.width]);
}
}

@end


(C) 2000-2007 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>ApplicationKit>NSEPSImageRep
修正日2006.12.26