public override void display_pmap(Graphics displayGraphics) { GuiHalSurfaceWindowsFormsDXBackend app = ((GuiHalSurfaceWindowsFormsDXBackend)m_app); if (DX_Device == null) { return; } DX_Device.Clear(ClearFlags.Target, Color.White, 1.0f, 0); DX_Device.BeginScene(); if (this.ClientRectangle.Width != app.backBuffer.Width || this.ClientRectangle.Height != app.backBuffer.Height) { throw new System.IO.InvalidDataException("the back buffer must be the same size as the client area"); } using (Surface s = DX_Device.GetBackBuffer(0, 0, BackBufferType.Mono)) { int pitch; using (GraphicsStream graphicsStream = s.LockRectangle(this.ClientRectangle, LockFlags.None, out pitch)) { unsafe { int sourceOffset; Byte[] sourceBuffer = app.backBuffer.GetBuffer(out sourceOffset); byte *pDestBuffer = (byte *)graphicsStream.InternalDataPointer; int * pDestBufferInt = (int *)pDestBuffer; int height = app.backBuffer.Height; int scanWidth = app.backBuffer.Width * 4; int numLongs = scanWidth / 4; fixed(byte *pSourceBuffer = &sourceBuffer[sourceOffset]) { int *pSourceBufferInt = (int *)pSourceBuffer; for (int y = 0; y < height; y++) { int destOffsetInt = y * pitch / 4; int sourceOffsetInt = app.backBuffer.GetBufferOffsetXY(0, height - y - 1) / 4; for (int x = 0; x < numLongs; x++) { pDestBufferInt[destOffsetInt++] = pSourceBufferInt[sourceOffsetInt++]; } } } } } s.UnlockRectangle(); } // Rendering is done here DX_Device.EndScene(); DX_Device.Present(); }
public GuiHalSurface CreateSurface(int Width, int Height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat) { GuiHalSurface newSurface; switch (pixelFormat) { case GuiHalSurface.PixelFormat.PixelFormatBgra32: newSurface = new GuiHalSurfaceWindowsFormsDXBackend(GuiHalSurface.ImageFormats.pix_format_bgra32); break; default: throw new NotImplementedException(); } newSurface.Init(Width, Height, flags, pixelFormat); return newSurface; }
public GuiHalSurface CreateSurface(int Width, int Height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat) { GuiHalSurface newSurface; switch (pixelFormat) { case GuiHalSurface.PixelFormat.PixelFormatBgra32: newSurface = new GuiHalSurfaceWindowsFormsDXBackend(GuiHalSurface.ImageFormats.pix_format_bgra32); break; default: throw new NotImplementedException(); } newSurface.Init(Width, Height, flags, pixelFormat); return(newSurface); }