Feel free to enhance it with the following code. the first function takes one image containing all of your bitmap font characters, and splits it into individual bitmaps. You just specify the base image, how many characters it contains horizontally and vertically, and the image number you want it to start writing them out to. It will do the rest,
AND it retains the alpha channel! GET IMAGE loses it, so I did it using memblocks.
function SplitImage(baseImage,imgX,imgY,firstImg)
localtest = 0
baseSprite = 1
while sprite exist(baseSprite) = 1
inc baseSprite
endwhile
sprite baseSprite,0,0,baseImage
memNo = 1
while memblock exist(memNo) = 1
inc memNo
endwhile
make memblock from image memNo,baseImage
` Image and Sprite no longer required...
if localtest <> 1
delete sprite baseSprite
delete image baseImage
endif
` Get image attributes
iW = (memblock dword(memNo,0))
iH = (memblock dword(memNo,4))
iD = (memblock dword(memNo,8))
` Make a memblock to create each image in.
` In Double Words, this is (width / x) * (height / y) + 3
`get the Image Width, Height and depth
imgWidth = iW / imgX
imgHeight = iH / imgY
`mbSize = (((imgWidth * imgHeight)) * (4)) + 12
mbSize = ((imgWidth * imgHeight) + 3) * 4
` 1 memblock for output images
memNo2 = memNo + 1
while memblock exist(memNo2) = 1
inc memNo2
endwhile
make memblock memNo2, mbSize
`initialise with header
write memblock dWord memNo2,0,imgWidth
write memblock dWord memNo2,4,imgHeight
write memblock dWord memNo2,8,iD
` Write the data to memblock...
for imagesY = 1 to imgY
for imagesX = 1 to imgX
img = ((imagesY -1) * imgX) + imagesX
NewByte = 12
for rows = 1 to imgHeight
for cols = 1 to imgWidth
` *** 1. Full Rows * images per Row
offSet1 = (imagesY - 1) * imgWidth * imgHeight * imgX
` *** 2. Full width * single rows processed
offset2 = (iW * (rows - 1))
` offset2 = (iW - (imgWidth * (imgX - 1 - imagesX))) * (rows - 1)
` *** offset 3 X-offset - width of images processed on this row
offset3 = imgWidth * (imagesX - 1)
` *** offset 3 Current image column
offset4 = cols - 1
imgDword = (offset1 + offset2 + offset3 + offset4 + 3) * 4
write memblock dWord memNo2,NewByte, memblock dWord(memNo,imgDWord)
inc NewByte,4
next cols
next rows
NewByte = 12
make image from memblock (img + firstImg - 1),memNo2
next imagesX
next imagesY
delete memblock memNo
delete memblock memNo2
endfunction 0
Secondly, if you want to get rid of the large number of IFs, just use an offset value. To change a character to a value between 1 and 26, for example, just use
a = asc(myChar$)-32
You can then use this value to pick your image number.