title: Issue of changing the UIImage back to the original image using UISlider
body: <p>I have a UISlider which increases the brightness of a UIImage as its value increases. But when I want to reduce the brightness and bring back the UISlider to the value that holds the original image, The brightness of the image does not reduce and it remains the same as it was on the last value of the UISlider.</p>
  
  <p>The code is below</p>
  
  <pre><code>Slider1 = [[UISlider alloc]initWithFrame:CGRectMake(100, 350, 100, 100)];
  [Slider1 addTarget:self action:@selector(Slider1Action:) forControlEvents:UIControlEventValueChanged];
  Slider1.minimumValue = 0.0;
  //slider.maximumValue = 50.0;
  Slider1.continuous = YES;
  [self.view addSubview:Slider1];
  
  -(void)Slider1Action:(id)sender{
  CGImageRef inImage = imageCollage.image.CGImage;
  CFDataRef ref = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); 
  UInt8 * buf = (UInt8 *) CFDataGetBytePtr(ref); 
  int length = CFDataGetLength(ref);
  
  float value2 =  (1+Slider1.value);
  
  for(int i=0; i&lt;length; i+=4)
  {
      int r = i;
      int g = i+1;
      int b = i+2;
  
      int red = buf[r];
      int green = buf[g];
      int blue = buf[b];
  
  
      buf[r] = SAFECOLOR(red*value2);
      buf[g] = SAFECOLOR(green*value2);
      buf[b] = SAFECOLOR(blue*value2);
  
  }
  
  CGContextRef ctx = CGBitmapContextCreate(buf,
                                           CGImageGetWidth(inImage), 
                                           CGImageGetHeight(inImage), 
                                           CGImageGetBitsPerComponent(inImage),
                                           CGImageGetBytesPerRow(inImage), 
                                           CGImageGetColorSpace(inImage),
                                           CGImageGetAlphaInfo(inImage));
  
  CGImageRef img = CGBitmapContextCreateImage(ctx);
  
  [imageCollage setImage:[UIImage imageWithCGImage:img]];
  CFRelease(ref);
  CGContextRelease(ctx);
  CGImageRelease(img);}
  </code></pre>
  
  <p>How can I reduce the brightness of the UIImage with the UISlider so that I can get the original image back again ?
  Your help is much appreciated.
  P.S.- I do not want to use Apple's OpenGL for this . </p>