rendered paste body gint color1_r, color1_g, color1_b, color2_r, color2_g, color2_b, min_d, d, color_index;
color1_r = gimp_context_get_background(GimpRGB 1); /* this is wrong */
color1_g = gimp_context_get_background(GimpRGB 2); /* so is this */
color1_b = gimp_context_get_background(GimpRGB 3); /* and this */
min_d = 195075; /* Max value possible is R^2 + G^2 + B^2 = ( 255^2 ) * 3 */
for (x = 0; x<16; x++) {
color2_r = vicpalette[x*3]
color2_g = vicpalette[x*3+1]
color2_b = vicpalette[x*3+2]
d = pow( (color1_r - color2_r), 2) ) + pow( (color1_g - color2_g) , 2 ) + pow ( (color1_b - color2_b), 2)
if (d < min_d) (
min_d = d
color_index = x
}
}
return min_d;
}