Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?
Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?
- Subject: Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?
- From: Peter N Lewis <email@hidden>
- Date: Wed, 28 Oct 2009 14:33:33 +0800
On 28/10/2009, at 14:00 , Graham Cox wrote:
On 28/10/2009, at 4:49 PM, Peter N Lewis wrote:
a) composite two images, preferably while keeping the different
resolutions of the icon
b) how to dim an image similarly to kTransformDisabled
I'm unclear what you mean by a), but certainly compositing NSImage
into another one or into a view/context is trivial.
An NSImage (potentially) contains multiple resolutions (eg 16x16,
128x128, 512x512). Especially if it is created from an IconRef.
What trivial way is there to take two NSImages and composite one on
top the other and retain this multiple resolution facility? The only
compositing method I see for NSImage is the carious drawInRect/
drawAtPoint/drawRepresentation (and the deprecated composite variants)
that all require a specified size). So as near as I can figure it, to
properly composite two NSImages, you would have to do something like:
scan through all the representations of each image and union all the
sizes
scan through all those sizes and composite the two NSImages at that size
create a union NSImage.
Possible, but fairly ugly, and not entirely trivial. Is this the only
way.
On b), you'd probably have to experiment but I would bet that a
straightforward combination of the compositing operation and the
alpha value would achieve this. It's been a good long while since I
wrote anything in Carbon, but I seem to recall that the disabled
look was a lowered contrast, semi-grayed appearance. If that's the
case, you can easily get that using the above.
Yes, I would guess some compositing operation with some magic numbers
to dim out the image would presumably work. It would be nice to
actually be consistent with the system on this though, without having
to hard code a bunch of magic numbers. I see Snow Leopard will now
dim NSImageCell's without borders - it'd be nice to know how they draw
these dimmed images.
Peter.
--
Clipboard Switching and Macros with Keyboard Maestro
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.stairways.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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