Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Faster graphic loading

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
TheCokeGuy
Asked:
TheCokeGuy
  • 4
  • 2
1 Solution
 
DragonSlayerCommented:
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
 
DragonSlayerCommented:
Ah, found a tutorial and intro in using DirectDraw: http://www.savagesoftware.com.au/DelphiGamer/showarticles.php?articleid=14&page=1
0
 
DragonSlayerCommented:
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
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!

 
TheCokeGuyAuthor Commented:
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
 
DragonSlayerCommented:
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
 
TheCokeGuyAuthor Commented:
Thanks...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now