Solved

Slick Slide

Posted on 2001-07-09
6
362 Views
Last Modified: 2010-04-06
I need to make an animation involving 4 big pictures.
One is background, it is painted once static since then.
Two and three are right and left part of a drawing which slide towards each other(painted transparently while they do)
Four is a frame. It is drawn transparently over the sliding images.

Now to the problem. I do not know DirectX or ASM or stuff like that. So I implemented the drawing the way I knew(if you want I will put the procedure here). I succeeded to get rid of the flickering but the animation is still rather slow and ugly.

Please help me make it more presentable(If you saw the game starcraft you might know what I mean to do).
0
Comment
Question by:duke_n
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6265293
If you are moving TImages then put them on a TPanel...
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 6265317
0
 
LVL 1

Author Comment

by:duke_n
ID: 6265712
no I am not moving images.
Here is my procedure roughly:

Procedure TMainForm.Animate;
var
i:integer;
bmp1,bmp2,Bmp3:Tbitmap;
J:TJPegImage;
Get:TResourceStream;
begin
Randomize;
...
//Slide Animation
bmp1:=TBitmap.Create;
bmp2:=TBitmap.Create;
bmp3:=TBitmap.Create;
J:=TJPEGImage.Create;

Get:=TResourceStream.Create(hInstance,'LEFT',RT_RCDATA);
bmp1.LoadFromStream(Get);
Get.Free;

Get:=TResourceStream.Create(hInstance,'RIGHT',RT_RCDATA);
bmp2.LoadFromStream(Get);
Get.Free;

Get:=TResourceStream.Create(hInstance,'FRAME',RT_RCDATA);
J.LoadFromStream(Get);
Get.Free;

bmp1.TransparentColor:=clWhite;
bmp1.TransparentMode:=tmFixed;
bmp1.Transparent:=True;
bmp2.TransparentColor:=clWhite;
bmp2.TransparentMode:=tmFixed;
bmp2.Transparent:=True;

FrameIMG.Canvas.Brush.Color:=clBlack;
FrameIMG.Canvas.CopyMode:=cmSrcCopy;
FrameIMG.Canvas.FillRect(Rect(0,0,FrameIMG.Width,FrameIMG.Height));
bmp3.TransparentColor:=clBlack;
bmp3.TransparentMode:=tmFixed;
bmp3.Transparent:=True;
bmp3.Height:=J.Height;
Bmp3.Width:=J.Width;

Bmp3.Canvas.Draw(0,0,J);
Get:=TResourceStream.Create(hInstance,'P'+IntTostr(Random(3)),RT_RCDATA);
J.LoadFromStream(Get);
Get.Free;
FrameImg.Canvas.Draw(28,28,J);
For i:=0 to 43 do
  begin
    // FrameIMG.Picture.Bitmap.Canvas.CopyRect(Rect(Width-i*16,28,Width-i*16+BMP2.Width,28+bmp2.Height),
      //                     BMP2.Canvas,Rect(0,0,BMP2.Width,bmp2.Height));
     FrameIMG.Picture.Bitmap.Canvas.Draw(Width-(i-4)*16,28,bmp2);
     FrameIMG.Picture.Bitmap.Canvas.Draw(-120+(i-4)*4,28,bmp1);
     FrameIMG.Picture.Bitmap.Canvas.Draw(0,0,bmp3);
     FrameIMG.Refresh;
  end;
bmp1.Free;
bmp2.Free;
bmp3.Free;
J.Free;
ShowCursor(True);
end;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:duke_n
ID: 6265718
and as I said I don't know how to handle DirectX
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6265738
You should be able to speed things up a bit by drawing onto a temporary bitmap (in memory) and then just throw that image at the screen once

i.e. Instead of drawing all four bitmaps to the screen each time in your loop, draw them to a temporary bitmap and then output THAT to the screen

The Neil =:)
0
 
LVL 1

Author Comment

by:duke_n
ID: 6266137
Oh, dude DelphiX has a ton of very good samples.
Wow it is pretty whack!
:)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 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