Jump to content
Xtreme .Net Talk

Bhen Hur

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Bhen Hur

  1. I'm tryin to do some Aplha blending with directdraw surfaces. I could not figure out how to do it using DirectDraw so I thought maybe I can do it manually. I tried to copy a portion of the suface into a bitmap object but it does not seem to work. Here is some code, btw it's in c# //Bitmap to hold the copied data Image _bitmap = new Bitmap(mPortion.Width, mPortion.Height); Graphics _g1 = Graphics.FromImage(_bitmap); IntPtr _dc1 = _g1.GetHdc(); //Get the surface's dc IntPtr _surfacedc = _surface.GetDc(); IntPtr _dc2 = CreateCompatibleDC(_surfacedc); //Copy the portion rectangle BitBlt(_dc1, mPortion.X, mPortion.Y, mPortion.Width, mPortion.Height, _dc2, 0, 0, 0x00CC0020); //Save the bitmap to test whether anything was copied _bitmap.Save("bah.bmp", System.Drawing.Imaging.ImageFormat.Bmp); //Clean _g1.ReleaseHdc(_dc1); _surface.ReleaseDc(_surfacedc); DeleteDC(_dc2); Nothing is being copied to the bitmap, can anyone help? Is there an easier way of doing this?
  2. System.Drawing.Font fntT = new System.Drawing.Font("Courier New",10); surPrint.FontHandle = fntT.ToHfont(); surPrint.ForeColor = Color.White; Hi, the above code is exactly what i use to set the font handle of the surface. This code exsists in the main loop, so for every frame this is executes. When i run the program it works fine for about a minute or two, until an exception occurs: An unhandled exception of type 'System.ArgumentNullException' occurred in microsoft.directx.directdraw.dll Additional information: Value cannot be null. This is very annoying. Nothing changes in the loop... the same code is executed. As I said before the code works for about 2 minutes then throws this exception. I commented out the lines dealing with the font handle System.Drawing.Font fntT = new System.Drawing.Font("Courier New",10); surPrint.FontHandle = fntT.ToHfont(); And it runs fine without throwing any exceptions at any time. So I'm guessing it has something to do with the font handle. But it works fine for 2 mins :confused:. Btw, because of what I have planned, I need to set the font handle every time it loops. So setting it before the loop begins is not an option for me. I hope this is not an internal error that is out of my reach, that would suck. Any ideas / suggestions thanx in advanced.
×
×
  • Create New...