Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PICT Resource and Bevel Button




On Mar 25, 2007, at 3:45 PM, Dair Grant wrote:

Durango wrote:

The archives have lots of info on issues with bevel buttons and icons,
but no one has mentioned the symptom I'm seeing.


Everything works fine on PPC. On Intel my bevel buttons with PICT
resources are ignoring the alpha channel. Where alpha is zero, I just
get a default gray background--which isn't even the proper control
color I've set. Doesn't really seem like a byte-swap issue, but it's
definitely Intel-only.

QD doesn't really support an alpha channel, and although you can put 32-bit pixels into a PICT the alpha byte isn't meaningful.

Historically QD has let you get away with keeping data in those bytes -
but only in so far as it won't generally trash it outright.


I suspect on Intel there's some point inside QD where those undefined
bytes are being normalised as they pass through, so you end up losing
that information.


There are hundreds of button images to deal with in this app, so I'm
looking for a way to avoid having to convert all of them to another
format.

I guess I can use a kEventControlDraw handler and draw the PICT
myself, but that doesn't help if the alpha handling bug remains.

If you can successfully get the alpha channel out of your PICT data on
Intel, then you could use kEventControlDraw to override the normal
drawing path (creating a CGImageRef out of the 32-bit pixels in the PICT
data, then draw that vs drawing the PICT directly).


If the alpha is mangled when the PICT is loaded, you might need to write
your own loading code too.


In the longer term, you could convert them all to .png and use
CGImageCreateWithPNGDataProvider to get a CGImageRef for the button.

Another option, which works prior to 10.4 (which is when I believe bevel buttons started supporting CGImageRefs) is to convert them to 'icns' resources and create IconRefs with them. IconRefs can be used in bevel buttons in all versions of Mac OS X. You can write a very simple function to convert your 'PICT' resources to 'icns' resources, and you won't end up with hundreds of little image files (if you *like* the idea of hundreds of little image files or want to get away from using resources, you can convert them to .icns files). You also get the benefit of full transparency with 'icns' resources. I used to use 'PICT' resources for bevel buttons and found they just didn't look very good in Mac OS X.


Larry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: PICT Resource and Bevel Button (From: Dair Grant <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.