Sack Library Documentation
sack::image::ColorAverage Variable
IMAGE_PROC_D CDATA (__cdecl * ColorAverage)(CDATA c1, CDATA c2, int d, int max);
How from from 0 to max distance to scale. 
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.
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at
Copyright (c) 2000+. All rights reserved.
What do you think about this topic? Send feedback!