🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.nativeapi
Article #215

Re: Getting 1st frame from AVI

#215
From: Pieter Zijlstra
Date: Sat, 24 Jan 2004 15:13
43 lines
2227 bytes
Simonetti wrote...

> How do I get the first frame of an AVI (either file or resource)
> as a bitmap?

I don't know if there is a direct way to do it.
What once did was loading the AVI in a TAnimate,
play frame by frame and copy the canvas content
to a bitmap. Something like this...

var
  Bitmap: TBitmap;
  i, x: Integer;
begin  for x := 1 to 8 do  // eight common AVIs
  begin
    Animate1.CommonAVI := TCommonAVI(x);
    for i := 1 to Animate1.FrameCount do
    begin
      Animate1.Play(i, i+1, 1);
      Label1.Caption := IntToStr(i);
      Bitmap := TBitmap.Create;
      try
        Bitmap.Width  := Animate1.Width;
        Bitmap.Height := Animate1.Height;
        Bitmap.Pixelformat := pf8bit; // pf24bit;
        Bitmap.Canvas.CopyRect(Bitmap.Canvas.ClipRect,
                               Self.Canvas,
                               Rect(Animate1.Left, Animate1.Top,
                                    Animate1.Left + Bitmap.Width,
                                    Animate1.Top  + Bitmap.Height));
        Bitmap.SaveToFile('AviBitmaps\'+
          IntToStr(Ord(Animate1.CommonAVI))+'_'+IntToStr(i) +'.bmp');
      finally
        Bitmap.Free
      end;
      Sleep(50);
      Application.ProcessMessages; // Just to update the label.
    end;
  end;
end;

-- 
Pieter
Technical Details
Message-ID: <40128b29$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40119ae4@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,6266bccb5a8e205
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2004-01-24 07:18:12 PST
From: "Pieter Zijlstra" <pzijlstra02@freeler.nl>
Subject: Re: Getting 1st frame from AVI
Newsgroups: borland.public.delphi.nativeapi
References:  <40119ae4@newsgroups.borland.com>
User-Agent: XanaNews/1.15.8.5
Date: Sat, 24 Jan 2004 16:13:07 +0100
NNTP-Posting-Host: 62.21.141.161
Message-ID: <40128b29$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1074957097 62.21.141.161 (24 Jan 2004 07:11:37 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail