APTR handle = LoadImage(STRPTR filename, struct LoadImageCtrl *ctrl);
NULL
. The handle returned by LoadImage()
is
an opaque datatype that only your plugin knows about. Hollywood will simply pass
this handle back to your GetImage() function when it wants to
have the raw pixel data.
This function also has to provide certain information about the image it
has just loaded. This information has to be written to the struct LoadImageCtrl
that is passed in the second parameter. This structure looks like this:
struct LoadImageCtrl { int Width; // [out] int Height; // [out] int LineWidth; // [out] int AlphaChannel; // [out] int ForceAlphaChannel; // [out] int Type; // [out] ULONG Flags; // [in/out] -- V5.3 int ScaleWidth; // [in] -- V5.3 int ScaleHeight; // [in] -- V5.3 int BaseWidth; // [out] -- V5.3 int BaseHeight; // [out] -- V5.3 ULONG ScaleMode; // [in] -- V5.3 STRPTR Adapter; // [in] -- V6.0 ULONG *Palette; // [unused] -- V9.0 ULONG TransPen; // [out] -- V9.0 int Depth; // [out] -- V9.0 struct hwUserTagList *UserTags; // [in] -- V10.0 }; |
Be careful when accessing above structure members: LoadImageCtrl has seen several revisions in Hollywood's history. Before accessing members that haven't been there in all Hollywood versions you must make sure that your plugin has been opened by a Hollywood version that has those members or you will access unallocated memory!
The following information has to be provided by LoadImage()
:
Type:
HWIMAGETYPE_RASTER
or HWIMAGETYPE_VECTOR
.
If you set this to HWIMAGETYPE_VECTOR
, Hollywood will call your TransformImage()
function whenever it needs to transform the image. This allows you to do lossless
transformation of the vector image. For images of type HWIMAGETYPE_RASTER
,
TransformImage() is never called. Instead, Hollywood does
all transformations itself.
Width:
Height:
Depth:
LineWidth:
AlphaChannel:
True
or False
, depending on whether or not this image has an
alpha channel.
ForceAlphaChannel:
True
, Hollywood will automatically create an alpha channel for
all objects that load this image. For example, if the user calls LoadBrush()
on your image but does not set the LoadAlpha
tag to True
, the brush will still
get an alpha channel if you set ForceAlphaChannel
to True
.
Flags:
HWIMGFLAGS_TRANSPARENCY:
LoadTransparency
tag to True
. If
HWIMGFLAGS_LOADPALETTE
is set as well (see below), you must return the pen that is
transparent in the TransPen
member of struct LoadImageCtrl
. If HWIMGFLAGS_LOADPALETTE
is not set, you have to write the image's transparency information to its alpha channel
and set the ForceAlphaChannel
member to True
. See above for more information. (V6.0)
HWIMGFLAGS_LOADPALETTE:
LoadPalette
tag to True
. If this
flag is set, your implementation of LoadImage()
should fail in case the image does
not have a palette. If it has a palette, you have to return that palette when
Hollywood calls your GetImage() implementation. Note that
palette images must always use HWIMAGETYPE_RASTER
. They may not register as vector
images. (V9.0)
The following flags may be set by your implementation:
HWIMGFLAGS_DIDSCALE:
HWIMGFLAGS_DIDSCALE
flag here so that Hollywood knows that your plugin has loaded and scaled the image.
See below for more information on scaled loading of images. (V5.3)
Adapter:
NULL
, Hollywood wants your plugin to
use the file adapter specified in Adapter
to open the image. This means that you
have to use hw_FOpenExt() instead of hw_FOpen()
to open the image. Make sure to check for Hollywood 6.0 before trying to access
this member because it isn't there in previous versions. See hw_FOpenExt for details. (V6.0)
TransPen:
HWIMGFLAGS_LOADPALETTE
and HWIMGFLAGS_TRANSPARENCY
are set and the image has
a transparent pen, set TransPen
to the index of that transparent pen. Otherwise
set this member to HWPEN_NONE
. (V9.0)
Starting with Hollywood 5.3 LoadImage()
also supports scaled loading of images.
This is optional functionality and need not be supported by LoadImage()
. If you
want to support it, you have to look at the members ScaleWidth
and ScaleHeight
of the struct LoadImageCtrl
pointer that is passed to LoadImage()
.
Warning! Make sure that you access these members only if you have checked that
your plugin has been opened by version 5.3 or higher of Hollywood. Otherwise, these
members won't be there and trying to access them will read from bad memory locations
and give you back random values. So if you want to implement support for scaled loading
of images, first check for Hollywood 5.3 and then take a look at the following members
of the struct LoadImageCtrl
:
ScaleWidth:
ScaleWidth
is 0,
Hollywood doesn't want to have any scaling. (V5.3)
ScaleHeight:
ScaleWidth
except
that it deals with the image height. (V5.3)
ScaleMode:
BaseWidth:
Width
member needs
to be set to the scaled width if you do scaling. (V5.3)
BaseHeight:
BaseWidth
but for the image height. (V5.3)
UserTags:
UserTags
could
also be intended for another plugin, namely the file adapter plugin passed
in Adapter
. See User tags for details. Make sure to check for Hollywood 10.0
before trying to access this member because it isn't there in previous versions.
(V10.0)
Please note that you should not use ANSI C functions like fopen()
to
open the file that is passed to this function because the filename that is passed
to this function can also be a specially formatted filename specification that
Hollywood uses to load files that have been linked to applets or executables. In
order to be able to load these files correctly, you have to use special IO functions
provided by Hollywood. See File IO information for details.
struct LoadImageCtrl
for storing information
about the imageNULL
if plugin doesn't
want to handle this image