Skip to content
Snippets Groups Projects
Commit 6d406323 authored by slevy's avatar slevy
Browse files

Add rgb565 blackbody-color encoding from Mitchell Charity's code.

parent 3c59d5e5
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,9 @@
/*
* $Log$
* Revision 1.8 2002/04/23 03:21:22 slevy
* Add rgb565 blackbody-color encoding from Mitchell Charity's code.
*
* Revision 1.7 2002/04/22 23:16:50 slevy
* Ignore SIGPIPEs in case the caller disconnects early.
* Accept T=<scalefactor> as well as T=<16 numbers>.
......@@ -906,6 +909,25 @@ void starswap(db_star *st) {
#define starswap(x) /*nothing*/
#endif /*!WORDS_BIGENDIAN*/
static struct logTmap {
float logT;
unsigned short rgb565;
} tmap[] = {
// Adapted from Mitchell Charity's web page on black body RGB colors,
// http://www.vendian.org/mncharity/dir3/blackbody/
3.000, 0xf9c0, 3.079, 0xfa80, 3.204, 0xfb80, 3.301, 0xfc42,
3.380, 0xfce7, 3.477, 0xfdad, 3.556, 0xfe31, 3.643, 0xfed6,
3.716, 0xff5a, 3.792, 0xffbe, 3.869, 0xef7f, 3.944, 0xdf1f,
4.017, 0xcedf, 4.093, 0xbe9f, 4.164, 0xb67f, 4.236, 0xae5f,
4.310, 0xae3f, 4.380, 0xa61f, 4.450, 0xa5ff,
};
static unsigned short logT2rgb565(float logT) {
int i;
for(i = 0; i < COUNT(tmap)-1 && logT > tmap[i].logT; i++)
;
return tmap[i].rgb565;
}
int serveonce(char *req, FILE *outf)
{
......@@ -988,7 +1010,12 @@ int serveonce(char *req, FILE *outf)
star.y = p.x[1];
star.z = p.x[2];
star.magnitude = curstate.mag0 - .921 * logf( sp->val[SPECK_LUM] );
star.color = (unsigned short) (curstate.colorscale * sp->val[SPECK_TLOG]);
if(curstate.colorscale >= 0) {
star.color = (unsigned short) (curstate.colorscale * sp->val[SPECK_TLOG]);
} else {
/* packed rgb565 */
star.color = logT2rgb565( sp->val[SPECK_TLOG] );
}
star.num = (int) sp->val[SPECK_ID];
starswap(&star);
wrote = fwrite(&star, sizeof(star), 1, outf);
......@@ -1121,7 +1148,7 @@ main(int argc, char *argv[])
progname = argv[0];
curstate.colorscale = 100.0;
curstate.colorscale = -1;
curstate.has_T0 = 0;
curstate.port = 3400;
......@@ -1140,7 +1167,7 @@ Options:\n\
-y sdbtype\n\
-g group\n\
-m mag0 sdb mag = mag0 - log(lum)/(log(100)/5)\n\
-c colorscale sdb color = log10(T)*colorscale\n\
-c colorscale sdb color = log10(T)*colorscale; -c -1 => RGB565 (default)\n\
-p portno listen for HTTP connections on that TCP port\n\
", progname);
exit(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment