Name
hw_RegisterFileType -- register a new file type (V5.3)
Synopsis
int ok = hw_RegisterFileType(hwPluginBase *self, int type, STRPTR name,
                STRPTR mime, STRPTR ext, ULONG formatid, ULONG flags);
Function
This function can be used to register a new file type with Hollywood. Hollywood won't do anything with these file types except return information about them to the user if requested by a call to GetPlugins(). The information about the file types supported by the individual plugins can be useful to filter file name extensions when showing file requesters or it can be useful to ask the user to select a file format when saving an image, etc. This makes it possible for scripts to dynamically support all plugins that are currently available.

You have to pass a pointer to your plugin's hwPluginBase in parameter 1. Hollywood passes this pointer to you when it first calls your InitPlugin() function. You also have to specify the root type of the file format you want to register. The following types are currently supported:

HWFILETYPE_IMAGE:
Register specified file type as an image file format.

HWFILETYPE_ANIM:
Register specified file type as an animation file format.

HWFILETYPE_SOUND:
Register specified file type as a sound file format.

HWFILETYPE_VIDEO:
Register specified file type as a video file format.

HWFILETYPE_ICON:
Register specified file type as an icon file format. (V9.0)

The name you have to specify in parameter 3 must be a human-readable name of the file type you want to register, e.g. "IFF ILBM". The name you specify here may use spaces. The fourth parameter is optional and allows you to specify the MIME type for the file format you want to register. If you don't want to provide this, pass NULL as the fourth parameter. Parameter number 5 must contain the extension(s) used by this file type. The extension(s) must be specified without the dot. If the file type supports more than one extension, separate the individual extensions using a vertical bar character (|), e.g. "iff|ilbm|lbm". The formatid parameter is only used if HWFILETYPEFLAGS_SAVE is set in the flags parameter. In that case, you have to pass the identifier of this file format here. This must match the identifier that is returned by your implementations of functions like RegisterImageSaver() or RegisterAnimSaver().

Finally, RegisterFileType() accepts the following flags:

HWFILETYPEFLAGS_SAVE:
If this flag is set, you're registering a saver file type. You must register loaders and savers in two separate calls. It is not possible to register loader and saver within a single call to hw_RegisterFileType().

HWFILETYPEFLAGS_ALPHA:
This flag indicates that your plugin can load or save alpha channel information, depending on whether HWFILETYPEFLAGS_SAVE is set. This is only applicable for HWFILETYPE_IMAGE and HWFILETYPE_ANIM.

HWFILETYPEFLAGS_QUALITY:
This flag indicates that your plugin supports lossy compression of image data. It is only supported by for HWFILETYPE_IMAGE and HWFILETYPE_ANIM and the HWFILETYPEFLAGS_SAVE flag must be set. The quality level is passed to your plugin saver as a value ranging between 0 (bad quality) to 100 (excellent quality).

HWFILETYPEFLAGS_FPS:
This flag indicates that your plugin can save animations with different frames per second settings. It is only supported by HWFILETYPE_ANIM together with the HWFILETYPEFLAGS_SAVE flag set.

RegisterFileType() is usually called in your InitPlugin() function but make sure that you have at least Hollywood 5.3 before attempting to call this function!

Designer compatibility
Supported since Designer 5.0

Inputs
self
pointer to a hwPluginBase as passed to your InitPlugin() function
type
file type to register (see above)
name
human-readable name of this file type
mime
MIME type for this file format or NULL
ext
extension(s) for this file type; multiple extensions must be separated by a vertical bar (|)
formatid
when registering output file types, the unique identifier used by this format (see above)
flags
additional flags (see above)
Results
ok
True for success, False on failure
Example
hw_RegisterFileType(self, HWFILETYPE_IMAGE, "JPEG 2000", NULL,
                      "jp2|j2k", 0, HWFILETYPEFLAGS_ALPHA);

hw_RegisterFileType(self, HWFILETYPE_IMAGE, "JPEG 2000 (JP2)", NULL,
                      "jp2", outfmt[0], HWFILETYPEFLAGS_SAVE|
                      HWFILETYPEFLAGS_ALPHA|HWFILETYPEFLAGS_QUALITY);

hw_RegisterFileType(self, HWFILETYPE_IMAGE, "JPEG 2000 (J2K)", NULL,
                      "j2k", outfmt[1], HWFILETYPEFLAGS_SAVE|
                      HWFILETYPEFLAGS_ALPHA|HWFILETYPEFLAGS_QUALITY);
The code above registers a loader file type for the JPEG 2000 format and two savers for the JPEG 2000 format. The savers distinguish between the JP2 and the J2K container formats while the loader combines them into a single format.

Show TOC