以“瀑布图”为例,代码如下:
public Bitmap GetBitMap(Matrix _matrix,bool isMap )
{
if (_matrix == null)
{
throw new ImageMapException("图片数据为空!!");
册肆 }
Bitmap bmp = new Bitmap(_matrix.ColCount, _matrix.RowCount);
for (int i = 0; i < bmp.Width; i++)
{
for (int j = 0; j < bmp.Height; j++)
{
汪禅 Color tmpColor;
if (!isMap)
{
tmpColor = Color.FromArgb(_matrix[i, j]);
}
else
{
困姿尘 if (_matrix[i, j] == 0)
{
tmpColor = Color.FromArgb(IM_WHITE);
}
else
{
tmpColor = Color.FromArgb(IM_BLACK);
}
}
bmp.SetPixel(i, j, tmpColor);
}
}
return bmp;
}