| Home 目次>ApplicationKit>NSImageView このサイトはこちらに移転しました。 | |
image
イメージビューに表示されている画像を返します
-(NSImage *) image
【返り値】 | |
| NSImage * | 画像 |
【解説】
イメージビューに表示されている画像を返します。
【例文】
#import "SetImage.h"
@implementation SetImage
- (IBAction)set:(id)sender
{
//開けるファイル拡張子の配列
NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ];
//OpenPanelを作る
NSOpenPanel *opImage = [ NSOpenPanel openPanel ];
//Imageを作る
NSImage *img;
NSImage *Copyimg;
//OpenPanelの結果のボタン番号
int opRet;
//OpenPanelでファイル選択
opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
file : @"Pictures" //どのどのファイルを選択しておくか
types : imgTypes ];//選べるファイルタイプ
if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら
//NSImageを作ってファイルから読み込む
img = [ [ NSImage alloc ]
initWithContentsOfFile: [ opImage filename ] ];
//レシーバimage(NSImageView)にimgをセットする
[image1 setImage : img ];
Copyimg = [ NSImage alloc ];
Copyimg = [image1 image];
[image2 setImage : Copyimg ];
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSImageView | 修正日2006.12.26 |