Link to home
Start Free TrialLog in
Avatar of sal1150
sal1150

asked on

Animation image

I have 10 image store in resource file and i like to show them as an Animation?
Avatar of shaneholmes
shaneholmes

OTTOMH

If each image is the same size, then create an image that has all of the images in one strip.

Place a TImageLIst on your form and set the height and width property that each individual
image is.  For example, if you have a strip that is 64 x 16 and each image
is 16 x 16, the strip contains 4 images, each of which is 16 wide and 16
tall, so set the imagelist height and width to 16.

 Next include the resource file in the appropriate unit, i.e. {$R
MYIMGS.RES}

Then, in your code,  Load the images in the imagelist as follows.

  MyImageList.ResourceLoad(rtBitmap, 'CLASSIMAGES', clBlue);
  if   MyImageList.Count=0 then
    MessageDlg('Could not load   My Image List',mtError,[mbOK],0);

Note: clBlue is the background color to be used for transparency purposes .


Now you have a TImageList with your images,

You can step through the imageList and display the images 1 at a time



 step through the images int he list, and display them in a TImage component

 for I:= 0 to ImageList.Count-1 do
 begin
  MyImageList.GetBitmap(I, MyImage.Picture.Bitmap)
  //maybe add somedelay here using TTimer, thread, or even just the Sleep function
 end;


Shane
Shane

Avatar of sal1150

ASKER

what means 'CLASSIMAGES'
and my images are in dll file.
i will use Ttimer to control them.
Well, you never said anything about a DLL....

Anyway, they are in a resource file compiled in the DLL right?

(You already of the code to load the DLL right? OR No

If so, you can use the same code.


change

MyImageList.ResourceLoad(rtBitmap, 'CLASSIMAGES', clBlue);

to

MyImageListResInstLoad(<HANDLE of DLL goes here>, rtBitmap, CLASSIMAGES, clBlue)

CLASSIMAGES is an example name of what you called your images in the Resource file

You should have one image like i described above, called CLASSIMAGES or whatever you want to call it.

Shane
Avatar of sal1150

ASKER

i have 33 images(bitmap) and still i cant understand u.
i do this code but no response:-


mydll := LoadLibrary('resdll.dll');
  if mydll=0 then
     raise Exception.Create('Cannont load resource library. Please check if RESONLY.DLL is in the application''s folder');

  imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);
Are all the images the same size? If so what is there size?

Shane
Avatar of sal1150

ASKER

yes all with same size.
125x125
Ahhh, thats a good size image. They only way you can load the TIMageList with a ResInstLoad, is if you combine all the images into one image (in this case the size would then be 4125 X 125). IN your case, you would name it '1' and recompile the resource into your DLL.

Set your TImageList & TImage height & Widths to 125

 mydll := LoadLibrary('resdll.dll');
  if mydll=0 then
     raise Exception.Create('Cannont load resource library. Please check if RESONLY.DLL is in the application''s folder')
  else
  imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);

Shane



WHen the ImageList loads the 1 image in using ResInstLoad, it will automatically split the picture up into its 125 X 125 parts.

Shane
Avatar of sal1150

ASKER

mydll := LoadLibrary('resdll.dll');
  if mydll=0 then
     raise Exception.Create('Cannont load resource library. Please check if RESONLY.DLL is in the application''s folder');

  imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);
  ImageList2.GetBitmap(0, Image1.Picture.Bitmap)


still no picture in image1
Avatar of sal1150

ASKER

imagelist2.Height :=125;
imagelist1.width :=125;
try

var
 bmp: TBitmap;


 imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);
 bmp:= TBitmap.Create;
 ImageList2.GetBitmap(0, bmp);
 Image1.Picture.Bitmap.Assign(bmp);
 bmp.Free;


SHane
Avatar of sal1150

ASKER

still no picture in image1
Avatar of sal1150

ASKER

in case of 'ResInstLoad' is it used 'GetBitmap' or 'GetInstRes'?

 first, make sure your imagelist is getting the image from the DLL


 mydll := LoadLibrary('resdll.dll');
  if mydll=0 then
     raise Exception.Create('Cannont load resource library. Please check if RESONLY.DLL is in the application''s folder')
  else
  begin
   imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);
   ShowMessage(IntToSTr(imagelist2.Count));
 end;

SHane
GetInstRes loads a particular bmp from the resource file into the imagageList.

GetBitmap gets a particular bitmap from an index in the imagelist and places it in the variable
example - ImageList2.GetBitmap(0, bmp); gets the first image and assignes it to bmp

Shane
Avatar of sal1150

ASKER

Message give me 0 value
ok, if your using

 imagelist2.ResInstLoad(mydll,rtBitmap,'1', clBlue);

that means you have a resource file with an image in there called '1'.

Not with an ID of 1, a name called '1' (a string name)

Is this correct?

Shane
if your app is not huge, i would entertain the thought of you zipping it up and mailing it to me and i would take a look at it for you.

you would also have to include the image and the DLL source

Shane (cladview@yahoo.com)

Avatar of sal1150

ASKER

yes that correct.
Avatar of sal1150

ASKER


sorry it is very large..but i will send resource script to check its format...

thanks
Avatar of sal1150

ASKER

dll source is:-


{$O+,D-,L-,M-,Y-,R-,Q-,U-}
library resDLL;

{$R myclock.res}
end.

//*************************************

and resourse sicript is:-


1 BITMAP 1.bmp
2 BITMAP 2.bmp
3 BITMAP 3.bmp
4 BITMAP 4.bmp
5 BITMAP 5.bmp
6 BITMAP 6.bmp
7 BITMAP 7.bmp
8 BITMAP 8.bmp
9 BITMAP 9.bmp
10 BITMAP 10.bmp
11 BITMAP 11.bmp
12 BITMAP 12.bmp
13 BITMAP 13.bmp
14 BITMAP 14.bmp
15 BITMAP 15.bmp
16 BITMAP 16.bmp
17 BITMAP 17.bmp
18 BITMAP 18.bmp
19 BITMAP 19.bmp
20 BITMAP 20.bmp
21 BITMAP 21.bmp
22 BITMAP 22.bmp
23 BITMAP 23.bmp
24 BITMAP 24.bmp
25 BITMAP 25.bmp
26 BITMAP 26.bmp
27 BITMAP 27.bmp
28 BITMAP 28.bmp
29 BITMAP 29.bmp
30 BITMAP 30.bmp
31 BITMAP 31.bmp
32 BITMAP 32.bmp
33 BITMAP 33.bmp
ummmm, thats 33 images not 1

Im creating you an example now



Shane
Avatar of sal1150

ASKER

Im waiting u.
you got an email address ?

Shane
Avatar of sal1150

ASKER

sal1150@hotmail.com
Avatar of sal1150

ASKER

?
ah, check your email, i've been emailing you stuff regularly, but you haven't been responding.

SHane
ASKER CERTIFIED SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sal1150

ASKER

thanks SHane.

I makke some change in your code.
It is now working good.
again thanku and I will increase the points to 450.