SetRgnColorHSVRange method (Main Control)

Visual Basic example
Visual C++ 4.0 example

Syntax short SetRgnColorHSVRange (short nH0, short nS0, short nV0, short nH1, short nS1, short nV1, short iCombineMode);

Overview:  Refer to Creating and Using a Bitmap Region.

Remarks

Creates or updates the bitmap region by adding a region that consists of all the pixels that fall in the range (nH0, nS0, nV0) ... (nH1, nS1, nV1), inclusively.

This method uses the HSV color model to set a region based on a color range.

nH0, nS0, and nV0 define a minimum (inclusive) H,S, and V. nH1, nS1, nV1 define a maximum (inclusive) H,S, and V. A pixel must have H,S, and V all greater than or equal to nH0, nS0, nV0 and less than or equal to nH1, nS1, nV1 to be included in the region.

It is useful for identifying all shades of a certain color. For example, SetRgnColorHSVRange could be used to set a region of all green colors including:

 

RGB(0,1,0)

 

 

 

 

RGB(0,2,0)

RGB(1,2,1)

 

 

 

RGB(0,3,0)

RGB(1,3,1)

RGB(2,3,2)

 

 

...

...

...

...

 

RGB(0,255,0)

RGB(1,255,1)

RGB(2,255,2)

...

 

 

The diagram below shows how S and V affect the color green (H = 85)

image\huetable.gif

As an example, you could set a region for all red (and colors near red) by specifying arguments as follows:

nH0 = 250 nH1 = 5

nS0 = 1 nS1 = 255

nV0 = 1 nV1 = 255

Note that nH0 is 250 and nH1 is 5. For a hue to fall in this range, it must be either 250, 251, 252, 253, 254, 255, 1, 2, 3, 4, or 5. Also, note that the hue values wrap from 255 back around to 1.

To update an existing region, you specify how the new region is to be combined with the existing one. For possible values, specified in the iCombineMode parameter, refer to Flags for Setting a Region

See Also

Elements:  SetRgnColorRGBRange method, SetRgnColor method

Topics:  Raster Images: Creating and Using a Region