13.07.2015 Views

Quicktime File Format (2012-08-14).pdf

Quicktime File Format (2012-08-14).pdf

Quicktime File Format (2012-08-14).pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Some Useful Examples and ScenariosCreating, Copying, and Disposing of Atom ContainersYou can use the QTCountChildrenOfType and QTGetNextChildType functions to retrieve informationabout the types of an atom’s children. The QTCountChildrenOfType function returns the number of childrenof a given atom type for a parent atom. The QTGetNextChildType function returns the next atom type inthe child list of a parent atom.You can use the QTFindChildByIndex, QTFindChildByID, and QTNextChildAnyType functions to retrievean atom. You call the QTFindChildByIndex function to search for and retrieve a parent atom’s child by itstype and index within that type.Listing 6-6 (page 330) shows the sample code function SetSpriteData, which updates an atom containerthat describes a sprite. (For more information about sprites and the Sprite Toolbox, refer to the bookProgramming With Wired Movies and Sprite Animation, available athttp://developer.apple.com/techpubs/quicktime/qtdevdocs/RM/PDF.htm.) For each propertyof the sprite that needs to be updated, SetSpriteData calls QTFindChildByIndex to retrieve the appropriateatom from the atom container. If the atom is found, SetSpriteData calls QTSetAtomData to replace theatom’s data with the new value of the property. If the atom is not found, SetSpriteData calls QTInsertChildto add a new atom for the property.Listing 6-6Finding a child atom by indexOSErr SetSpriteData (QTAtomContainer sprite, Point *location,short *visible, short *layer, short *imageIndex){OSErr err = noErr;QTAtom propertyAtom;// if the sprite’s visible property has a new valueif (visible){// retrieve the atom for the visible property --// if none exists, insert oneif ((propertyAtom = QTFindChildByIndex (sprite,kParentAtomIsContainer, kSpritePropertyVisible, 1,nil)) == 0)FailOSErr (QTInsertChild (sprite, kParentAtomIsContainer,kSpritePropertyVisible, 1, 1, sizeof(short), visible,nil))<strong>2012</strong>-<strong>08</strong>-<strong>14</strong> | © 2004, <strong>2012</strong> Apple Inc. All Rights Reserved.330

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!