Image List

Started by
23 comments, last by Daboy 22 years, 5 months ago
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?
Jordan Weberwww.pheonixsoftware.com
Advertisement
Huh? you''re gonna have to explain that one a little better...
I want to flip through 3 images....will an imagelist do that?
Jordan Weberwww.pheonixsoftware.com
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.
Can u explain how i can get it to flip through it??? Thx
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
For some reason thats throwing up alot of errors....and what do i put for the timer''s event handler???
Crap wrong post.... Ok dude...where do i put this code in?? and what do i put for some Index??? Thx
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
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!

This topic is closed to new replies.

Advertisement