F-IN-BOX News, Tips and Tricks

F-IN-BOX .NET Edition: How To Grab Frames From A Flash Movie

One customer wrote me:

Why GetBitmap method consums so much processor time.
It’s 720×576 25fps simple movie with 40-60% processor time.
I’m making a call to GetBitmap without any further processing.

Actually, GetBitmap is not a good way when you need to grab frames from a movie quickly. So, what is the best way?

Use f_in_box__control, set TransparentMode = true, then handle OnFlashPaint event, for example:

[DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory")]
private static extern void CopyMemory(IntPtr Destination, IntPtr Source, int Length); 

private void flashControl1_OnFlashPaint(object sender, IntPtr pPixelPointer)
  if (videoOut != null)
      BitmapData bmd = videoOut.VideoBitmap.LockBits(new Rectangle(0, 0, 720, 576), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
      int StrideSize = 720 * 4;
      for (int i = 0; i < 576; i++)
        IntPtr s = new IntPtr(pPixelPointer.ToInt32()+StrideSize * i);
        IntPtr d = new IntPtr(bmd.Scan0.ToInt32() + (StrideSize * (575 - i)));
        CopyMemory(d, s, StrideSize);
      videoOut.PixelPointer = bmd.Scan0;

Write a Comment

Note: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>