From: ehofman Date: Fri, 14 Jan 2005 15:52:56 +0000 (+0000) Subject: Add support for contrast. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e2e74662504e86f92a9b92f7b3bde4ab1563f090;p=simgear.git Add support for contrast. --- diff --git a/simgear/screen/texture.cxx b/simgear/screen/texture.cxx index a04242b4..cc27c83f 100644 --- a/simgear/screen/texture.cxx +++ b/simgear/screen/texture.cxx @@ -19,6 +19,7 @@ #include SG_GLU_H +#include #include #include "texture.hxx" @@ -806,6 +807,11 @@ SGTexture::make_monochrome(float contrast, GLubyte r, GLubyte g, GLubyte b) { GLubyte *rgb = get_pixel(x,y); GLubyte avg = (rgb[0] + rgb[1] + rgb[2]) / 3; + if (contrast != 1.0) { + float pixcol = -1.0 + (avg/128); + avg = 128 + 128*powf(pixcol, contrast); + } + ap[0] = avg*r/255; ap[1] = avg*g/255; ap[2] = avg*b/255; @@ -817,17 +823,23 @@ SGTexture::make_monochrome(float contrast, GLubyte r, GLubyte g, GLubyte b) { void SGTexture::make_grayscale(float contrast) { - if (num_colors >= 3) + if (num_colors < 3) return; GLubyte *map = (GLubyte *)malloc (texture_width * texture_height); + for (int y=0; y