首页 > 其他 > 详细

积木效果

时间:2015-01-22 10:47:25      阅读:315      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!