CoreImage:创建一个纯色的CIImage并在NSImageView中显示
我想以编程方式生成带有纯色填充的矩形图像。 我该怎么做? 我想用 inputImage 填充 inputImageView。
到目前为止,这是我的代码,但我得到的只是一个空的图像视图:
-(void) awakeFromNib{
CIColor *red = [CIColor colorWithRed:1 green:0 blue:0];
CIImage *redImage = [CIImage imageWithColor:red];
NSCIImageRep *ir = [NSCIImageRep imageRepWithCIImage:redImage];
[self setInputImage:[[NSImage alloc] initWithSize: NSMakeSize(25, 25)]];
//magic should be happening right here!
[[self inputImage] addRepresentation:ir];
[[self inputView] setImage:[self inputImage]];
[inputView setNeedsDisplay:YES];
}
I want to programatically generate a rectangular image with a solid color fill.
How can I do this?
I want to populate inputImageView with inputImage.
Here's my code so far, but all I get is an empty image view:
-(void) awakeFromNib{
CIColor *red = [CIColor colorWithRed:1 green:0 blue:0];
CIImage *redImage = [CIImage imageWithColor:red];
NSCIImageRep *ir = [NSCIImageRep imageRepWithCIImage:redImage];
[self setInputImage:[[NSImage alloc] initWithSize: NSMakeSize(25, 25)]];
//magic should be happening right here!
[[self inputImage] addRepresentation:ir];
[[self inputView] setImage:[self inputImage]];
[inputView setNeedsDisplay:YES];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)