【发布时间】:2015-04-29 23:59:39
【问题描述】:
谁能帮帮我:我想为图片框的每个像素绘制颜色
这是我到目前为止所做的:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication25
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
int x, y;
for (y = 0; y < 200; y++)
{
for (x = 0; x < 200; x++)
{
((Bitmap)pictureBox1.Image).SetPixel(x, y, Color.FromArgb(255, 255, 0));
}
}
}
}
}
我已经添加了一个计时器,所以我可以看到绘制每个像素的进度。
代码在内存中绘制的问题 - 延迟 - 然后放入图片框
我想在每个 y = 0 和 x = 0 到 200、y =1 x = 0 到 200、y=2 x=0 到 200 等处绘制颜色
【问题讨论】:
-
一个简单的解决方案是三个嵌套循环来生成所有可能值的范围。这是 O(n^3),但 800 万次迭代还不错。
-
实际上可以生成 (R,B,G) = (0..200, 0..200, 0..200) 之间的每种颜色。我建议了一种方法。
标签: c# draw picturebox progress