macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initWithFocusedViewRect:

INDEX>AppKit>NSBitmapImageRep

フォーカスされているビューからビットマップ画像を初期化して返します
-(id)initWithFocusedViewRect:(NSRect)rect:

解説

フォーカスされているビューからビットマップ画像を初期化して返します。

返り値

( id )

NSBitmapImageRep

引数

( NSRect )rect

範囲

フレームワーク

ApplicationKit

クラス

NSBitmapImageRep

Instance Methods

使用可能

10.0

参照

例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{

    //Imageを作る
    NSImage      *img = [[NSImage alloc] initWithSize:NSMakeSize(200,200)];
    NSBitmapImageRep *bmpRep;

    [[[sender window] contentView] lockFocus];
     bmpRep =[[NSBitmapImageRep alloc] initWithFocusedViewRect:[image frame]];
    [[[sender window] contentView] unlockFocus];
    [img addRepresentation:bmpRep];
    [image setImage:img];
        NSLog([NSString stringWithFormat:@"bit / pixel:%d",[bmpRep bitsPerPixel]]);

}

@end