Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Faster graphic loading

Posted on 2004-10-13
6
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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