bool qtCanvas::Impl::setupTrack() { mTrack = NewMovieTrack(mMovie, FixRatio(mWidth,1), FixRatio(mHeight,1), (short)kNoVolume); if (!CheckMoviesError("NewMovieTrack")) return false; SCTemporalSettings temporal; SCGetInfo(mSCComponent, scTemporalSettingsType, &temporal); mMedia = NewTrackMedia(mTrack, VideoMediaType, (TimeScale)temporal.frameRate, nil, 0); if (!CheckMoviesError("NewTrackMedia" )) return false; MediaHandler mh = GetMediaHandler(mMedia); if (!CheckMoviesError("GetMediaHandler")) return false; ComponentResult err; err = MediaSetGraphicsMode(mh, graphicsModePreMulColorAlpha, NULL); if (!CheckError(err, "MediaSetGraphicsMode")) return false; BeginMediaEdits(mMedia); if (!CheckMoviesError("BeginMediaEdits" )) return false; return true; }
OSErr QTTarg_AddTextToggleButtonTrack (Movie theMovie) { Track myTrack = NULL; Media myMedia = NULL; MatrixRecord myMatrix; RGBColor myKeyColor; Fixed myWidth, myHeight; TimeValue myDuration = 0L; TimeValue myTimeScale = 0L; OSErr myErr = noErr; ////////// // // get some information about the target movie // ////////// if (theMovie == NULL) { myErr = paramErr; goto bail; } myWidth = Long2Fix(2 * kButtonWidth); myHeight = Long2Fix(2 * kButtonHeight); myDuration = GetMovieDuration(theMovie); myTimeScale = GetMovieTimeScale(theMovie); ////////// // // create a new sprite track in the target movie // ////////// myTrack = NewMovieTrack(theMovie, myWidth, myHeight, kNoVolume); myMedia = NewTrackMedia(myTrack, SpriteMediaType, myTimeScale, NULL, 0); // set the track matrix to compensate for any existing movie matrix GetMovieMatrix(theMovie, &myMatrix); if (InverseMatrix(&myMatrix, &myMatrix)) SetTrackMatrix(myTrack, &myMatrix); myErr = BeginMediaEdits(myMedia); if (myErr != noErr) goto bail; ////////// // // add sprite images and sprites to the sprite track; add actions to the sprites // ////////// QTTarg_AddTextButtonSamplesToMedia(myMedia, 2 * kButtonWidth, 2 * kButtonHeight, myDuration); ////////// // // insert media into track // ////////// myErr = EndMediaEdits(myMedia); if (myErr != noErr) goto bail; // add the media to the track InsertMediaIntoTrack(myTrack, 0, 0, GetMediaDuration(myMedia), fixed1); ////////// // // set the sprite track properties // ////////// QTTarg_SetTrackProperties(myMedia, kNoQTIdleEvents); // no idle events myKeyColor.red = myKeyColor.green = myKeyColor.blue = 0xffff; // white MediaSetGraphicsMode(GetMediaHandler(myMedia), transparent, &myKeyColor); // make sure that the sprite track is in the frontmost layer SetTrackLayer(myTrack, kMaxLayerNumber); SetTrackLayer(myTrack, QTTarg_GetLowestLayerInMovie(theMovie) - 1); bail: return(myErr); }
OSErr QTTarg_MakeDualVRControllerMovie (void) { Movie myMovie = NULL; Track myTrack = NULL; Media myMedia = NULL; RGBColor myKeyColor; Fixed myWidth, myHeight; FSSpec myFile; Boolean myIsSelected = false; Boolean myIsReplacing = false; StringPtr myPrompt = QTUtils_ConvertCToPascalString(kSpriteSavePrompt); StringPtr myFileName = QTUtils_ConvertCToPascalString(kSpriteSaveMovieFileName); long myFlags = createMovieFileDeleteCurFile | createMovieFileDontCreateResFile; short myResRefNum = 0; short myResID = movieInDataForkResID; OSType myType = FOUR_CHAR_CODE('none'); OSErr myErr = noErr; ////////// // // create a new movie file // ////////// // prompt the user for the destination file name QTFrame_PutFile(myPrompt, myFileName, &myFile, &myIsSelected, &myIsReplacing); myErr = myIsSelected ? noErr : userCanceledErr; if (!myIsSelected) goto bail; // create a movie file for the destination movie myErr = CreateMovieFile(&myFile, FOUR_CHAR_CODE('TVOD'), smSystemScript, myFlags, &myResRefNum, &myMovie); if (myErr != noErr) goto bail; // select the "no-interface" movie controller myType = EndianU32_NtoB(myType); SetUserDataItem(GetMovieUserData(myMovie), &myType, sizeof(myType), kUserDataMovieControllerType, 1); ////////// // // get some information about the target movie // ////////// myWidth = Long2Fix(kVRControlMovieWidth); myHeight = Long2Fix(kVRControlMovieHeight); ////////// // // create a new sprite track in the target movie // ////////// myTrack = NewMovieTrack(myMovie, myWidth, myHeight, kNoVolume); myMedia = NewTrackMedia(myTrack, SpriteMediaType, kVRControlMovieDuration, NULL, 0); myErr = BeginMediaEdits(myMedia); if (myErr != noErr) goto bail; ////////// // // add sprite images and sprites to the sprite track; add actions to the sprites // ////////// QTTarg_AddVRControllerButtonSamplesToMedia(myMedia, kVRControlMovieWidth, kVRControlMovieHeight, kVRControlMovieDuration); ////////// // // insert media into track // ////////// myErr = EndMediaEdits(myMedia); if (myErr != noErr) goto bail; // add the media to the track InsertMediaIntoTrack(myTrack, 0, 0, GetMediaDuration(myMedia), fixed1); ////////// // // set the sprite track properties // ////////// QTTarg_SetTrackProperties(myMedia, 0); // idle as fast as possible myKeyColor.red = myKeyColor.green = myKeyColor.blue = 0xffff; // white MediaSetGraphicsMode(GetMediaHandler(myMedia), transparent, &myKeyColor); ////////// // // add the movie resource to the movie file // ////////// myErr = AddMovieResource(myMovie, myResRefNum, &myResID, myFile.name); bail: if (myResRefNum != 0) CloseMovieFile(myResRefNum); if (myMovie != NULL) DisposeMovie(myMovie); free(myPrompt); free(myFileName); return(myErr); }
/* call-seq: enable_alpha() Enable the straight alpha graphic mode for this track. This is best used on an overlayed video track which includes some alpha transparency (such as in a PNG image). */ static VALUE track_enable_alpha(VALUE obj) { MediaSetGraphicsMode(GetMediaHandler(TRACK_MEDIA(obj)), graphicsModeStraightAlpha, 0); return obj; }