Jump to content
  • Advertisement
Sign in to follow this  
CLoudius

Flash BitBlt success but fps help?

This topic is 4731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!