我在模擬生命遊戲的WPF應用程序中編寫程序。 我如何使GDI +像圖形操作一樣進行預成型以創建包含單元網格的圖像?在WPF應用程序中使用GDI +
(通常,在WinForms中,我會知道如何執行此操作)。
編輯: 我用這個代碼:
WriteableBitmap wb = new WriteableBitmap(width * 5, height * 5, 100, 100, new PixelFormat(), new BitmapPalette(new List<Color> { Color.FromArgb(255, 255, 0, 0) }));
wb.WritePixels(new Int32Rect(0, 0, 5, 5), new IntPtr(), 3, 3);
Background.Source = wb;
背景是System.Windows.Controls.Image
控制
你有沒有想過使用WPF'Grid'和'Rectangle's?你甚至可能會獲得更好的性能,因爲一切都是基於矢量的 – madd0 2011-03-03 15:22:51