Solved

Faster graphic loading

Posted on 2004-10-13
6
191 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

20 Experts available now in Live!

Get 1:1 Help Now