ImagePacker comes with a set of code
templates used for generating source code.
This sourcecode can then be used to test your saved pack.
When you save your pack tick
the Generate code checkbox in the Save Pack
dialog window.
You now have the following options:

Global variables- Tick this to make program variables 'global'
Example
Global pack=LoadPack("textures.png")Pack name - The variable name for the loaded pack in the source code
The example here shows the pack name as mypackExample
mypack=LoadPack("bricks.png")Template - Which source code to generate
There are a few templates supplied which can generate code for
After you save your pack the generated source code will be placed in the same folder as the pack along with a copy of either SpriteMasterPro or ImageMaster include.
The filename will be PackViewer
- packfilename.bb where packfilename is the same
as the packs filename.
Here is an example of files created after saving a pack with generated code (using a 3D template):
| FILE | DESCRIPTION |
| pack1.png | The main pack of images |
| pack1.def | Definitions file for pack1.png |
| PackViewer - pack1.bb | The generated source code. Run this to test the sprites/images |
| smPro.bb | Include file (SpriteMaster Pro) |
The templates provided give the choice to generate code for both 3D sprites and 2D images.
Sprites are for use with SpriteMaster Pro, the single-surface quad sprite system for Blitz3D.
Images are for use
with ImageMaster, an include for Blitz2D, BlitzPlus, or Blitz3D
With ImageMaster you can extract standard Blitz 2D images from
the pack.
The templates themselves can
be modified to suit your needs.
Or, you can create your own templates and place them in the
ImagePacker\Templates folder.
There are some special tags in the code which ImagePacker uses to create the generated code:
| TAG | %COPYINCLUDEFILE% |
| DESCRIPTION | Copies the specified include file to the same folder where the code is generated. The file is copied from the Includes folder in the ImagePacker directory |
| CODE EXAMPLE | %COPYINCLUDEFILE%ImageMaster.bb |
| TAG | %GLOB% |
| DESCRIPTION | Replaces with 'Global ' if the'Global' option is selected from the Save Pack dialog box |
| CODE EXAMPLE | %GLOB%pack=LoadPack() becomes: Global pack=LoadPack() |
| TAG | %PACKNAME% |
| DESCRIPTION | Replaces with the name entered in
the PackName textfield from the Save Pack dialog box. The example on the right assumes the name entered is pack1 |
| CODE EXAMPLE | %PACKNAME%=LoadPack() becomes: pack1=LoadPack() |
| TAG | %PACKFILENAME% |
| DESCRIPTION | The filename of the pack saved during code generation. This replaces any occurances in the template. The example on the right assumes the filename is pack1.png |
| CODE EXAMPLE | mypack=LoadPack("%PACKFILENAME%") becomes: mypack=LoadPack("pack1.png") |
| TAG | %ALL% and %IMAGENAME% |
| DESCRIPTION | These tags are used to generate a
line of code for each image in the pack. When %ALL% is found in the template, the next line of code below the tag is repeated for every image in the pack. The %IMAGENAME% tage is replaced by the name of the current image from the pack. The example on the right would be generated if the pack contained these images: ball |
| CODE EXAMPLE | %ALL% PositonSprite %IMAGENAME%,Rand(100),Rand(100) becomes something like: PositonSprite
ball,Rand(100),Rand(100) |