NSview または NSImageView で画像を表示したい。私のヘッダーファイルには
@interface FVView : NSView
{
NSImageView *imageView;
}
@end
実装ファイルで私がやろうとしていたことは次のとおりです。
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
(Here I get an image called fitsImage........ then I do)
//Here I make the image
CGImageRef cgImage = CGImageRetain([fitsImage CGImageScaledToSize:maxSize]);
NSImage *imageR = [self imageFromCGImageRef:cgImage];
[imageR lockFocus];
//Here I have the view context
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
//Here I set the via dimensions
CGRect renderRect = CGRectMake(0., 0., maxSize.width, maxSize.height);
[self.layer renderInContext:ctx];
[imageR unlockFocus];
CGContextDrawImage(ctx, renderRect, cgImage);
CGImageRelease(cgImage);
}
スクリプトを実行しても、NSview ウィンドウに何も表示されません。エラーはまったくありません。何が間違っているのかわかりません。5.1.1 の私の Xcode バージョン
CGImageRef を操作してウィンドウまたは nsview で表示する方法を学習しようとしています。
ありがとうございました。