/// <summary> /// 用窗口句柄初始化 /// </summary> /// <param name="hwnd">绘制窗口句柄</param> public DirectXEngine(Control ctrl) { _ctrl = ctrl; _cancelTask = new CancellationTokenSource(); InitHwndRenderTarget(); _bmp = new DXBitmap(hwndRenderTarget); }
public void ChangeBitmap(Stream s) { lock (_lockObj) { _preBmp = _bmp; //当前图片变成前一张图片 _bmp = new DXBitmap(hwndRenderTarget, s); //新图片赋值给当前图片 _opacity = 1f; // } }
public void ChangeBitmap(string imageFileName) { if (string.IsNullOrWhiteSpace(imageFileName)) { throw new ArgumentException(imageFileName); } if (!File.Exists(imageFileName)) { throw new FileNotFoundException(imageFileName); } lock (_lockObj) { _preBmp = _bmp; //当前图片变成前一张图片 _bmp = new DXBitmap(hwndRenderTarget, imageFileName); //新图片赋值给当前图片 _opacity = 1f; // } }
// Dispose(bool disposing) executes in two distinct scenarios. // If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources // can be disposed. // If disposing equals false, the method has been called by the // runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. if (hwndRenderTarget != null) { hwndRenderTarget.Dispose(); hwndRenderTarget = null; } if (_preBmp != null) { _preBmp.Dispose(); _preBmp = null; } if (_bmp != null) { _bmp.Dispose(); _bmp = null; } } // Call the appropriate methods to clean up // unmanaged resources here. // If disposing is false, // only the following code is executed. // Note disposing has been done. disposed = true; } }