drawAtPoint:fromRect:operation:fraction:
画像を表示します(NSAffineTransformで回転を適用可能)
-(void)drawAtPoint:(NSPoint)aPoint: fromRect:(NSRect)fromRect: operation:(NSCompositingOperation)op: fraction:(float)delta:

ディジタル画像処理の基礎と応用―基本概念から顔画像認識まで (ディジタル信号処理シリーズ)
- 作者: 酒井幸市
- 出版社/メーカー: CQ出版
- 発売日: 2007/02
- メディア: 単行本
- 購入: 1人 クリック: 1,336回
- この商品を含むブログ (8件) を見る
解説
画像を表示します(NSAffineTransformで回転を適用可能)
【NSCompositingOperation】合成方法
● NSCompositeClear クリアする
● NSCompositeCopy 透明度を無視して上書きする
● NSCompositeSourceOver 透明度を考慮してして上書きする
● NSCompositeDestinationOver
● NSCompositeSourceIn 透明度を無視して上書きする
● NSCompositeDestinationIn 色があるところは切り抜き
● NSCompositeSourceOut クリアする
● NSCompositeDestinationOut 色があるところはクリア
● MSCompositeSourceAtop 透明度を考慮してして上書きする
● NSCompositeDestinationAtop
● NSCompositeXOR
● NSCompositePlusDarker
● NSCompositeHighlight
● NSCompositePlusLighter
NSAffineTransformで回転させる場合。
変換マトリックを作って、その後フォーカスしているビューにsetする。
NSAffineTransform *affin = [NSAffineTransform transform];
[affin rotateByDegrees:10.0];
[affin set];
[thePath transformUsingAffineTransform: affin];
返り値
( void )
なし
引数
( NSPoint )aPoint
表示位置
( NSRect )fromRect
表示元範囲
( NSCompositingOperation )op
合成方法
( float )delta
不透明度
フレームワーク
ApplicationKit
クラス
NSImage
Instance Methods
使用可能
10.0
参照
- compositeToPoint:fromRect:operation:fraction:
- dissolveToPoint:fraction:
例文
#import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { //開けるファイル拡張子の配列 NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ]; //OpenPanelを作る NSOpenPanel *opImage = [ NSOpenPanel openPanel ]; //Imageを作る NSImage *img; NSImage *img2; //OpenPanelの結果のボタン番号 int opRet; //OpenPanelでファイル選択 opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Pictures" //どのどのファイルを選択しておくか types : imgTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら //NSImageを作ってファイルから読み込む img = [ [ NSImage alloc ] initWithContentsOfFile: [ opImage filename ] ]; //NSImageをバンドルファイルからつくる img2 = [NSImage imageNamed: @"NSApplicationIcon" ]; //imgを描画対象にする [img lockFocus]; //描画対象にimg2を合成する [img2 drawAtPoint:NSMakePoint(10,100) fromRect:NSMakeRect(0.0,0.0,80.0,80.0) operation:NSCompositeXOR fraction:0.5 ]; //合成後のimgをImageViewに表示する [image setImage:img]; //imgを描画から外す [img unlockFocus]; } } @end