Bitmap ProcessFrame(IntPtr SourcePtr, int SourceRowPitch) { _lastFrame = new Bitmap(_rect.Width, _rect.Height, PixelFormat.Format32bppRgb); // Copy pixels from screen capture Texture to GDI bitmap var mapDest = _lastFrame.LockBits(new Rectangle(0, 0, _rect.Width, _rect.Height), ImageLockMode.WriteOnly, _lastFrame.PixelFormat); Parallel.For(0, _rect.Height, Y => { Utilities.CopyMemory(mapDest.Scan0 + Y * mapDest.Stride, SourcePtr + Y * SourceRowPitch, _rect.Width * 4); }); // Release source and dest locks _lastFrame.UnlockBits(mapDest); if (_includeCursor && _frameInfo.PointerPosition.Visible) { using (var g = Graphics.FromImage(_lastFrame)) MouseCursor.Draw(g, P => new Point(P.X - _rect.X, P.Y - _rect.Y)); } return(_lastFrame); }
/// <summary> /// /// </summary> /// <param name="sourcePtr"></param> /// <param name="sourceRowPitch"></param> /// <returns></returns> private Bitmap ProcessFrame(IntPtr sourcePtr, int sourceRowPitch) { var frame = new Bitmap(ScreenDpi.Width, ScreenDpi.Height, PixelFormat.Format32bppRgb); // Copy pixels from screen capture Texture to GDI bitmap var mapDest = frame.LockBits(new Rectangle(0, 0, ScreenDpi.Width, ScreenDpi.Height), ImageLockMode.WriteOnly, frame.PixelFormat); Parallel.For(0, ScreenDpi.Height, y => { Utilities.CopyMemory(mapDest.Scan0 + y * mapDest.Stride, sourcePtr + y * sourceRowPitch, ScreenDpi.Width * 4); }); // Release source and dest locks frame.UnlockBits(mapDest); if (!DxModel.FrameInfo.PointerPosition.Visible) { return(frame); } using (var g = Graphics.FromImage(frame)) MouseCursor.Draw(g, p => new Point(p.X - ScreenDpi.X, p.Y - ScreenDpi.Y)); return(frame); }
public IEditableFrame Capture() { // Update Location _region.Location = _locationFunc(); Gdi32.BitBlt(_hdcDest, 0, 0, _region.Width, _region.Height, _hdcSrc, _region.X, _region.Y, (int)CopyPixelOperation.SourceCopy); var img = new GraphicsEditor(Image.FromHbitmap(_hBitmap)); if (_includeCursor) { MouseCursor.Draw(img, _transform); } return(img); }
public Bitmap Capture(bool Cursor) { var rectangle = Screen.Bounds; var bmp = new Bitmap(rectangle.Width, rectangle.Height); using (var g = Graphics.FromImage(bmp)) { g.CopyFromScreen(rectangle.Location, Point.Empty, rectangle.Size, CopyPixelOperation.SourceCopy); if (Cursor) { MouseCursor.Draw(g, P => new Point(P.X - rectangle.X, P.Y - rectangle.Y)); } g.Flush(); } return(bmp); }
public IEditableFrame Capture() { try { OnCapture(); var img = new GraphicsEditor(Image.FromHbitmap(_hBitmap)); if (_includeCursor) { MouseCursor.Draw(img, _transform); } return(img); } catch (Exception e) when(!(e is WindowClosedException)) { return(RepeatFrame.Instance); } }
/// <summary> /// Draw this state to the screen. /// </summary> public override void Draw() { fps.IncrementFrames(); SpriteBatch batch = ServiceManager.Game.Batch; ServiceManager.Game.GraphicsDevice.RenderState.DepthBufferEnable = true; GraphicOptions.graphics.GraphicsDevice.Clear(GraphicOptions.BackgroundColor);//Must manually clear since we're not using the main Draw() batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.FrontToBack, SaveStateMode.SaveState); batch.Draw(sky, ServiceManager.Game.GraphicsDevice.Viewport.TitleSafeArea, Color.White); batch.End(); Scene.Draw(false); batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.FrontToBack, SaveStateMode.SaveState); batch.DrawString(ServiceManager.Game.Font, fps.GetFormattedFPS(), Vector2.Zero, Color.White); batch.DrawString(ServiceManager.Game.Font, FormatTimeLeft(timeLeft), Vector2.UnitX * 300, Color.White); batch.End(); tips.Draw(); buffbar.Draw(); if (mouseCursor != null) { mouseCursor.Draw(); } hud.Draw(); cd.Draw(); Chat.Draw(); miniMap.Draw(localPlayer.Position); Scores.Draw(); helpOverlay.Draw(); }