【发布时间】:2012-10-18 08:45:10
【问题描述】:
我正在尝试在 C# windows 窗体上使用现有的位图图像,该窗体是渲染的 MandleBrot 分形。我想实现颜色循环。必须使用调色板图像来完成。这是我的代码,我被困了好几天,无法让它工作。代码必须在计时器方法中。
private void timer1_Tick(object sender, EventArgs e)
{
Bitmap bitmap2 = new Bitmap(640, 480,PixelFormat.Format8bppIndexed);
ColorPalette palette = bitmap2.Palette;
for (int i = 0; i < 256; i += 3)
{
Color b = new Color();
b = Color.FromArgb(i);
bitmap2.Palette.Entries.SetValue(b, i);
//b = Color.FromArgb(palette[i], palette[i + 1], palette[i + 2]);
// bitmap.Palette.Entries.SetValue(b, i);
//bitmap.Palette = palette;
}
mandelbrot();
}
原始图像称为位图,调色板需要是位图2。 谢谢
【问题讨论】:
-
这个问题你已经问过了(stackoverflow.com/questions/12894031/…),答案还是“使用HSV”。
-
这种方式太慢了,需要用到调色板。你能给我看一个工作的例子吗?
标签: c# winforms bitmap fractals pallet