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.

Figure 8-4. Composited video tracks with addMax graphics mode
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access