Skip to main content
Inspiring
December 2, 2012
Answered

Non-Custom UI Drawing

  • December 2, 2012
  • 1 reply
  • 4152 views

Hi all.

My plugin requires certain things drawing to the comp, including circles, lines and (hopefully) text. However they are *not* part of a custom UI - in other words they can stay on-screen during a RAM preview, for example.

I've been looking into using Drawbot, but I'm not sure I can use it for this purpose, the reason being how do I get a drawing ref using suites.EffectCustomUISuite1()->PF_GetDrawingReference() without having a context (looks like the context is passed as part of a UI event, which I won't have)?

I've already written a bunch of code to draw pixels directly to the screen, which is working great so far, and I can go ahead and write functions for drawing shapes using this method; I was just wondering if I'm supposed to use Drawbot for non UI drawing, or if "rolling your own" is the way to go here.

Thanks,

Christian

This topic has been closed for replies.
Correct answer shachar carmi

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.

:-)


1 reply

Brainiac
December 3, 2012

hi christian.

your question is a bit fuzzy... i don't get if you're asking how to draw an interface even when AE is not asking for it,

or if you're asking how to use the system's drawing tools to draw into the rendered image.

so, what's drawbot really for?

it's only for graphic overlay of interfaces.

up to cs4, AE would hand you a copy of the platform specific graphic buffer of your target window, and you would draw on that buffer however you wanted. (usually using the OS API)

since cs5, you no longer have direct access to that graphic buffer, and you have no choice but to use drawbot to access it.

drawbot also offers some drawing tools so that you can fulfill most taks using solely it.

however, you can draw with whatever tools you want, and only copy the result to AE's graphic buffer using drawbot.

if youre trying to use these tools to render the output image of your plug-in, then drawbot is not your tool of choice, as it operates only on AE's internal interface graphics buffers.

i hope this answers your question.

Inspiring
December 3, 2012

Hi Shachar,

Thanks for responding.

I was asking about drawing directly into the effect's output image, not anything to do with custom UI. So you've answered my question - Drawbot is not the tool I need here. I've already started writing the code to draw the required shapes to the screen (just basic antialiased lines and shapes).

I was wondering how I'd handle doing what Drawbot does for pre-CS5 versions anyway (the guide is quite vague about this), so if I can get away with not using it, all the better!

Thanks for your help.

Christian

shachar carmiCorrect answer
Brainiac
January 20, 2013

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.

:-)