#### Archived

This topic is now archived and is closed to further replies.

# Image List

This topic is 6029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, since no one answers me im gonna ask if this is how...If i add 3 images into an imagelist is that how i flip through them?

##### Share on other sites
Huh? you''re gonna have to explain that one a little better...

##### Share on other sites
I want to flip through 3 images....will an imagelist do that?

##### Share on other sites
Well the imagelist itself won''t do the flipping, but you can store three images in the imagelist and then setup a picturebox or other graphical component that you can use to display the image in the imagelist you want. Then all you need to do is display them in the sequence you want, to create a simple animation.

##### Share on other sites
Can u explain how i can get it to flip through it??? Thx

##### Share on other sites
You can use mod to cycle through a series of numbers (if that''s what you mean). This gives you the remainder of a division, so the values can only ever be in the range [0..number-1]. Much like this:

SomeIndex := (SomeIndex + 1) mod 3; // cycles 0,1,2 inclusive

You can add in code like this:

ImageList1.GetBitmap(SomeIndex, MyBitmap);
SomeIndex := (SomeIndex + 1) mod 3;
// etc. (draw MyBitmap, whatever)

The next time you do a GetBitmap, SomeIndex will be the next number in the sequence. If it''s two (i.e. the last one, zero based) then it will become 0 again. Therefore, you can cycle through the images.

You can optimise mod when it''s a power of two. Replace it with an "and" with the power minus one. So for example,

SomeIndex := (SomeIndex + 1) mod 4;
becomes...
SomeIndex := (SomeIndex + 1) and 3; // much faster!

Btw, here''s a really cool and unrelated link: Blah.

Alistair Keys

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

##### Share on other sites
For some reason thats throwing up alot of errors....and what do i put for the timer''s event handler???

##### Share on other sites
Crap wrong post.... Ok dude...where do i put this code in?? and what do i put for some Index??? Thx

##### Share on other sites
I''ve created a small web page giving example code (with a downloadable project for you). Hop over to:

Animation

Alistair Keys

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

##### Share on other sites
ok cool ...Thx man but one more thing now...how can i get that to work in a timage??? and how can i activate that on a button click? Thx ALOT!

• 9
• 13
• 41
• 15
• 14