2013-05-03 77 views
0

我有20幀每秒。我在每一幀畫出一些線條,我得到的線條沒有問題,但經常會出現背景圖像的問題。隨機我得到10幀相同的圖像,但線條看起來不錯。Drawing.Line位圖與圖像LockBits

if (cizik == null) 
{ 
BitmapData imageData = CloneOrj2.LockBits(new Rectangle(0, 0, CloneOrj2.Width, CloneOrj2.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); 
UnmanagedImage tmp = new UnmanagedImage(imageData); 
cizik = UnmanagedImage.Create(CloneOrj2.Width, CloneOrj2.Height, PixelFormat.Format24bppRgb); 
tmp.Copy(cizik); 
Drawing.Line(cizik, new IntPoint(XX, XX), new IntPoint(XX, XX), System.Drawing.Color.Yellow); 
} 
else 
{ 
BitmapData imageData = CloneOrj2.LockBits(new Rectangle(0, 0, CloneOrj2.Width, CloneOrj2.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); 
UnmanagedImage tmp = new UnmanagedImage(imageData); 
Drawing.Line(tmp, new IntPoint(XX, XX), new IntPoint(XX, XX), System.Drawing.Color.Yellow); 
cizik = UnmanagedImage.Create(CloneOrj2.Width, CloneOrj2.Height, PixelFormat.Format24bppRgb); 
tmp.Copy(cizik); 
} 

DrawScreenActual.Image = (System.Drawing.Image)cizik.ToManagedImage().Clone(); 

感謝您的幫助!

回答

0

也許你的代碼沒有完全顯示出來,但是在LockBits之後你必須解鎖這些位。

爲此,您必須在位圖對象中使用UnlockBits方法。我會在DrawLine之後調用它。

也許有問題!