split an image in to array of images

Good Day there coders, i hope this finds you all well
i am wondering if you have a large image that is made up of smaller images or icons
can you use the larger image in something like a image well then split of the icons knowing that the image is on an 8 by 8 grid
can you then loop though all of the images and add them in either a list or an array of images?
Any thoughts ?

Oh one other question im new to the forums, is there a bit ware you can upload examples or do you have to do it using your own server?

cheers Clev

[quote=132971:@James Cleverly]i am wondering if you have a large image that is made up of smaller images or icons
can you use the larger image in something like a image well then split of the icons knowing that the image is on an 8 by 8 grid
can you then loop though all of the images and add them in either a list or an array of images?[/quote]

At first glance, you are speaking about sprite sheets. You can indeed drag a sprite sheet in your project, and then create an array of pictures and in each of them drawpicture a portion of the sprite sheet.

See http://documentation.xojo.com/index.php/Graphics.DrawPicture

Thanks for the Reply Mr Burjardet, Sprite sheets , after a look on Google that exactly what i mean . if you would not mind sir what would be the code for getting the image at 100 pixes in from the left and 100 pixels from the top and the image is 200 by 200
is the draw image done in pixels or some other measurement ?

thank you Clev

You create a new picture, let’s say “p”, and your spritesheet has been added to the project as “spritesheet” then

p.graphics.drawpicture(spritesheet,0,0,200,200,100,100,200,200)

The first two 200 are the size in the new picture, then the two 100 are the offset on spritesheet, and the last 200 are the size of the square you want to fetch from spritesheet. The LR link I posted details it well.

you star thank you very much for tacking the time to do that for me

You can get away with just shifting the sprite sheet, drawing with negative x y positions to align the sub images. The sheet will need to be evenly divisible by 8 for this code to work.

[code] dim srcpic As Picture = yourFullSized8x8Sheet

dim miniWidth As integer = srcpic.Width / 8
dim miniHeight As integer = srcpic.Height / 8

dim picArr(), p As Picture

dim x, y As integer
for y = 0 to 7
for x = 0 to 7
p = new Picture(miniWidth, miniHeight)
p.Graphics.DrawPicture(srcpic, x * -miniWidth, y * -miniHeight)
picArr.Append p
next
next

//picArr contains the 64 sub images from srcpic[/code]

Thanks Mr Shank there is a few guys at work that are good with graphics now i know what im asking for ill see what i can get going
cheers guys