近在研究灰度图像的渲染。arcgis在对dem进行渲染的时候出来的图也很精美。这得意于它色卡,色卡都是渐变色。因此出来的图具有渐变效果,栅格颜色之间的过渡很自然。
1为效果图,2为色卡。
经过我的研究其实这里的色卡得到的过程如下:
Blue渐变到(0,255,255),(0,255,255)渐变到Yellow,Yellow渐变到Red
1 效果图。
2 色卡
int stepnum = 1200;
Color[] color1 = new Color[2];
color1[0] = Color.Blue;
color1[1] = Color.FromArgb(0, 255, 255);
Color[] clr1 = this.GetGradient(color1, 400);
Color[] color2 = new Color[2];
color2[0] = Color.FromArgb(0, 255, 255);
color2[1] = Color.Yellow;
Color[] clr2 = this.GetGradient(color2, 400);
Color[] color3 = new Color[2];
color3[0] = Color.Yellow;
color3[1] = Color.FromArgb(255, 0, 0);
Color[] clr3 = this.GetGradient(color3, 400);
int len = clr1.Length + clr2.Length + clr3.Length;
Color[] color = new Color[len];
for (int i = 0; i < clr1.Length; i++)
{
color[i] = clr1[i];
}
for (int i = clr1.Length; i < clr1.Length + clr2.Length; i++)
{
color[i] = clr2[i - clr1.Length];
}
for (int i = clr1.Length + clr2.Length; i < clr1.Length + clr2.Length + clr3.Length; i++)
{
color[i] = clr3[i - clr1.Length - clr2.Length];
}
//下面创建bitmap开始画图
Bitmap bm = new Bitmap(stepnum, stepnum);
for (int i = 0; i < stepnum; i++)
{
for (int j = 0; j < 50; j++)
{
//通过设置每个像素点的值画图
bm.SetPixel(i, j,color[i]);
}
}
//在窗体上显示,预览
Graphics g = this.CreateGraphics();
g.DrawImage(bm, 0, 100);