- Timestamp:
- Mar 11, 2015, 3:11:07 AM (10 years ago)
- Location:
- geovis/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/ColorMap.cpp
r5118 r5119 34 34 float x = (float)i/(height-1); 35 35 float val = min + (max - min) * x; 36 osg::Vec4f rgb = map->getColor(val); 36 osg::Vec4f rgba = map->getColor(val); 37 float opacity = rgba[3]; 37 38 unsigned char color[3]; 38 39 if (opaque) { 39 color[0] = (unsigned char)(255. * (bgr ? rgb [2] : rgb[0]));40 color[1] = (unsigned char)(255. * rgb [1]);41 color[2] = (unsigned char)(255. * (bgr ? rgb [0] : rgb[2]));40 color[0] = (unsigned char)(255. * (bgr ? rgba[2] : rgba[0])); 41 color[1] = (unsigned char)(255. * rgba[1]); 42 color[2] = (unsigned char)(255. * (bgr ? rgba[0] : rgba[2])); 42 43 } else { 43 float opacity = rgb[3]; 44 color[0] = (unsigned char)(255. * (bgColor[0] * (1.0 - opacity) + (bgr ? rgb[2] : rgb[0]) * opacity)); 45 color[1] = (unsigned char)(255. * (bgColor[1] * (1.0 - opacity) + rgb[1] * opacity)); 46 color[2] = (unsigned char)(255. * (bgColor[2] * (1.0 - opacity) + (bgr ? rgb[0] : rgb[2]) * opacity)); 44 color[0] = (unsigned char)(255. * (bgColor[0] * (1.0 - opacity) + (bgr ? rgba[2] : rgba[0]) * opacity)); 45 color[1] = (unsigned char)(255. * (bgColor[1] * (1.0 - opacity) + rgba[1] * opacity)); 46 color[2] = (unsigned char)(255. * (bgColor[2] * (1.0 - opacity) + (bgr ? rgba[0] : rgba[2]) * opacity)); 47 47 } 48 48 for (int j = 0; j < width; j++) { … … 50 50 dst += 3; 51 51 if (bytesPerPixel == 4) { 52 *(dst++) = (unsigned char) 255.;52 *(dst++) = (unsigned char)(255. * (opaque ? 1.0 : opacity)); 53 53 } 54 54 } … … 60 60 float val = min + (max - min) * x; 61 61 osg::Vec4f rgb = map->getColor(val); 62 double opacity = rgb[3]; 62 63 unsigned char color[3]; 63 64 if (opaque) { … … 66 67 color[2] = (unsigned char)(255. * (bgr ? rgb[0] : rgb[2])); 67 68 } else { 68 double opacity = rgb[3];69 69 color[0] = (unsigned char)(255. * (bgColor[0] * (1.0 - opacity) + (bgr ? rgb[2] : rgb[0]) * opacity)); 70 70 color[1] = (unsigned char)(255. * (bgColor[1] * (1.0 - opacity) + rgb[1] * opacity)); … … 74 74 dst += 3; 75 75 if (bytesPerPixel == 4) { 76 *(dst++) = (unsigned char) 255.;76 *(dst++) = (unsigned char)(255. * (opaque ? 1.0 : opacity)); 77 77 } 78 78 } -
geovis/trunk/RendererCmd.cpp
r5118 r5119 743 743 Tcl_Obj *const *objv) 744 744 { 745 if (objc !=4) {745 if (objc < 4) { 746 746 Tcl_AppendResult(interp, "wrong # args: should be \"", 747 747 Tcl_GetString(objv[0]), " colormapName width height\"", (char*)NULL); … … 755 755 return TCL_ERROR; 756 756 } 757 758 757 bool opaque = true; 758 if (objc > 4) { 759 if (GetBooleanFromObj(interp, objv[4], &opaque) != TCL_OK) { 760 return TCL_ERROR; 761 } 762 } 759 763 float bgColor[3]; 760 memset(bgColor, 0, sizeof(float)*3); 764 if (objc > 5) { 765 if (GetFloatFromObj(interp, objv[5], &bgColor[0]) != TCL_OK || 766 GetFloatFromObj(interp, objv[6], &bgColor[1]) != TCL_OK || 767 GetFloatFromObj(interp, objv[7], &bgColor[2]) != TCL_OK) { 768 return TCL_ERROR; 769 } 770 } else { 771 memset(bgColor, 0, sizeof(float)*3); 772 } 761 773 osg::ref_ptr<osg::Image> imgData = new osg::Image(); 762 774 -
geovis/trunk/geovis_protocol.txt
r5107 r5119 85 85 <numberOfTableEntries> = integer or "default" 86 86 87 legend <colormapName> <w> <h> <?opaque?> <?bgR?> <?bgG?> <?bgB?> 88 Render a legend colorbar. 89 <colormapName> - Name of the colormap defined with the colormap command 90 <w>,<h> - width and height of colorbar 91 <opaque> - If false, blend with background color 92 <bgR>,<bgG>,<bgB> - Background color (defaults to black) 93 87 94 renderer render 88 95 Force a new image to be rendered
Note: See TracChangeset
for help on using the changeset viewer.