Commit de1d8f38 authored by saeed's avatar saeed

update on the ocean color

parent e1677041
time gcc -g -std=c99 -O2 rita.c -o odbview -lX11 -lm -lpthread
......@@ -12,13 +12,39 @@ static void colortoRGBA(uint32 color, uint8 *red, uint8 *green, uint8 *blue, uin
return;
}
static void lineartosrgb(float *red, float *green, float *blue){
*red = sqrt(*red);
*green = sqrt(*green);
*blue = sqrt(*blue);
}
static uint32 lineartosrgbi(uint32 color){
uint32 result = 0x00000000;
uint8 ured = 0x00;
uint8 ugreen = 0x00;
uint8 ublue = 0x00;
uint8 ualpha = 0x00;
float red = ((uint8)((color & 0x00FF0000) >> 16)) / 255.0;
float green = ((uint8)((color & 0x0000FF00) >> 8)) / 255.0;
float blue = ((uint8)(color & 0x000000FF) ) / 255.0;
float alpha = ((uint8)((color & 0xFF000000) >> 24)) / 255.0;
lineartosrgb(&red, &green, &blue);
ured = (uint8 )(red * 255.0);
ugreen = (uint8 )(green * 255.0);
ublue = (uint8 )(blue * 255.0);
ualpha = (uint8 )(alpha * 255.0);
result = (((uint32)ured << 16) | ((uint32)ugreen << 8) | ((uint32)ublue) | (uint32)ualpha<<24);
return result;
}
static void clamp(float *value, float min, float max){
if (*value <= min) *value = min;
......@@ -148,17 +174,17 @@ static void drawonscreen_expose(struct Vis *vis,struct dsp_field *dspf,struct Co
for (int j=0; j < dspf->ny; ++j){
for (int i=0; i < dspf->nx;++i){
if (dspf->SSH[(dspf->ny -j -1)*dspf->nx+i] == 0.0){
pcolor=landcolor;
pcolor=land_color;
}
else{
pcolor=oceancolor;
pcolor=ocean_color;
}
*pimage++ = pcolor;
}
}
ximage = XCreateImage(vis->dsp, vis->visual, 24, ZPixmap, 0, dspf->image32, vis->w, vis->h, 32, 0);
XPutImage(vis->dsp, pixmap, vis->gc, ximage, 0, 0, 0, 0, vis->w, vis->h);
XSetForeground(vis->dsp, vis->gc, stncolor);
XSetForeground(vis->dsp, vis->gc, stn_color);
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
......@@ -260,10 +286,10 @@ static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolo
for (int j=0; j < dspf->ny; ++j){
for (int i=0; i < dspf->nx;++i){
if (dspf->SSH[(dspf->ny -j -1)*dspf->nx+i] == 0.0){
pcolor=landcolor;
pcolor=land_color;
}
else{
pcolor=oceancolor;
pcolor=ocean_color;
}
*pimage++ = pcolor;
}
......@@ -315,17 +341,17 @@ static void drawonscreen_motion(struct Vis *vis,struct Colort *scolor, int ncolo
for (int j=0; j < dspf->ny; ++j){
for (int i=0; i < dspf->nx;++i){
if (dspf->SSH[(dspf->ny -j -1)*dspf->nx+i] == 0.0){
pcolor=landcolor;
pcolor=land_color;
}
else{
pcolor=oceancolor;
pcolor=ocean_color;
}
*pimage++ = pcolor;
}
}
ximage = XCreateImage(vis->dsp, vis->visual, 24, ZPixmap, 0, dspf->image32, vis->w, vis->h, 32, 0);
XPutImage(vis->dsp, pixmap, vis->gc, ximage, 0, 0, 0, 0, vis->w, vis->h);
XSetForeground(vis->dsp, vis->gc, stncolor);
XSetForeground(vis->dsp, vis->gc, stn_color);
for (int i=0; i< obsp->npy;++i){
if (obsp->iindex[i] != -1 && obsp->jindex[i] != -1){
struct Index index = map(obsp->iindex[i], obsp->jindex[i], vis->w, vis->h, NX, NY);
......
......@@ -22,6 +22,10 @@
typedef unsigned int uint32;
typedef unsigned char uint8;
static uint32 land_color = landcolor;
static uint32 ocean_color = oceancolor;
static uint32 stn_color = stncolor;
#pragma pack(push,1)
struct field {
short SSH[NX*NY];
......@@ -144,6 +148,15 @@ int main(int argc, char *argv[]){
int height = HEIGHT_INIT;
int ncolor = 0;
land_color = landcolor;
ocean_color = oceancolor;
stn_color = stncolor;
if (usesrgb) land_color = lineartosrgbi(landcolor);
if (usesrgb) ocean_color = lineartosrgbi(oceancolor);
if (usesrgb) stn_color = lineartosrgbi(stncolor);
struct screen_dim scdim = {0,0,0};
scdim.width = width;
scdim.height = height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment