Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
TextConverterMain.c
/* Sample program that demonstrates creating "burnt" text tracks for a QuickTime movie. |
The program puts up a file dialog. The user selects a text track movie to be converted. |
A second dialog then appears asking for a destination movie file as well as giving the |
user some options for selecting anti-alias, drop shadow, and what compressor to |
use for the burnt text. The default is the graphics compressor. |
*/ |
#include <Movies.h> |
#include <ImageCompression.h> |
#include <QuickTimeComponents.h> |
#include "ConvertTextMovie.h" |
pascal short SaveDialogHook(short item, DialogPtr dlg, void *myData); |
pascal void Doit(FSSpec *srcFileSpec); |
Boolean gDoAntiAlias; |
Boolean gDoDropShadow; |
Boolean gImageTrack; |
SCSpatialSettings gSpatial; |
void main(void) |
{ |
FSSpec srcFileSpec; |
Point where; |
SFTypeList types; |
SFReply reply; |
InitGraf(&thePort); |
InitFonts(); |
InitWindows(); |
InitMenus(); |
TEInit(); |
InitDialogs(0L); |
InitCursor(); |
MaxApplZone(); |
EnterMovies(); |
gDoAntiAlias = false; |
gDoDropShadow = false; |
gImageTrack = false; |
types[0] = MovieFileType; |
where.h = where.v = -2; |
// The prompt field is ignored - isn't that swell? |
SFGetFilePreview(where, (StringPtr)"\pPick a Text Track Movie", 0, 2, types, 0, &reply); |
if (!reply.good) goto bail; |
FSMakeFSSpec(reply.vRefNum, 0, reply.fName, &srcFileSpec); |
Doit(&srcFileSpec); |
bail: |
ExitMovies(); |
} |
pascal void ChooseCompressor(void); |
pascal void ChooseCompressor(void) |
{ |
ComponentInstance ci = 0; |
Point pt; |
OSErr err; |
ci = OpenDefaultComponent(StandardCompressionType,StandardCompressionSubType); |
if (!ci) return; |
SCSetInfo(ci,scSpatialSettingsType,&gSpatial); |
pt.h = pt.v = -1; |
SCSetInfo(ci,scWindowPositionType,&pt); |
err = SCRequestImageSettings(ci); |
if (err == 0) |
SCGetInfo(ci,scSpatialSettingsType,&gSpatial); |
if (ci) CloseComponent(ci); |
} |
#define kSaveDialogID (456) |
#define kAntiAliasCheckBox (13) |
#define kDropShadowCheckBox (14) |
#define kImageTrackCheckBox (16) |
#define kCompressionBtn (17) |
pascal short SaveDialogHook(short item, DialogPtr dlg, void *myData) |
{ |
Handle itemToChange; /* needed for GetDItem and SetCtlValue */ |
Rect itemBox; /* needed for GetDItem */ |
short itemType; /* needed for GetDItem */ |
if (GetWRefCon(dlg) == sfMainDialogRefCon) |
{ |
if (item == sfHookFirstCall) |
{ |
GetDItem( dlg, kAntiAliasCheckBox, &itemType, (Handle*)&itemToChange, &itemBox); |
SetCtlValue( (ControlHandle)itemToChange, gDoAntiAlias); |
GetDItem( dlg, kDropShadowCheckBox, &itemType, (Handle*)&itemToChange, &itemBox); |
SetCtlValue( (ControlHandle)itemToChange, gDoDropShadow); |
} |
else if (item == kAntiAliasCheckBox) |
{ |
GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox); |
gDoAntiAlias = !GetCtlValue((ControlHandle)itemToChange); |
SetCtlValue( (ControlHandle)itemToChange, gDoAntiAlias); |
} |
else if (item == kDropShadowCheckBox) |
{ |
GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox); |
gDoDropShadow = !GetCtlValue((ControlHandle)itemToChange); |
SetCtlValue( (ControlHandle)itemToChange, gDoDropShadow); |
} |
else if (item == kImageTrackCheckBox) |
{ |
GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox); |
gImageTrack = !GetCtlValue((ControlHandle)itemToChange); |
SetCtlValue( (ControlHandle)itemToChange, gImageTrack); |
} |
else if (item == kCompressionBtn) |
{ |
ChooseCompressor(); |
} |
} |
bail: |
return item; |
} |
pascal void Doit(FSSpec *srcFileSpec) |
{ |
SFTypeList types; |
Str255 newName; |
FSSpec dstFileSpec; |
Point where; |
StandardFileReply sfr; |
long displayFlags = 0; |
gSpatial.codecType = 'smc '; |
gSpatial.codec = 0; |
gSpatial.depth = 8; |
gSpatial.spatialQuality = 1023; |
types[0] = MovieFileType; |
where.h = where.v = -1; |
BlockMove(srcFileSpec->name, newName, srcFileSpec->name[0]+1); |
BlockMove("(Bitmap)", &newName[newName[0]+1], 8); |
newName[0] += 8; |
CustomPutFile((StringPtr)"\pName the destination movie", newName, &sfr, kSaveDialogID, where, SaveDialogHook, |
nil, (short *)nil, (ActivateYDProcPtr)nil, (void *)nil); |
if (!sfr.sfGood) return; |
if (gDoAntiAlias) displayFlags |= dfAntiAlias; |
if (gDoDropShadow) displayFlags |= dfDropShadow; |
ConvertMovie(srcFileSpec, &sfr.sfFile, displayFlags, gImageTrack, &gSpatial); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14