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];
}
1 Answer