// first record at 0 hrs, 0 min, 0 sec, 0 frames
TimeCodeTime tcTime = new TimeCodeTime (0, 0, 0, 0);
// create time code track and media
Track tcTrack = movie.addTrack (width, height, 0);
TimeCodeMedia tcMedia = new TimeCodeMedia (tcTrack, timescale);
TimeCoder timeCoder = tcMedia.getTimeCodeHandler();
int style = 0;
if (fontOptions.equalsIgnoreCase("plain"))
{
style = QDConstants.normal;
} // if (fontOptions.equalsIgnoreCase("plain"))
else if (fontOptions.equalsIgnoreCase("bold"))
{
style = QDConstants.bold;
} // else if (fontOptions.equalsIgnoreCase("bold"))
else if (fontOptions.equalsIgnoreCase("italic"))
{
style = QDConstants.italic;
} // else if (fontOptions.equalsIgnoreCase("italic"))
else if (fontOptions.equalsIgnoreCase("bolditalic"))
{
style = QDConstants.bold | QDConstants.italic;
} // else if (fontOptions.equalsIgnoreCase("bolditalic"))
else if (fontOptions.equalsIgnoreCase("underline"))
{
style = QDConstants.underlined;
} // else if (fontOptions.equalsIgnoreCase("underline"))
else if (fontOptions.equalsIgnoreCase("boldunderline"))
{
style = QDConstants.underlined | QDConstants.bold;
} // else if (fontOptions.equalsIgnoreCase("boldunderline"))
else if (fontOptions.equalsIgnoreCase("italicunderline"))
{
style = QDConstants.underlined | QDConstants.italic;
} // else if (fontOptions.equalsIgnoreCase("italicunderline"))
else if (fontOptions.equalsIgnoreCase("bolditalicunderline"))
{
style = QDConstants.underlined| QDConstants.italic | QDConstants.bold;
} // else if (fontOptions.equalsIgnoreCase("bolditalicunderline"))
// turn on time code display, set colors
timeCoder.setFlags(timeCoder.getFlags() | StdQTConstants.tcdfShowTimeCode,
StdQTConstants.tcdfShowTimeCode);
TCTextOptions tcTextOptions = timeCoder.getDisplayOptions();
tcTextOptions.setTXSize(fontSize);
tcTextOptions.setTXFace(style);
tcTextOptions.setTXFont(QDFont.getFNum(fontName));
tcTextOptions.setForeColor(new QDColor(fgColor[0] / 255f, fgColor[1] / 255f,
fgColor[2] / 255f));
// if transparency is indicated, set background color to a special value
if (bgColor[0] == -1)
{
tcTextOptions.setBackColor(new QDColor(0.1f, 0.7f, 0.43f));
} // if (bgColor[0] == -1)
else
{
tcTextOptions.setBackColor(new QDColor(bgColor[0] / 255f,
bgColor[1] / 255f, bgColor[2] / 255f));
} // else
timeCoder.setDisplayOptions(tcTextOptions);
// set up a sample as a 4-byte array in a QTHandle
int frameNumber = timeCoder.toFrameNumber(tcTime, tcDef);
int frameNums[] = new int[1];
// BOOK ERRATA: this is buggy on Windows for time codes other
// than 00:00:00;00. You need to adjust for endianness, as
// seen in the revised (uncommented) line.
// frameNums[0] = frameNumber;
frameNums[0] = EndianOrder.flipNativeToBigEndian32(frameNumber);
QTHandle frameNumHandle = new QTHandle (4, false);
frameNumHandle.copyFromArray(0, frameNums, 0, 1);
// create a time code description (sample to be added)
TimeCodeDescription tcDesc = new TimeCodeDescription();
tcDesc.setTimeCodeDef (tcDef);
// add the sample to the TimeCodeMedia
tcMedia.beginEdits();
tcMedia.addSample(frameNumHandle, 0, frameNumHandle.getSize(),
movie.getDuration(), tcDesc, 1, 0);
tcMedia.endEdits();
// insert media into track
tcTrack.insertMedia(0, 0, tcMedia.getDuration(), 1);
// set a transparent-background GrahpicsMode
QDRect moveFrom = new QDRect(0, 0, width, height);
QDRect moveTo = new QDRect(x, y, width, height);
Matrix matrix = new Matrix();
matrix.rect(moveFrom, moveTo);
tcTrack.setMatrix (matrix);
// if transparency is indicated, make the special value the transparent
// color
if (bgColor[0] == -1)
{