I have an NSImageView in the lower left with a red background. In the screenshot it is displaying a PDF document.
I want the shape of the document filled in white white, instead it is transparent and the red background bleeds through the document. How do I force the PDF to not be transparent?
Or the more general question, how do I get the NSImageView to fill transparent images with a solid color. My current strategy is to create a new image the same size with a white background and draw the original image on top and then use the new image in the image view. Is there a better way?
NSImage* newImage = [[NSImage alloc] initWithSize:[image size]];
[newImage lockFocus];
[[NSColor whiteColor] set];
CGRect rc = NSMakeRect(0,0,[newImage size].width, [newImage size].height);
NSRectFill(rc);
[image drawInRect:rc];
[newImage unlockFocus];
image = newImage;