此示例创建并填充 Bitmap 对象,然后在现有的 Windows 窗体 PictureBox 控件中显示该对象。
示例
void CreateBitmap() { System.Drawing.Bitmap flag = new System.Drawing.Bitmap(10, 10); for( int x = 0; x < flag.Height; ++x ) for( int y = 0; y < flag.Width; ++y ) flag.SetPixel(x, y, Color.White); for( int x = 0; x < flag.Height; ++x ) flag.SetPixel(x, x, Color.Red); pictureBox1.Image = flag; }
编译代码
本示例需要:
- 对 System 命名空间的引用。
文章来源: http://www.cnblogs.com/suiqirui19872005/archive/2007/06/03/769694.html