NSImageView:imageScaling
Home 目次>ApplicationKit>NSImageView このサイトはこちらに移転しました。

imageScaling

スケーリングモードを返します


-(NSImageScaling) imageScaling


【返り値】
   NSImageScalingスケーリングモード


【解説】

スケーリングモードを返します
【NSImageScaling】
● NSScaleProportionally 縦横比を維持してNSImageViewに合わせる
● NSScaleToFit NSImageViewに合わせる縦横比は無視する
● NSScaleNone 拡大縮小せずそのまま



【例文】


#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];
[image1 setImageScaling : NSScaleToFit ];
[image2 setImage : Copyimg ];
[image2 setImageScaling : [image1 imageScaling] ];
}
}

@end


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

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

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

良い 

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

Home 目次>ApplicationKit>NSImageView
修正日2006.12.26