cocoa - Is there an API to do per-pixel Alpha Blend on GTK and OSX? -
I want to draw a transparent window (with alpha channel) on Linux (GTK) and OSX. Is there an API to do this? Note that I do not want to set a global transparency, alpha level should be set per pixel.
As an example, I am looking for similar types of APIs from the UpdateLayeredWindow function on Windows:.
For Mac OS X, see sample code. This works by using a custom fully transparent window and drawing shapes in it. Although the example uses only shapes with hard edges + overall alpha, arbitrary alpha can be used.
Though uses a custom window, but you can use the same technique to call the code and use holes in normal windows. > SetOpaque: No . Hacky example:
@implementation ClearView - (zero) drawRect: (NSRect) rect {if (mask == zero) mask = [[NSImage imageNamed: @ "mask"] maintained]; [Self. Window set opaque: no]; [Mask Drynrift: Self. Bound lines: (NSRact) {{0}, mask size} Operation: NSC Composite Cop Excerpt: 1.0]; } @end
The primary limitation of this technique is that the standard drop shadow does not interact well with alpha-mixed edges.
Comments
Post a Comment