LoadBitmapFromBytes() public method

从给定的 Byte 数组中加载 Direct2D 位图。
public LoadBitmapFromBytes ( byte data ) : SharpDX.Direct2D1.Bitmap
data byte 要加载位图的数据。
return SharpDX.Direct2D1.Bitmap
Example #1
0
 /// <summary>
 /// 开始一个拼图游戏。
 /// </summary>
 /// <param name="ct">取消任务的通知。</param>
 private void StartGame(CancellationToken ct)
 {
     this.background = devices.LoadBitmapFromBytes(gameInfo.ImageData);
     this.imageSize  = background.Size;
     this.isDraging  = this.isSelecting = false;
     // 添加事件侦听器。
     this.renderPanel.JigsawRegionChanged += this.renderPanel_JigsawRegionChanged;
     this.renderPanel.JigsawScaleChanging += this.renderPanel_JigsawScaleChanging;
     // 设置渲染区域。
     this.renderPanel.Invoke(new Action(() =>
     {
         this.renderPanel.ImageSize = imageSize;
         this.renderPanel.SetJigsawScale(this.gameInfo.Scale, new Point(0, 0));
         this.renderPanel.AutoScrollPosition = this.gameInfo.ScrollPosition;
     }));
     if (this.gameInfo.UsedTime.Milliseconds == 0)
     {
         // 对于新游戏,重新分布拼图碎片。
         this.pieces.SpreadPieces(renderPanel.JigsawRegion, this.gameInfo.Rotatable);
     }
     this.UpdatePiecesVisible();
     ct.ThrowIfCancellationRequested();
     this.renderer.PrepareRender(gameInfo.ImageData, pieces, gameInfo.Rotatable, ct);
     ct.ThrowIfCancellationRequested();
     this.hasGame     = true;
     this.gameChanged = true;
     this.InvalidateAll();
     this.startTime = DateTime.Now - gameInfo.UsedTime;
     this.UpdateFinishedPercent();
     this.renderPanel.MouseDown += this.renderPanel_MouseDown;
     this.renderPanel.MouseMove += this.renderPanel_MouseMove;
     this.renderPanel.MouseUp   += this.renderPanel_MouseUp;
 }