Re: drawing in an FXPlug Filter
Re: drawing in an FXPlug Filter
- Subject: Re: drawing in an FXPlug Filter
- From: Darrin Cardani <email@hidden>
- Date: Mon, 28 Mar 2011 09:04:10 -0700
On Mar 28, 2011, at 8:54 AM, Rainer Standke wrote:
> Hello,
>
> I am trying to write filter that leaves the image unchanged, but puts a bit of text in the image. I am already doing the something similar in a generator, where I am following closely what happens in the Scrolling Text sample code. There, the FXImage passed in gets turned into an NSGraphicscontext, and I do my drawing on that.
>
> In a filter I get passed an input image and an output image. I am wondering how I can get the data in the input image into the output image. There are 2 scenarios I can think of:
>
> - get a dataPtr from the input image, and set the dataPtr on the output image to the same, then turn the output image into a NSGraphicsContext, and draw. This seems the easiest, and most expedient.
>
> - create NSGraphicsContext for both input & output, create a NSImageRep fro the input, draw that in the output image. Seems convoluted?
>
> Or is there yet another way? I am very much a newbie to drawing and image manipulation, so any advice would be ver much appreciated.
Excellent question! Unfortunately, the first way will likely get you into big trouble. In Motion, at least, the app owns the data for the input and output images, and knows when it can dispose of each. So if you go around changing it behind the app's back, it can leak or worse. (In the future it may become hard or impossible to do this, anyway.)
The second way is the way to do it. Yes, it's convoluted and slower, but we don't have a mechanism that says, "This plug-in can operate in-place." That might be really handy some day. Most of the color correction filters (in fact, anything pixel independent) should theoretically be able to do that. (I'm not sure how OpenGL would handle that in hardware, though. I think I just might have to ask the OpenGL folks about that!) But alas, we don't yet support it.
Darrin
--
Darrin Cardani
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden