Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:48:02+00:00 2026-06-08T12:48:02+00:00

I have a UISlider which increases the brightness of a UIImage as its value

  • 0

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.

The code is below

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<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);}

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 .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:48:04+00:00Added an answer on June 8, 2026 at 12:48 pm

    You’re destructively setting the values of the pixels in your image. You are taking the input image, changing the pixel brightness and then using that output as your new input the next time around. Once you have brightened it up, you can’t get that information back again when you slide it down.

    You need to keep the original image as the source and apply the changes to a copy of that image and then display that copy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UISlider that I want to update a UITextField for the value
I have a customized UISlider which has its track image disappear sometimes. It happens
I have a custom UITableViewCell that contains a UISlider control and a UILabel which
For example, I have a UISlider that calls - (IBAction)sliderMoved:(id)sender , which performs some
i have IBOutlet uislider. i want it to show the value of slider when
I want to use a vertical UISlider . I have no idea about how,
I have set my UISlider up to respond to value changed events: [customSlider addTarget:self
I have 4 UITextFields that I'm dynamically creating, in the viewDidLoad, which works good.
I am using the jQuery UISlider. I have it set up so that upon
I have two sliders in my view and I want to get both value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.