Loads a sub image from an atlas texture for use as a standalone image.
constructor Create(const Owner: TAgkObject; const AtlasImage: TAgkImage; const SubImageFilename: String); overload;
Parameters |
Description |
const Owner: TAgkObject |
the owner of the new image (eg. a TAgkScene object). |
const AtlasImage: TAgkImage |
the image that hold the atlas texture, loaded previously. |
const SubImageFilename: String |
The filename of the sub image as stored in the sub images text file (see Remarks). Do not use a path before the filename. |
Atlas textures consist of an image file and a text file. The text file must be named '[imagename] subimages.txt', and must be in the same directory is the image file. So, if the image file is called 'foo.png', then the text file must be called 'foo subimages.txt'.
Each line in the text file must be in the following format:
Where: SubImageFilename: the name of the sub image, as used by the Filename parameter of this method. X, Y: the location (top-left) in the atlas texture where the sub image starts. Width, Height: the dimensions of the sub image.
For example, if the text file looks like this:
subimage1.png:0:0:20:20 subimage2.png:20:0:20:20 subimage3.png:40:0:20:20
Then this call:
AtlasImage := TAgkImage.Create('Atlas.png'); MySubImage := TAgkImage.Create(AtlasImage, 'subimage2.png');
will create a 20x20 pixel sub image that starts at position (40,0) in the image Atlas.png
Copyright (c) 2012. All rights reserved.
|