Board index » delphi » bitmap.savetofile

bitmap.savetofile

In a time critical application grabbing pictures I have to store several
bitmaps to disk using bitmap.savetofile('name.bmp').
After this command the performance of my system is less than before and
I'm missing pictures.
How can I enforce the system to write immediately to disk so that there
won't be access to harddisk when program continues execution?
 

Re:bitmap.savetofile


Hi Andreas!
The fastest possible would probably be to use threads! (TThread)

Regards
        Olrik Larsen
        Ol...@MercuryGroup.dk

Quote
On Tue, 28 Mar 2000 10:14:30 +0200, Andreas Seyler <sey...@itap.de> wrote:
>In a time critical application grabbing pictures I have to store several
>bitmaps to disk using bitmap.savetofile('name.bmp').
>After this command the performance of my system is less than before and
>I'm missing pictures.
>How can I enforce the system to write immediately to disk so that there
>won't be access to harddisk when program continues execution?

Re:bitmap.savetofile


Maybe Flush will be of use here?

Re:bitmap.savetofile


Quote
On Tue, 28 Mar 2000 11:41:18 +0200, "Linus Elman" <pr...@techno.org> wrote:
>Maybe Flush will be of use here?

Hmm! Maybe, but that would still occupy a timeslice, it's like making the application idle
for amoment but ofcourse not the same as calling Application.ProcessMessages which
would enable windows to do other unwanted tasks.
On the other hand! I thought that the flush thing was gone together with Windows 3.xx ;-)
One last consideration is that Andreas is overwriting the TBitmap.Canvas without been
aware of it ???

Regards
        Olrik Larsen
        mailto:Ol...@MercuryGroup.dk

Re:bitmap.savetofile


Quote
"Andreas Seyler" <sey...@itap.de> wrote in message

news:38E069E6.1A32@itap.de...

Quote
> In a time critical application grabbing pictures I have to store several
> bitmaps to disk using bitmap.savetofile('name.bmp').
> After this command the performance of my system is less than before and
> I'm missing pictures.
> How can I enforce the system to write immediately to disk so that there
> won't be access to harddisk when program continues execution?

I suggest running some experiments to find out what your system
is capable of doing.  For example, how fast can you save a series
of images?  Try this experiment:

procedure TForm1.Button1Click(Sender: TObject);
  VAR
    i     :  INTEGER;
    Bitmap:  TBitmap;
    Start :  DWORD;
begin
  Start := GetTickCount;
  // This test will need about 100 MB of disk space
  FOR i := 1 TO 100 DO
  BEGIN
    Bitmap := TBitmap.Create;
    TRY
      Bitmap.Width  := 640;
      Bitmap.Height := 480;
      Bitmap.PixelFormat := pf24bit;

      // Draw random line with random color
      Bitmap.Canvas.Pen.color := TColor(Random(16*16*16));
      Bitmap.Canvas.MoveTo(Random(640), Random(480));
      Bitmap.Canvas.LineTo(Random(640), Random(480));

      Bitmap.SaveToFile( IntToStr(i) + '.BMP');
    FINALLY
      Bitmap.Free
    END
  END;

  ShowMessage('Total time = ' + IntToStr(GetTickCount - Start) + ' ms')
end;

On an old 166 MHz Pentium, this took about 22 seconds to write 100
640-by-480 x pf24bit bitmaps to disk.   On a 400 MHz system this
took about 20 seconds -- so the time is more dependent on how good
your disk is than the speed of the  processor.  I can save about
5 images/second.

This also shows the problem of missing images isn't in the SaveToFile.
I'll bet your system isn't capturing them as fast as you'd like.  You
might be grabbing the same image twice if your image capture
hardware isn't fast enough.  Or when you do grab an image,
you may have already missed one.

I've used the EPIX PIXCI image processing card.  I can use
DirectX and display 30 frames a second, but the program
has no control except to start and stop the display.  With a
"get" and "display" image loop, I can with fast hardware
and a good video system get about 15 frames/second.
Any processing of the image in software (e.g., a flip or a
reverse) will slow everything down to perhaps 7 frames/
second.  Saving them to disk couldn't be any faster than
the experiment above demonstrates.

With the EPIX card you can capture a number of frames
to the image card memory and later retrieve them, but
normally a PC under software control can't keep up with
the image card.

--
efg

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Other Threads