c# - 在 C# 中的位图上映射温度数据
问题描述
我有一个二维数组,其中包含来自 C# 中数值求解的传热问题的温度数据。为了可视化温度分布,我使用了“位图”;最低温度用蓝色表示,而最高温度用红色表示!问题是生成 300x300 图像大小的位图需要太多时间!虽然我正在尝试与更大的合作,但这是不可能的!有没有更有效的方法让它工作?任何帮助将不胜感激这是我的一些代码和生成的位图:在此处输入图像描述
//RGB Struct
struct RGB
{
public Int32 num;
public int red;
public int green;
public int blue;
public RGB(Int32 num)
{
int[] color = new int[3];
int i = 2;
while (num > 0)
{
color[i] = num % 256;
num = num - color[i];
num = num / 256;
i--;
}
this.red = color[0];
this.green = color[1];
this.blue = color[2];
this.num = (256 * 256) * color[0] + 256 * color[1] + color[2];
}
}
//Create Color Array
Int32 red = 16711680;
Int32 blue = 255;
Int32[,] decimalColor = new Int32[Nx, Ny];
for (int i = 0; i < Nx; i++)
{
for (int j = 0; j < Ny; j++)
{
double alpha = (T_new[i, j] - T_min) / (T_max - T_min);
double C = alpha * (red - blue);
decimalColor[i, j] = Convert.ToInt32(C) + blue;
}
}
//Bitmap Result
Bitmap bmp = new Bitmap(Nx, Ny);
for (int i = 0; i < Nx; i++)
{
for (int j = 0; j < Ny; j++)
{
RGB rgb = new RGB(decimalColor[i, j]);
bmp.SetPixel(i,j,Color.FromArgb(rgb.red,rgb.green,rgb.blue));
}
}
pictureBox1.Image = bmp;
解决方案
推荐阅读
- ios - Delphi / ios:链接动态库应用程序时立即崩溃并出现错误“找不到图像”
- python - 在 Pandas 中查找每 10 秒值变化的平均值和标准差
- r - 对于 r 中的 rprop,神经网络中默认的初始学习率是多少?
- html - 当我从另一个指定了 viewBox 的文件中引用 SVG 时,为什么我需要指定 viewBox 属性?
- swift - 我在 swift 中的数据库连接不起作用
- java - 包括带有 Steam 应用程序的 JRE
- python - 循环中的 mininet 主机之间的 ICMP 回显数据包被丢弃
- sql - 如果子选择中不存在字符串,则从 postgres 数组中删除元素
- unity3d - 拼图完成后如何播放音频而不是显示wintext
- html - 如何在不同大小的容器中保持两个相同大小的 flexbox 元素?