# LoadSubImage

## Description

Loads a sub image from an atlas texture for use as a standalone image into a specified image ID. The subimages.txt file should start with the same name as the image file, for example an atlas image MyImage.png would have a subimages file named "MyImage subimages.txt". The subimages file contains a series of rows each describing an image that exists within the atlas image. Each line must have the format Name:X:Y:Width:Height with the delimiter : used between the fields. The Name field is the name you want to used to reference the sub image when loading, this should match the sImageFilename parameter of this LoadSubImage command. The X:Y fields are the X and Y pixel coordinates that represent the top left corner of the subimage, and the Width:Height fields are the size in pixels of the sub image. These values are then used to extract your named image from the atlas and load it into its own image ID to be used as if it were a normal image. The atlas image must remain loaded for the entire time you are using the loaded sub image. Note that when loading a sub image AGK will modify the UV coordinates slightly so that the image does not steal pixels from neighboring images during filtering, by default it shifts the UV inwards by 0.5 pixels. You can override this by setting SetSpriteUVBorder to 0 for sprites where you need pixel perfect results, but you will have to watch out for pixel bleeding around the edges, and may need to give your sub images a 1 pixel border of an appropriate color that it can safely steal from when filtering.

## Definition

integer LoadSubImage ( iParentIndex, sImageFilename )

UINT agk::LoadSubImage ( UINT iParentIndex, const char *sImageFilename )

LoadSubImage ( iImageIndex, iParentIndex, sImageFilename )

void agk::LoadSubImage ( UINT iImageIndex, UINT iParentIndex, const char *sImageFilename )

## Parameters

- iParentIndex - The image ID that holds the atlas texture, loaded previously.
- sImageFilename - The filename of the sub image as stored in subimages.txt. Do not use a path before the filename.