title: Brightness, Contrast, Gamma adjustments with C++, Qt
body: <p>What is the easiest way to <strong>properly</strong> adjust Brightness, Contrast and Gamma of an image. The word 'properly' is here because I know how to perform these adjustments improperly: loop over all the RGB pixels and do the following to each channel:</p>
  
  <pre><code>int changeBrightness( int value, int brightness) {
      return qBound&lt;int&gt;(0, value + brightness * 255 / 100, 255);
  }
  int changeContrast( int value, int contrast ) {
      return qBound&lt;int&gt;(0, int(( value - 127 ) * contrast / 100 ) + 127, 255 );
  }
  int changeGamma( int value, int gamma ) {
      return qBound&lt;int&gt;(0, int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 255 );
  }
  </code></pre>
  
  <p>Although this code will add the effect of brightness/conrast/gamma change, it does not look very well. Professional imaging software, like Photoshop does it much better.</p>
  
  <p>What is the best library to deal with this kind of stuff? I know there is ImageMagick, but it's really heavy, I dont want to link to only one feature of hundreds. Are there any lightweight alternatives?</p>