![]() |
![]() |
Example: Using a ramp (vpalRamp)
This example shows how to configure the virtual palette so an image is rendered with a ramp using an 8-bit visual. In this configuration, it is possible to dynamically change the colors in the hardware color lookup table.
This example is found in Libraries.Examples.Graphics_Display. The example renders an image of a mandrill in the viewer's window.
You are now ready to configure the virtual palette. This is the first step to allow the image to be rendered with a ramp. Note: these steps have already been done for you in the example that has been loaded.
Select an 8-bit visual for the virtual palette.
Open vclass. This controls the visual class that is used for this view. Set vclass to 3, which means 8-bit pseudo color visual.
Open cube_size. This controls the size of the color cube that is allocated in the virtual palette. Set cube_size to 3.
This reduces the amount of color resource consumed by the cube and allows the ramp to be larger. The dither pattern should now be readily apparent since the cube size is small.
Close VirtPal, close Uview2D, and close Uviewer2D.
You are now ready to configure the Graphics Display Kit object that represents the image so it will use a ramp. Note: these steps have already been done for you in the example that has been loaded.
Select the image in the view window using the left mouse button.
This causes the image to become the current object. Any subsequent changes you make using the viewer's editors will affect this object. Notice that the Current Object string at the bottom of the view window now says extract_scalar.
Select Editors->Object to make the object editor's user interface visible. Select Field Conversion from the Object option menu. Select Image from the Type option menu.
Select Ramp from the Dither Technique option menu.
This causes the datamap that is attached to the Graphics Display Kit object to be converted into a ramp and loaded into a section of the system palette. You should notice that the dither pattern that was present goes away since the image is now rendered with a ramp.
You are now ready to start modifying the datamap and see the effect of the changes you make.
Select Editors->Datamap to make the user interface for the datamap editor visible.
Set the Immediate toggle. This causes changes made to the sliders in the datamap editor to be processed as the slider is moved as opposed to when you are done moving the slider.
Select Edit Color from the Options option menu. Move the Min slider in the Hue frame.
Notice that the colors of the image are updated immediately. This is because the section of the hardware colormap that is used to render this image is being changed. The view is not rerendered in this case - a virtual palette that is using an 8-bit visual and an object that has a dither technique of ramp.
Select Edit Range/Data from the Options option menu. Set the Sub-range Values toggle. This will allow you to perform window leveling on the image.
As you move, all values in the image that are less than the slider value are clamped to the minimum color value. This process can be repeated for the Range Max slider.
Reset the range value sliders. Unset the Sub-range Values toggle.
You are now ready to change the datamap's ramp size. By default, the requested size of the ramp is 256 as indicated by the range size typein.
Set the range size typein to 5. Notice the effect this has on the image and on the color bar in the datamap editor. The individual color bands should be clearly visible.
Try other sizes in the range size type. Notice the effect on the image.
This completes the tutorial. The completed tutorial is available in Libraries.Examples.Graphics_Display.vpalRamp.
![]() |
![]() |