我在模拟生命游戏的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