Name
OpenAnim -- open an animation (V9.0)
Synopsis
[id] = OpenAnim(id, filename$[, table])
Function
This function opens the animation specified by filename$ and assigns the identifier id to it. If you pass Nil in id, OpenAnim() will automatically choose an identifier and return it.

In contrast to LoadAnim(), OpenAnim() won't load any frames into memory. Thus, it will return control to the script quickly and won't use much memory. Using OpenAnim() is basically the same as calling LoadAnim() with the FromDisk table argument set to True.

Anim formats that are supported on all platforms are IFF ANIM, GIF ANIM, AVI (uncompressed or using Motion JPEG compression), and formats you have a plugin for. Depending on the platform Hollywood is running on, more anim formats might be supported. For example, on Amiga compatible systems Hollywood will be able to open all anim formats you have datatypes for as well. On Windows, OpenAnim() can also load anim formats supported by the Windows Imaging Component.

The third argument is optional. It is a table that can be used to set further options for the loading operation. The following fields of the table can be used:

Transparency:
This field can be used to specify a color in RGB notation that shall be made transparent in the animation.

LoadAlpha:
Set this field to True if the alpha channel of the anim shall be loaded, too. This field defaults to False.

SkipLoopFrames:
If you set this to True, Hollywood will automatically skip the last two frames of the anim. This is only required for IFF ANIMs that have two loop frames at the end of the anim. Auto detection of loop frames is not possible because it would require Hollywood to decode the whole anim first. That is why you have to tell Hollywood manually whether the anim has loop frames or not.

Deinterlace:
This tag allows you to specify how Hollywood should deinterlace interlaced anims. This can be set to either #DEINTERLACE_DEFAULT or #DEINTERLACE_DOUBLE. If set to #DEINTERLACE_DEFAULT (which is as the name implies also the default), Hollywood will combine two half-frames into one full frame. This mostly results in the best quality but can lead to visual artefacts when there is a lot of movement in the anim. If you use #DEINTERLACE_DOUBLE instead, Hollywood will double the lines of a half-frame to get a full frame. This leads to some quality loss but can make the anim look smoother. The best deinterlace mode to use always depends on the anim. Note that mostly you should not have to care about this tag at all because deinterlacing is actually only required for some obscure IFF ANIM formats which store interlaced frames like ANIM16i and ANIM32i.

Loader:
This tag allows you to specify one or more format loaders that should be asked to load this anim. This must be set to a string containing the name(s) of one or more loader(s). Defaults to the loader set using SetDefaultLoader(). See Loaders and adapters for details.

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to the adapter set using SetDefaultAdapter(). See Loaders and adapters for details.

LoadTransparency:
If this tag is set to True, the monochrome transparency of the anim will be loaded. Please note that this tag is specifically designed for monochrome transparency channels, i.e. a transparent pen in a palette-based anim. If you want to load the alphachannel of an anim, set the LoadAlpha tag to True. This tag defaults to False.

LoadPalette:
If this tag is set to True, Hollywood will load the anim as a palette anim. This means that you can get and modify the anim's palette which is useful for certain effects like color cycling. You can also make pens transparent using the TransparentPen tag (see below) or the LoadTransparency tag (see above). Palette animations also have the advantage of requiring less memory because 1 pixel just needs 1 byte of memory instead of 4 bytes for 32-bit images. This tag defaults to False.

TransparentPen:
If the LoadPalette tag has been set to True (see above), the TransparentPen tag can be used to define a pen that should be made transparent. Pens are counted from 0. Alternatively, you can also set the LoadTransparency tag to True to force Hollywood to use the transparent pen that is stored in the anim file (if the anim format supports the storage of transparent pens). This tag defaults to #NOPEN.

UserTags:
This tag can be used to specify additional data that should be passed to loaders and adapters. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.0)

Please note that the Transparency, LoadTransparency and LoadAlpha fields are mutually exclusive. An animation cannot have a mask and an alpha channel!

This command is also available from the preprocessor: Use @ANIM to preload animations from the preprocessor but note that you have to set FromDisk to True in that case to get the same behaviour as OpenAnim(). If you don't set FromDisk to True, @ANIM will load the entire animation into memory!

Starting with Hollywood 9.0, this function can also open vector anim formats if you have an appropriate plugin installed. Keep in mind, though, that if you open vector anim formats using OpenAnim(), the anim may not support all features of normal anims. See Vector animations for more information on vector anims.

To free an animation allocated by OpenAnim(), use the CloseAnim() command. See CloseAnim for details.

Inputs
id
identifier for the animation or Nil for auto id selection
filename$
file to load
table
optional: further options (see above)
Results
id
optional: identifier of the animation; will only be returned when you pass Nil as argument 1 (see above)
Example
OpenAnim(2, "MyAnim.gif", {Transparency = #RED})
This opens "MyAnim.gif" as anim 2 with the color red being transparent.

Show TOC