标签:获取 point nta graph info height 清空 private sys
实现效果:
知识运用:
Bitmap类的GetPixel和SetPixel方法
public Color GetPixel (int x,int y) //获取bitmap图像中指定像素的颜色
public void SetPixel (int x, int y,Color color) //设置bitmap图像中指定像素的颜色
实现代码:
private void button1_Click(object sender, EventArgs e) { Bitmap myBitmap = (Bitmap)this.BackgroundImage.Clone(); //使用窗体背景的副本创建Bitmap对象 int intWidth = myBitmap.Width; //记录图片的宽度 int intHeight = myBitmap.Height/20; //记录图片的制定高度 Graphics myGraphics = this.CreateGraphics(); //创建窗体的Graphics对象 myGraphics.Clear(Color.WhiteSmoke); //使用指定颜色清空窗体背景 Point[] myPoints=new Point[20]; //定义数组 for (int i = 0; i < 20; i++) //记录百叶窗个节点的位置 { myPoints[i].X = 0; myPoints[i].Y = i * intHeight; } Bitmap bitmap=new Bitmap(myBitmap.Width,myBitmap.Height); //创建Bitmap对象 for (int m = 0; m < intHeight; m++) { for (int n = 0; n < 20; n++) { for (int i = 0; i < intWidth; i++) { bitmap.SetPixel(myPoints[n].X + i, myPoints[n].Y + m, myBitmap.GetPixel(myPoints[n].X + i, myPoints[n].Y + m)); } } this.Refresh(); //绘制无效 this.BackgroundImage = bitmap; //显示百叶窗效果 System.Threading.Thread.Sleep(100); //线程挂起 } }
标签:获取 point nta graph info height 清空 private sys
原文地址:https://www.cnblogs.com/feiyucha/p/10265828.html