今度はツールバーを増やし出力オプションを追加する。
まずはウィンドウの影の制御(Winow Shadow)から。
これは SimpleCap内部で使っている CGWindowListCreateImageFromArray( ) 関数の第三引数で制御できる。
CGWindow.h
enum {
kCGWindowImageDefault = 0, /* Default behavior: If a rect of CGRectNull is used
* bounds computation includes the framing effects, such as a shadow. */
kCGWindowImageBoundsIgnoreFraming = (1 << 0), /* If a rect of CGRectNull is used,
* ignore framing effects for bounds computation */
kCGWindowImageShouldBeOpaque = (1 << 1), /* The captured image should be
* opaque. Empty areas are white */
kCGWindowImageOnlyShadows = (1 << 2)
};
オプションの種類は全部で4つ。挙動は以前ブログで紹介したことがある。
CGWindowListCreateImage のオプション
今回はこのうちの kCGWindowImageDefault(影あり)とkCGWindowImageBoundsIgnoreFraming(影無し)を使おう。以前リファクタリングした時に CGWindowListCreateImageFromArray( ) の利用はハンドラのベースクラス HandlerBase#cgimageWithWindowList:cgrect へまとめてある。ここだけを変更すれば良い。
HandlerBase.m
- (CGImageRef)cgimageWithWindowList:(NSArray*)list cgrect:(CGRect)cgrect
{ CGWindowImageOption option;
if ([[UserDefaults valueForKey:UDKEY_WINDOW_SHADOW] intValue] == 1) {
option = kCGWindowImageDefault;
} else {
option = kCGWindowImageBoundsIgnoreFraming;
}
:
CGImageRef cgimage = CGWindowListCreateImageFromArray(cgrect, windowIDsArray, option);
:
実行してみる。
影あり

影無し

良さそうだ、