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: Alpha for Carbon window...



So there is no way to "set" an alpha channel that will persist indefinitely (or at least until I change it) as the alpha mask of a window?

No, there is no way to do that. The operating system does not treat the alpha channel for the window as a separate channel. The alpha value is intimately tied to the color channels.

If not, does that mean that on every update/paint I have to supply the alpha as well as the rgb?

Think of it this way. On every update you have to draw the window. The colors that you use to draw the window can be translucent. There is no separation of the alpha channel from the color components... it's all one color.

If you draw into the window with QuickDraw it will set the alpha channel to fully opaque for every pixel you touch.

I'll be setting pixels manually... no quickdraw calls, no CG calls, etc.. both alpha and rgb.

I *think* that you can directly access the pixels through the GWorld's baseAddress then. If that doesn't work then you can set up the the pixel image in your own pixel buffer and create a CGImage from that pixel buffer then use Quartz to draw that image into your window.

When you get the paint event it will pass you a CGContext as a parameter to use. If you want to use CG to draw into any other GWorld you can use QDBeginCGContext to create a CG context... Draw your stuff and end it with a call to QDEndCGContext. (don't use QuickDraw calls between the Begin and End context calls).

Hmm.. I'm still not clear on that. If I'm passed a CGContext can I get the baseAddress and rowBytes (or similar) of the CGContext - or somehow else manually manipulate the raw pixels of the CGContext?

:-) :-) Read some basic Quartz documentation. :-) :-)

<http://developer.apple.com/documentation/GraphicsImaging/Conceptual/ drawingwithquartz2d/index.html>

The short answer is No.. you can't.

The longer answer is that a generic CGContext DOES NOT HAVE PIXELS for you to manipulate. A CGContext is an idealized drawing environment in which you draw in a virtual coordinate space (called User Space).

A CGContext may be drawing into a bitmap on screen, a page on a printer, or a PDF file on disk. Only one of these, drawing into a bitmap, has the concept of pixels. The printer and PDF file don't have pixels at all. The same CGContext abstraction can be used to draw into any of them.

As I mentioned above, if you want pixel-level control then what you are going to want to do is create your own memory buffer (using malloc). Then you can create a CGImage from that buffer using CGImageCreate. Then you can draw that image into any context (even the one you get from kEventWindowPaint) using CGDrawImage.

--
Macintosh Software Engineering Contractor for Hire
Resume available at <http://homepage.mac.com/easco/RSTResume.html>
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Alpha for Carbon window... (From: Ando Sonenblick <email@hidden>)
 >Re: Alpha for Carbon window... (From: Ricky Sharp <email@hidden>)
 >Re: Alpha for Carbon window... (From: Scott Thompson <email@hidden>)
 >Re: Alpha for Carbon window... (From: Ando Sonenblick <email@hidden>)
 >Re: Alpha for Carbon window... (From: Scott Thompson <email@hidden>)
 >Re: Alpha for Carbon window... (From: Ando Sonenblick <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.