| Home 目次>ApplicationKit>NSEPSImageRep | |
initWithData:
NSEPSImageRepを初期化して返します
-(id) initWithData:(NSData *)epsData
【返り値】 | |
| id | NSEPSImageRep |
| 【パラメータ】 | |
| epsData | EPSデータ |
【解説】
NSEPSImageRepを初期化して返します。
初期化できなければnilを返します。
オブジェクトのサイズは、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 alloc] initWithData:dat];
[img addRepresentation:epsRep];
NSLog([NSString stringWithFormat:@"w=%.1f",[epsRep boundingBox].size.width]);
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSEPSImageRep | 修正日2006.12.26 |