📄 subject_26288.htm
字号:
<p>
序号:26288 发表者:zfl 发表日期:2002-12-30 21:10:08
<br>主题:图例颜色与变量值的对应关系
<br>内容:在计算机绘图时常用颜色来表示所要显示的变量值。如果颜色用RGB()函数来实现,如何将变量值与RGB()中的三个变量对应?盼各位大侠赐教。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:不说 回复日期:2002-12-30 22:56:20
<br>内容:GetRValue() GetGValue() GetBValue().......
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:bb 回复日期:2002-12-31 10:52:33
<br>内容:先确定想要显示的图形的颜色数,一般用256色颜色表.<BR>假设颜色数为COLOR_COUNT<BR>初始化颜色表:<BR>COLORREF colorTable[COLOR_COUNT];<BR>for(i=0;i<COLOR_COUNT; i++)<BR>{<BR> if(i<COLOR_COUNT/2)<BR> {<BR> colorTable[i]=RGB(0, 512*i/COLOR_COUNT, 256-256*i/COLOR_COUNT);<BR> }<BR> else<BR> {<BR> colorTable[i]=RGB(512*(i-COLOR_COUONT)/COLOR_COUNT, <BR> 512-512*i/COLOR_COUNT, 0);<BR> }<BR>}<BR>假设原始数据为<BR>float data[x][y]=....<BR>找出原始数据的最大值maxd、最小值mind<BR>做一个颜色映射,<BR>COLORREF map[x][y];<BR>int index;<BR>for(i=0;i<x;i++)<BR>{<BR> for(j=0;j<y;j++)<BR> {<BR> index=(int)(COLOR_COUNT*(data[i][j]-mind)/(maxd-mind));<BR> map[i][j]=colorTable[index];<BR> }<BR>}<BR><BR>将map[i][j]的颜色设置到坐标为(i,j)的点上即可。<BR><BR>如何设置颜色有很多优化办法,请参考其他资料。<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -