Documentation Project 1
ContentsIndexHome
PreviousUpNext
sack::image::ColorAverage Variable
C++
IMAGE_PROC_D CDATA (__cdecl * ColorAverage)(CDATA c1, CDATA c2, int d, int max);
Parameters 
Description 
distance 
How from from 0 to max distance to scale. 
max 
How wide the scalar is. 

This routine can be used to generically scale to any point between two colors.

Max is the scale that distance can go from. Distance 0 is the first color, Distance == max is the second color. The distance from 0 to max proportionately scaled the color....

 

Compute a color that is halfway from blue to green. (if the total distance is 100, then 50 is half way).

CDATA blue_green = ColorAverage( blue, green, 50, 100 );

 

Compute a color that's mostly red.

CDATA red_blue_green = ColorAverage( blue_green, red, 240, 255 );

 

Iterate through a whole scaled range...

int n;
for( n = 0; n < 100; n++ )
{
    CDATA scaled = ColorAverage( BASE_COLOR_WHITE, BASE_COLOR_BLACK, n, 100 );
    // as n increases, the color slowly goes from WHITE to BLACK.
}
Copyright (c) 2010. All rights reserved.
What do you think about this topic? Send feedback!