Solved

Animation image

Posted on 2004-03-21
29
386 Views
Last Modified: 2010-04-05
I have 10 image store in resource file and i like to show them as an Animation?
0
Comment
Question by:sal1150
  • 15
  • 14
29 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10643719
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

0
 

Author Comment

by:sal1150
ID: 10648109
what means 'CLASSIMAGES'
and my images are in dll file.
i will use Ttimer to control them.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10648318
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
0
 

Author Comment

by:sal1150
ID: 10648442
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);
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10648512
Are all the images the same size? If so what is there size?

Shane
0
 

Author Comment

by:sal1150
ID: 10648538
yes all with same size.
125x125
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10648576
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



0
 
LVL 11

Expert Comment

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

Shane
0
 

Author Comment

by:sal1150
ID: 10648644
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
0
 

Author Comment

by:sal1150
ID: 10648671
imagelist2.Height :=125;
imagelist1.width :=125;
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10648711
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
0
 

Author Comment

by:sal1150
ID: 10648761
still no picture in image1
0
 

Author Comment

by:sal1150
ID: 10648799
in case of 'ResInstLoad' is it used 'GetBitmap' or 'GetInstRes'?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10649298

 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
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Expert Comment

by:shaneholmes
ID: 10649350
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
0
 

Author Comment

by:sal1150
ID: 10649525
Message give me 0 value
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10649570
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10649580
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)

0
 

Author Comment

by:sal1150
ID: 10649598
yes that correct.
0
 

Author Comment

by:sal1150
ID: 10649752

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

thanks
0
 

Author Comment

by:sal1150
ID: 10649819
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10649888
ummmm, thats 33 images not 1

Im creating you an example now



Shane
0
 

Author Comment

by:sal1150
ID: 10650493
Im waiting u.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10650563
you got an email address ?

Shane
0
 

Author Comment

by:sal1150
ID: 10650715
sal1150@hotmail.com
0
 

Author Comment

by:sal1150
ID: 10652586
?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10652629
ah, check your email, i've been emailing you stuff regularly, but you haven't been responding.

SHane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 450 total points
ID: 10652640
Never mind, here it is:

******* MAIN CODE HERE **************

unit UntMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    procedure FormActivate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
 Form1: TForm1;
 DLLHandle: THandle;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);

begin
 DLLHandle:= LOadLibrary('AnimateImages.Dll');
 Image1.Picture.Bitmap.Handle := LoadImage(DLLHANDLE, 'IMAGE1',IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION or LR_DEFAULTSIZE);
 Randomize;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
 I: String;
begin
 I:= intToStr(Random(4) + 1);
 DLLHandle:= LOadLibrary('AnimateImages.Dll');
 Image1.Picture.Bitmap.Handle := LoadImage(DLLHANDLE, PChar('IMAGE' + I),IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION or LR_DEFAULTSIZE);
end;

end.

******* DLL CODE HERE **************

library AnimateImages;

uses
  SysUtils,
  Classes;

{$R *.res}
{$R IMAGES.res}

begin
end.
0
 

Author Comment

by:sal1150
ID: 10656078
thanks SHane.

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now