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)
{
timeCoder.setGraphicsMode(new GraphicsMode(QDConstants.transparent,
new QDColor(0.1f, 0.7f, 0.43f)));
} // if (bgColor[0] == -1)
return movie;
} // addTimeCode(Movie, String, String, int, int[], int[], int, int, int, int)