Solved

Faster graphic loading

Posted on 2004-10-13
6
192 Views
Last Modified: 2010-04-05
I need a method to load graphic faster than:

TBitmap.LoadFromFile('path');

...I heard something about DirectDraw, but I'm not sure how it works.

Thanks for your participation.
0
Comment
Question by:TheCokeGuy
  • 4
  • 2
6 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12302141
One way to make your graphics load faster (or rather, give the impression of it loading faster), is to first read the whole graphic, and then drawing it when needed.

About DirectDraw, well, it essentially means programming by utilising the DirectX APIs. Header translations and examples are available here:

http://turbo.gamedev.net/asphyre.asp
http://turbo.gamedev.net/delphix.asp
http://turbo.gamedev.net/undelphix.asp
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12302172
Ah, found a tutorial and intro in using DirectDraw: http://www.savagesoftware.com.au/DelphiGamer/showarticles.php?articleid=14&page=1
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12302233
Oh, and about the first method I explained, well, let's say you want to draw an Image somewhere on your TForm, you can prebuffer it during your Form's OnCreate:

type
  TForm1 = class(TForm)
    procedure Form1Create(Sender: TObject);
    procedure Form1Destroy(Sender: TObject);
  private
    MyBuffer: TBitmap;
  end;

...

procedure TForm1.Form1Create(Sender: TObject);
begin
  MyBuffer := TBitmap.Create;
  MyBuffer.LoadFromFile('myfile.bmp');
end;

procedure TForm1.Form1Destroy(Sender: TObject);
begin
  MyBuffer.Free;
end;

to display the file anytime on your form, issue a

Form1.Canvas.Draw(0, 0, MyBuffer);

and you are done! Almost instantaneous drawing. You can also look at BitBlt and CopyRect from the Help file.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:TheCokeGuy
ID: 12302449
I'm creating a thumbnail viewer and I need to load all the images fast, because it's too slow right now.

I need a function, that do the same as "LoadFromFile". A little like "scanline" is faster than formating every pixel in a photo.
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 250 total points
ID: 12302720
In that case, download this file http://club.telepolis.com/silverpointdev/velvex/VELVExDemo.zip and see if it is similar to what you are doing. Read more about Velvex here: http://club.telepolis.com/silverpointdev/velvex/downloads.htm

Note that the above demo utilises VirtualTreeEx, which has some sort of 'load on demand' mechanism, therefore, if you are making a thumbnail viewer, your programme will load those files that are only currently viewed by the user, and will process the rest later. That will speed up your display. Check it out.
0
 

Author Comment

by:TheCokeGuy
ID: 12302770
Thanks...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

19 Experts available now in Live!

Get 1:1 Help Now