现在的位置: 首页 > 综合 > 正文

在运行时创建位图 (Visual C#)

2012年03月19日 ⁄ 综合 ⁄ 共 325字 ⁄ 字号 评论关闭

此示例创建并填充 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 命名空间的引用。

抱歉!评论已关闭.