码迷,mamicode.com
首页 > 其他好文 > 详细

积木效果

时间:2015-01-22 10:49:06      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

int avg, iPixel;
            Color C, newC;

            Graphics g = this.CreateGraphics();
            Bitmap bmp = new Bitmap(pictureBox1.Image);
            Bitmap tmp = (Bitmap)bmp.Clone();
            //根据色彩分量的值重新设置像素颜色
            for (int i = 0; i < bmp.Width - 1; i++)
                for (int j = 0; j < bmp.Height - 1; j++)
                {
                    C = tmp.GetPixel(i, j);
                    avg = (C.R + C.G + C.B) / 3;
                    iPixel = 0;
                    if (avg >= 128)
                        iPixel = 255;
                    newC = Color.FromArgb(255, iPixel, iPixel, iPixel);
                    tmp.SetPixel(i, j, newC); 
                }
            g.Clear(Color.WhiteSmoke);
g.Dispose();
pictureBox2.Image = tmp;

技术分享

积木效果

标签:

原文地址:http://www.cnblogs.com/wjshan0808/p/4240763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!