// // gradient_int.cc // // Colour utility functions // // Copyright (c) J. Belson 2000.03.29 // #include "gradient_int.h" gradient_int::gradient_int( uchar r1, uchar g1, uchar b1, uchar r2, uchar g2, uchar b2, int step) { col_r = r1<<16; col_g = g1<<16; col_b = b1<<16; step_r = step_g = step_b = 0; if (step) { step_r = ((r2 - r1)<<16) / step; step_g = ((g2 - g1)<<16) / step; step_b = ((b2 - b1)<<16) / step; } } void gradient_int::set( uchar r1, uchar g1, uchar b1, uchar r2, uchar g2, uchar b2, int step) { col_r = r1<<16; col_g = g1<<16; col_b = b1<<16; step_r = step_g = step_b = 0; if (step) { step_r = ((r2 - r1)<<16) / step; step_g = ((g2 - g1)<<16) / step; step_b = ((b2 - b1)<<16) / step; } } void gradient_int::get_next(uchar &r, uchar &g, uchar &b) { r = col_r>>16; g = col_g>>16; b = col_b>>16; col_r += step_r; col_g += step_g; col_b += step_b; }