Recent

Author Topic: Fast picture loading  (Read 2668 times)

user5

  • Sr. Member
  • ****
  • Posts: 357
Fast picture loading
« on: January 17, 2016, 12:33:15 am »
I've been doing some picture loading speed tests. Each test in the attached code loads and displays 361 pngs. I noticed that the second run of each test ran faster than the first. I think I have the best that I can get but I'd like to know about any other loading procedure that I can try if anyone has any suggestions. Are Vampyre's low level methods fast?

Code: Pascal  [Select][+][-]
  1. //uses wincrt, intfgraphics, windows, SysUtils, FileUtil,
  2. //     EpikTimer, Forms, Controls, Graphics, LResources, Process, ExtCtrls,
  3. //     Dialogs, StdCtrls, LCLProc, ActnList, LCLIntf, LCLType, Interfaces,
  4. //     Buttons, ExtDlgs, Menus, ComCtrls, strutils, Classes,
  5. //     GraphType, LazLogger;
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. var timeperiod,extvar1:extended;
  9.     i:integer;
  10.     picture:TPicture;
  11.     mypng:TPortableNetworkGraphic;
  12.     tempstr1,filenum:string;
  13.     elapsedtime:string;
  14.     newimage: TLazIntfImage;
  15.     lRawImage: TRawImage;
  16.     tempvar1:integer;
  17.  
  18. begin
  19.  
  20.  epiktimer1.clear;
  21.  epiktimer1.start;
  22.  
  23.  lRawImage.Init;
  24.  lRawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(0,0);
  25.  lRawImage.CreateData(false);
  26.  newimage := TLazIntfImage.Create(0,0);
  27.  newimage.SetRawImage(lRawImage);
  28.  newimage.DataDescription:=GetDescriptionFromDevice(0);
  29.  mypng := TPortableNetworkGraphic.create;
  30.  picture := TPicture.create;
  31.  i := 0;
  32.  go := true;
  33.  edit1.text := '';
  34.  tempvar1 := 361;
  35.  application.processmessages;
  36.  
  37.  while (i < tempvar1) and (go) do
  38.   begin
  39.    application.processmessages;
  40.    i := i + 1;
  41.    str(i,filenum);
  42.  
  43.                          // #1 4.1 sec. (.exe) Transparent no
  44.    //newimage.LoadFromFile('c:\temp15\bin4\image'+filenum+'.png');
  45.    //Image1.picture.Bitmap.LoadFromIntfImage(newimage);
  46.  
  47.                          // #2 4.9 sec. (.exe) Transparent yes
  48.    //picture.loadfromfile('c:\temp47\image'+filenum+'.png');
  49.    //image1.picture := picture;
  50.  
  51.                          // #3 5.6 sec. (.exe)
  52.    //picture.loadfromfile('c:\temp47\image'+filenum+'.png');
  53.    //image1.canvas.draw(0,0,picture.Graphic);
  54.  
  55.                          // #4 5.2 sec. (.exe) Transparent: yes
  56.    //image1.picture.loadfromfile('c:\temp47\image'+filenum+'.png');
  57.  
  58.                          // #5 4.1 sec. (.exe) Transparent no
  59.    newimage.LoadFromFile('c:\temp47\image'+filenum+'.png');
  60.    mypng.LoadFromIntfImage(newimage);
  61.    image1.canvas.draw(0,0,mypng);
  62.  
  63.   end;
  64.  
  65.  newimage.free;
  66.  sound(350);
  67.  timeperiod := epiktimer1.elapsed;
  68.  elapsedtime := FloatToStr(timeperiod);
  69.  edit1.text := 'Time:> '+elapsedtime;
  70.  picture.free;
  71.  mypng.free;
  72. end;

benohb

  • Full Member
  • ***
  • Posts: 213
Re: Fast picture loading
« Reply #1 on: January 18, 2016, 01:08:03 am »


This depend on : operating system /file system / storage types /syscall



Quote
Are Vampyre's low level methods fast?


Yes, in some stages

 

TinyPortal © 2005-2018