private void button1_Click(object sender, System.EventArgs e)
{
Color c = new Color();
Bitmap box1 = new Bitmap(pictureBox1.Image);
Bitmap box2 = new Bitmap(pictureBox1.Image);
int r, g, b, i, j, size, k1, k2, xres, yres;
xres = pictureBox1.Image.Width;
yres = pictureBox1.Image.Height;
size = 4;
for (i = 0; i <= xres - 1; i += size)
{
for (j = 0; j <= yres - 1; j += size)
{
c = box1.GetPixel(i, j);
r = c.R; g = c.G; b = c.B;
Color cs = Color.FromArgb(r, g, b);
for (k1 = 0; k1 <= size - 1; k1++)
{
for (k2 = 0; k2 <= size - 1; k2++)
{
if(j+k2<yres)
box2.SetPixel(i + k1, j + k2, cs);
}
}
}
}
pictureBox2.Refresh();
pictureBox2.Image = box2;
}
楼主只要修改红色那里,就可以通过运行了