NSImage question
NSImage question
- Subject: NSImage question
- From: Jeff Laing <email@hidden>
- Date: Thu, 29 Mar 2007 10:11:13 +1000
I'm currently trying to come to grips with NSImage.
I have an NSImageView that I want to display an NSImage which may be bigger
or smaller than the view area - the image is created from RGBA data and I'm
confident that its built correctly because I've successfully export it to
.png, .gif, .jpg, .tiff and in each case the transparency information came
through as expected.
Now, I need to be able to scale the large NSImage's down to display them in
my NSImageView. I can't just use the setImageScaling: on the image view, I
want to have more than one of my NSImages with different scales, displayed
simultaneously in the same NSImageView - think "thumbnail display", or
"combined graphic preview page". I expect to create a new NSImage, draw 2
or more scaled NSImages into it, then get the NSImageView to display the
composite image.
When I used drawInRect:fromRect:operation: to scale the images down I found
gritty gray spots happening round the edges and I believe that they are
caused by the way the scaling handles the alpha mask.
When I use compositeToPoint:operation: the resulting image displays
correctly, but of course is not scaled down.
My best guess at the moment is:
- image 1 is my RGBA data
- create image 2 with the same size as image 1
- fill image 2 with white
- compositePoint:operation image 1 into image 2
- create image 3 with the target size
- drawInRect:fromRect:operation: image 2 into image 3
This seems ludicrously expensive - is there a better way? Preferably 10.3
compatible if possible?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden