View Full Version : iTunes Visual Plugin Difficulties

Jun 9, 2008, 02:05 AM
I'm currently working on a visualizer plugin for iTunes.

I have most of it working, but i need a way to draw a transparent black rectangle. (For a nice fade-out effect)

I haven't been able to find what I need in any of the API references - That is, I'm not sure if I should have 2 large bitmaps (one all black, one light grey as an alpha channel) and call CopyMask, or wether I should do something with CoreGraphics (in which case I don't know where to start, I haven't used any of OSX's "Core" APIs yet.

Any help would be greatly appreciated.

Jun 9, 2008, 08:19 AM
Some good and bad news:
1, i figured out how to use Quartz to do the fading, but it's slowing things down horribly.

Here's the code I used:

GrafPtr oldPort;
GDHandle oldDevice;
Rect srcRect;
RGBColor foreColor;
short j;
long vw, vh, hw, hh, hs, hd;
CGContextRef cgc;
CGRect fadeRect;
CGColorRef chroma;
OSErr err;
float fadeColor[4];

srcRect = *destRect;

GetGWorld(&oldPort, &oldDevice);
SetGWorld(destPort, nil);

vw = srcRect.right - srcRect.left;
vh = srcRect.bottom - srcRect.top;
hw = vw/2;
hh = vh/2;
hs = hw+hh;
hd = hw-hh;

err = CreateCGContextForPort(destPort,&cgc);
if (err == noErr)
fadeColor[0] = 0.0;
fadeColor[1] = 0.0;
fadeColor[2] = 0.0;
fadeColor[3] = 0.03;

chroma = CGColorCreate(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB),fadeColor);
fadeRect = CGRectMake(0,0,vw,vh);
foreColor.red = foreColor.green = foreColor.blue = 0;

any reason why this would cause a slowdown, and any possible fixes?

And I suppose I should ask: is calling CoreGraphics here before doing the rest of my drawing with QuickDraw a bad idea?