TGC Codebase Backup



Tile Image Function by Scraggle

15th Dec 2003 4:20
Summary

A Function to tile images



Description

This is a simple fuction to cut an image into tiles.

The Parameters are:

filename$ = The filename of the original image that you want to tile.
across = The amount of tiles to cut the image into along the X axis.
down = The amount of tiles to cut the image into along the Y axis.
imagenumber = The tiles you create will have consecutive image numbers. The number you place here will be the number of the first image.
bitmap = This can be any bitmap number that is not currently in use.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Function TileImage(filename$,across,down,imagenumber,bitmap)

load bitmap filename$, bitmap
set current bitmap bitmap

ScaleX = bitmap width(bitmap) / across
ScaleY = bitmap height(bitmap) / down

for y = 0 to down-1
   for x = 0 to across-1
      get image imagenumber,x * ScaleX,y * ScaleY,x * ScaleX + ScaleX,y * ScaleY + ScaleY, 1
      inc imagenumber
   next x
next y

delete bitmap bitmap
set current bitmap 0
endfunction