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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [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; videoOut.VideoBitmap.UnlockBits(bmd); } } |
Write a Comment