Sign in to follow this  
CLoudius

Flash BitBlt success but fps help?

Recommended Posts

CLoudius    126
Hello, I have a success with showing flash on a texture. But there's one little problem: I need to create the bitmap each time in the captureframe function. This takes 15 ms. This is a lot for fps because the flash file could be at 1280x1024 on a top system.
		public void Navigate(string url)
		{
			while (!ibrowser.Created)
			{
				Application.DoEvents();
			}

			object arg1 = 0;
			object arg2 = "";
			object arg3 = "";
			object arg4 = "";

			ibrowser.Navigate(url, ref arg1, ref arg2, ref arg3, ref arg4);
			ibrowser.Width = width;
			ibrowser.Height = height;

			//bmp = new Bitmap(width,height);

			while (!documentComplete)
			{
				Application.DoEvents();
			}

			while (GetHtmlBody() == null)
			{
				Application.DoEvents();
			}

			CaptureFrame();
			return;

		}

		private Bitmap bmp = new Bitmap(w,h); 

		private const int w = 1280;
		private const int h = 1024;

		private int width = w;
		private int height = h;
		Rectangle Rect = new Rectangle(0,0, w, h); 

		public Bitmap CaptureFrame()
		{
			
			bmp = new Bitmap(w,h); // This line must be applied each time but is not fast because it takes 15 ms
			while ((GetHtmlBody()) == null)
			{
				Application.DoEvents();
			}

			//lock (bmp)
			{
				IntPtr memDC = Win32.CreateCompatibleDC(IntPtr.Zero);
				Graphics g = Graphics.FromImage(bmp);
				IntPtr bitmapHDC = g.GetHdc();


				IntPtr memBmp = Win32.CreateCompatibleBitmap(bitmapHDC, width, height);
				IntPtr oldBmp = Win32.SelectObject(memDC, memBmp);

				Win32.OleDraw(this.ibrowser.GetOcx(), 1, memDC, ref Rect);

				Win32.BitBlt(bitmapHDC, 0,0, width, height, memDC, 0,0, TernaryRasterOperations.SRCCOPY);
				Win32.SelectObject(memDC, oldBmp);
				Win32.DeleteDC(memDC);
				Win32.DeleteObject(memBmp);
				Win32.DeleteDC(bitmapHDC);
				g.ReleaseHdc(bitmapHDC);
				g.Dispose();
			}
			return bmp;
		}
[Edited by - Coder on August 3, 2005 6:21:15 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this