[id] = LoadSprite(id, filename$[, args])
filename$ into memory and
assigns the identifier id to it. If you pass Nil in id, LoadSprite()
will automatically choose an identifier and return it.
Supported image formats are PNG, JPEG, BMP, IFF ILBM, and some more
depending on the platform Hollywood is running on. Starting with
Hollywood 4.5, LoadSprite() can also open animation formats (IFF ANIM,
GIF ANIM, uncompressed AVIs or AVIs using Motion JPEG compression) and
convert these animations into a sprite directly.
The optional argument args accepts a table which can contain further
options for the loading operation. The following fields can be set
in the args table:
Transparency:
LoadAlpha:True if the image contains an alpha
channel that shall be loaded.
X, Y, Width, Height, Frames, FPR:LoadSprite() create a sprite with multiple
frames from a single picture. Width and Height define the dimensions
for the sprite and Frames specifies how many frames LoadSprite() shall
read from the source image. If the frames are aligned in multiple rows in
the source image, you will also have to pass the argument FPR (stands
for frames per row) to tell LoadSprite() how many frames there are in each
row. Finally, you can tell LoadSprite() where in the image it should start
scanning by specifying the fields X and Y (they both default to 0).
LoadSprite() will then start off at position X and Y and read Frames number
of images with the dimensions of Width by Height from the picture
specified by filename$. After it has read FPR number of images, it will
advance to the next row. All of these fields can only be used if you
specify an image file in filename$. If you specify an anim file, they
are ignored.
Loader:
Adapter:
LoadTransparency:True, the monochrome transparency of the sprite will
be loaded. Please note that this tag is specifically designed for monochrome
transparency channels, i.e. a transparent pen in a palette-based sprite. If
you want to load the alphachannel of a sprite, set the LoadAlpha tag to
True. This tag defaults to False. (V6.0)
LoadPalette:True, Hollywood will load the sprite as a palette sprite.
This means that you can get and modify the sprite'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 sprites 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. (V9.0)
TransparentPen: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 file
(if the file format supports the storage of transparent pens). This tag defaults
to #NOPEN. (V9.0)
UserTags:
Please note that the Transparency, LoadTransparency and LoadAlpha fields are mutually
exclusive. A sprite cannot have a mask and an alpha channel!
This command is also available from the preprocessor: Use @SPRITE to preload sprites!
LoadSprite(1, "MySprite.png", {Transparency = #RED})
This loads "MySprite.png" as sprite 1 with the color red being transparent.
LoadSprite(1, "PlayerSprites.png", {Width = 32, Height = 32,
Frames = 16, FPR = 8, Transparency = #BLACK})
The code above creates sprite 1 from the file "PlayerSprites.png".
Sprite 1 will be of the dimensions 32x32 and will contain 16 different
frames. The single frames are aligned with 8 frames per row in the
image "PlayerSprites.png". Thus, LoadSprite() needs to scan two
rows to read the full 16 frames.