protected internal Backbuffer(VisibleSurface visSurface) { // make the dimensions equal to the VisibleSurface dimensions range = new Rectangle(0, 0, visSurface.Width, visSurface.Height); // create a new temp GDI+ Bitmap to get old GDI32 bitmap handle Bitmap memBmp = new Bitmap(range.Width, range.Height, visSurface.DC); // obtain handle to VisibleSurface Graphics object for Backbuffer instantiation IntPtr visDC = visSurface.DC.GetHdc(); // create a DC compatible with the visible surface DC IntPtr compatDC = pInvoke.CreateCompatibleDC(visDC); // associate the new bitmap handle with the Backbuffer DC pInvoke.SelectObject(compatDC, memBmp.GetHbitmap()); //create a GDI+ Graphics object for the Backbuffer dc = Graphics.FromHdc(compatDC); // release handle to VisibleSurface Graphics object visSurface.DC.ReleaseHdc(visDC); // Dispose of temp GDI+ Bitmap memBmp.Dispose(); // set default FogPen value to black with 128 alpha blending fogBrush = new SolidBrush(Color.FromArgb(128, Color.Black)); // set default GridPen value to white gridPen = new Pen(Color.White); //showGrid = false; matrixDisposeDel = new GridPointMatrixesDisposingEventHandler(source_Disposing); }