public void RefreshViewer() { _entityBinder.UpdateObject(); EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions(); _pictureData = DebugApi.GetEventViewerOutput(options); int picHeight = _baseHeight; if (_screenBitmap == null || _screenBitmap.Height != picHeight) { _screenBitmap = new Bitmap(_baseWidth, picHeight); _overlayBitmap = new Bitmap(_baseWidth, picHeight); _displayBitmap = new Bitmap(_baseWidth, picHeight); } GCHandle handle = GCHandle.Alloc(this._pictureData, GCHandleType.Pinned); try { Bitmap source = new Bitmap(_baseWidth, _baseHeight, _baseWidth * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); using (Graphics g = Graphics.FromImage(_screenBitmap)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; g.DrawImageUnscaled(source, 0, 0); } } finally { handle.Free(); } UpdateDisplay(true); }
public void RefreshViewer() { EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions(); _isGameboy = EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy; if (_isGameboy) { _baseWidth = 456 * 2; _xRatio = 0.5; } else { _baseWidth = 1364 / 2; _xRatio = 2; } _pictureData = DebugApi.GetEventViewerOutput(_baseWidth, ScanlineCount, options); int picHeight = (int)ScanlineCount * 2; if (_screenBitmap == null || _screenBitmap.Height != picHeight || _screenBitmap.Width != _baseWidth) { _screenBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb); _overlayBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb); _displayBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb); } GCHandle handle = GCHandle.Alloc(this._pictureData, GCHandleType.Pinned); try { Bitmap source = new Bitmap(_baseWidth, (int)ScanlineCount * 2, _baseWidth * 4, PixelFormat.Format32bppPArgb, handle.AddrOfPinnedObject()); using (Graphics g = Graphics.FromImage(_screenBitmap)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; g.DrawImageUnscaled(source, 0, 0); } } finally { handle.Free(); } UpdateDisplay(true); }