Hi all.
I'm bumping this up in the hope that I can find a solution to my problem.
To be clear, this is not a custom comp UI thing. I need to draw anti-aliased shapes, like lines & circles with various line thicknesses, and more importantly, text, into the effect output buffer. Drawing shapes is one thing I can probably do using the code I've already written, although it may not be the fastest way of doing things (or look the best!). What I'm completely in the dark about is how to render text. There's nothing in the SDK documentation about how to do this, with the exception of DrawBot (and we've already established cannot be used to draw into the output buffer).
I know it must be possible as there are standard AE effects that draw anti-aliased lines and shapes (Beam, Ellipse, Write-on) and older ones that render text (Basic Text). Question is, do these effects make use of OS drawing libraries like GDI+ and Quartz, and if so, how?
Thanks, Christian
hey christian.
it's not too complicated. let's give it a go.
basically, AE doesn't know, nor does it care what how you fill the output buffer.
so it's mostly not an AE question, but rather an OS drawing tools question.
the only part that concerns the AE API is the part where you copy your result into the output buffer. (we'll get to that)since you can only use OS drawing tools on OS drawing contexts, that's exactly what we'll do.
during the render call, you start the process by creating a new drawing bitmap context (i'll demonstrate on quartz. you'll get the general notion). you'll probably want to create it at the same size as the plug-in's output buffer. it's up to you.
allocate memory for the graphics context using the memory suite and use that memory handle with CGBitmapContextCreate(). (lookup some sample code. there's some periferial stuff to do there)
now that you have an os graphics buffer, you can start drawing.
CGContextShowTextAtPoint() will draw a string,
CGContextDrawPath() will draw a line, ect...
so.
now you have an invisible os graphics buffer filled with goodies you want to copy into the output buffer.
how do you do that?
well, remember that memory handle we mentioned earlier?
it now contains the filled buffer you just drew in. this is how you get the base address for the os graphics context.
osBufferBaseAddress = suites.HandleSuite1()->host_lock_handle(osBufferMemHandle);
take a look at the CCU sample (in the render function) to see how to access the output buffer directly in ram, and run through it.
just copy the value of each pixel from the context to the output buffer as the pixel pointer progresses. (it's all there in the CCU sample)
after the copying is done, rid of the context, free the memory, and you're done.
any questions?
no?
good.
:-)