How can I draw a NSBitmapImageRep in a NSImageView?
NSImage *im = [[[NSImage alloc] init] autorelease];
[im addRepresentation:bitmapRep];
[imageView setImage:im];
Pretty easy:
NSImage *image = [[NSImage alloc] initWithCGImage:[bitmapRep CGImage] size:NSMakeSize(width,height)];
Then:
[imageView setImage:image];
Another possibility is by turning it into a TIFF ( - (NSData *)TIFFRepresentation ) and using that to create the NSImage object, but that could create quite some overhead.
Also keep in mind that the method of NSBitmapImageRep - (CGImageRef)CGImage is 10.5 or higher.
Edit:
For a cleaner solution look at @Ken's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With