Overlaying Video Tracks
When one video track is drawn on top of another, the top
doesn’t necessarily have to obscure the bottom.
QuickTime gives you the option of specifying a
GraphicsMode
to combine pixels from multiple video
layers to create interesting effects.
How do I do that?
You can create a GraphicsMode
object to describe
the means of combining overlapping colors. To try it out, take the
previous lab’s code and replace all the matrix stuff
(after the foreTrack
and
backTrack
are created, but before the
MovieController
is created) with the following:
GraphicsMode gm = new GraphicsMode (QDConstants.addMax, QDColor.green); VisualMediaHandler foreHandler = (VisualMediaHandler) foreTrack.getMedia( ).getHandler( ); foreHandler.setGraphicsMode(gm); foreTrack.setLayer(-1);
Note
Run this example with ant run-ch08-composit-evideotracks.
When run, this sample program asks you to open two movies, then creates a new movie with video tracks from the source movies’ media, and combines the pixels of the foreground movie with the background, so the foreground appears atop the background. The result is shown in Figure 8-4.
What just happened?
Setting a GraphicsMode
instructs QuickTime to
apply a specific behavior to combine overlapping pixels. The
GraphicsMode
has a
“mode” int
,
which indicates which kind of behavior to use, and a
QDColor
that is used by some behaviors to indicate
a color to operate on. For example, you might use mode
QDConstants.transparent
and
QDColor.green
to make all green pixels ...
Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.