Solved

Faster graphic loading

Posted on 2004-10-13
6
195 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
Independent Software Vendors: 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!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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