PX Family

Datasheet (PDF)

Manual & Guide

Application Notes

Driver Updates

Example Source Code

Compatible Image Processing Software

Product FAQ

Home Page


Feedback at:
CSinfo@cyberoptics.com or
1-800-366-9131

PXCOLOR.C
This sample is derived from the VMSAMP.C sample (available on your DOS distribution disk). VMSAMP.C illustrates the use of the VESAMENU library including constructing and calculating the sizes of menus. It  can be used as the starting point for an application. 

This sample adds to the VMSAMP sample by illustrating how to use color  with a monochrome frame grabber and a monochrome VESAMENU library. 

There are two topics illustrated in this sample: 

  1. Drawing a color overlay on a monochrome image. 
  2. Producing color menus 


Drawing a color overlay on a monochrome image: 
In order to draw a color overlay on a monochrome image, you need to give up a few of the colors in the image. See the PX User Manual section on the input LUT. The LUT accepts 256 digitized values from the A/D converter. It produces 256 gray values according to the values it has been programmed with. Normally, the LUT is programmed with the values from 0 to 255. However, if you skip a few of those values, then you can convert those values to color on the VGA screen. For example, if you program the LUT such that the offsets 1, 2, and 3 all have the value of 0, then the LUT will not produce the values of 1, 2, and 3 since those values have not been programmed into the LUT. 

Normally the first 5 entries in the LUT would look like this: 

0, 1, 2, 3, 4 
However, in the above example the first 5 entries would look like this: 
0, 0, 0, 0, 4 


Remember that this removes the values 1, 2, and 3 from your image. If you absolutely need all 256 gray values in your image, then you cannot afford to do this. 

See Item 1 in the source code for an example of programming the first three offsets in the LUT. 
 
In order to draw a color overlay using the 3 values you have deleted from the LUT, you would need to set those values to RED, GREEN, and BLUE or any other colors. See the function SetPalette below. 

The last thing is to draw the rectangles using draw_rectangle().  The rectangles will appear in the color you choose. 

Producing color menus: 
The VESAMENU library provides a mechanism for setting the colors of menus, menu backgrounds, etc. VESAMENU exports a global variable called "colors". It contains 8 values that can be set, see Item 2 below. Also see Chapter 6 in the PX User Manual. The section on Menu Structures and Types defines the structure of colors. 



Compile as follows: 
Borland and Turbo: 
bcc -ml pxcolor.c px5_lb.lib vmenu_lb.lib 
tcc -ml pxcolor.c px5_lb.lib vmenu_lb.lib 
Microsoft version 7.0 or later: 
cl /AL pxcolor.c px5_lm.lib  vmenu_lm.lib 
Microsoft before version 7.0: 
cl /AL pxcolor.c px5_l6.lib  vmenu_l6.lib