| Home 目次>ApplicationKit>NSBitmapImageRep このサイトはこちらに移転しました。 | |
TIFFRepresentationOfImageRepsInArray:
TIFF画像データを作成します
+(NSData *) TIFFRepresentationOfImageRepsInArray:(NSArray *)array
【返り値】 | |
| NSData * | 画像データ |
| 【パラメータ】 | |
| array | 配列 |
【解説】
TIFF画像データを作成します。TIFFデータの作成中に問題が発生すればNSTIFFExceptionかNSBadBitmapParametersExceptionを起こします。
【例文】
#import "SetImage.h"
@implementation SetImage
- ( IBAction )set:( id )sender
{
// 開けるファイル拡張子の配列
NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ];
//OpenPanel を作る
NSOpenPanel *opImage = [ NSOpenPanel openPanel ];
//Image を作る
NSImage *img = [[[NSImage alloc] initWithSize:NSMakeSize( 100 , 100 )] autorelease];
NSBitmapImageRep *bmpRep;
NSData *dat;
//OpenPanel の結果のボタン番号
int opRet;
NSData *dat2;
NSArray* currentReps;
//OpenPanel でファイル選択
opRet = [ opImage runModalForDirectory : NSHomeDirectory() // どこのディレクトリを出すか
file : @"Pictures" // どのどのファイルを選択しておくか
types : imgTypes ]; // 選べるファイルタイプ
if ( opRet == NSOKButton ) { // OPENPanel のボタンが OK なら
//NSData を作ってファイルから読み込む
dat = [NSData dataWithContentsOfFile: [ opImage filename ] ];
bmpRep =[[[NSBitmapImageRep alloc] autorelease] initWithData:dat];
[img addRepresentation:bmpRep];
[image setImage:img];
currentReps=[img representations];
dat2=[NSBitmapImageRep TIFFRepresentationOfImageRepsInArray:currentReps ];
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>ApplicationKit>NSBitmapImageRep | 修正日2006.12.26 |