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 3599238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:20:35+00:00 2026-05-18T20:20:35+00:00

I am using UIImagePickerController to take photos on iPhone. I’d like to adjust the

  • 0

I am using UIImagePickerController to take photos on iPhone. I’d like to adjust the photo on the fly, it appears that I could use UIImagePickerController to adjust the shape of the photo on the fly, but I am not able to find a way to change the color on the fly. For example, change all the color to black/white.

Thanks.

  • 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-05-18T20:20:36+00:00Added an answer on May 18, 2026 at 8:20 pm

    The best way to do this is with an AVCaptureSession object. I’m doing exactly what you’re talking about in my free app “Live Effects Cam”

    There are several code examples on-line that a will help you implement this too. Here is a sample chunk of code that might help:

    - (void) activateCameraFeed
        {
        videoSettings = nil;
    
    #if USE_32BGRA
        pixelFormatCode = [[NSNumber alloc] initWithUnsignedInt:(unsigned int)kCVPixelFormatType_32BGRA];
        pixelFormatKey = [[NSString alloc] initWithString:(NSString *)kCVPixelBufferPixelFormatTypeKey];
        videoSettings = [[NSDictionary alloc] initWithObjectsAndKeys:pixelFormatCode, pixelFormatKey, nil]; 
    #endif
    
        videoDataOutputQueue = dispatch_queue_create("com.jellyfilledstudios.ImageCaptureQueue", NULL);
    
        captureVideoOutput = [[AVCaptureVideoDataOutput alloc] init];
        [captureVideoOutput setAlwaysDiscardsLateVideoFrames:YES]; 
        [captureVideoOutput setSampleBufferDelegate:self queue:videoDataOutputQueue];
        [captureVideoOutput setVideoSettings:videoSettings];
        [captureVideoOutput setMinFrameDuration:kCMTimeZero];
    
        dispatch_release(videoDataOutputQueue); // AVCaptureVideoDataOutput uses dispatch_retain() & dispatch_release() so we can dispatch_release() our reference now
    
        if ( useFrontCamera )
            {
            currentCameraDeviceIndex = frontCameraDeviceIndex;
            cameraImageOrientation = UIImageOrientationLeftMirrored;
            }
        else
            {
            currentCameraDeviceIndex = backCameraDeviceIndex;
            cameraImageOrientation = UIImageOrientationRight;
            }
    
        selectedCamera = [[AVCaptureDevice devices] objectAtIndex:(NSUInteger)currentCameraDeviceIndex];
    
        captureVideoInput = [AVCaptureDeviceInput deviceInputWithDevice:selectedCamera error:nil];
    
        captureSession = [[AVCaptureSession alloc] init];
    
        [captureSession beginConfiguration];
    
        [self setCaptureConfiguration];
    
        [captureSession addInput:captureVideoInput];
        [captureSession addOutput:captureVideoOutput];
        [captureSession commitConfiguration];
        [captureSession startRunning];
        }
    
    
    // AVCaptureVideoDataOutputSampleBufferDelegate
    // AVCaptureAudioDataOutputSampleBufferDelegate
    //
    - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 
        {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
        if ( captureOutput==captureVideoOutput )
            {
            [self performImageCaptureFrom:sampleBuffer fromConnection:connection];
            }
    
        [pool drain];
        } 
    
    
    
    - (void) performImageCaptureFrom:(CMSampleBufferRef)sampleBuffer
        {
        CVImageBufferRef imageBuffer;
    
        if ( CMSampleBufferGetNumSamples(sampleBuffer) != 1 )
            return;
        if ( !CMSampleBufferIsValid(sampleBuffer) )
            return;
        if ( !CMSampleBufferDataIsReady(sampleBuffer) )
            return;
    
        imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); 
    
        if ( CVPixelBufferGetPixelFormatType(imageBuffer) != kCVPixelFormatType_32BGRA )
            return;
    
        CVPixelBufferLockBaseAddress(imageBuffer,0); 
    
        uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer); 
        size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); 
        size_t width = CVPixelBufferGetWidth(imageBuffer); 
        size_t height = CVPixelBufferGetHeight(imageBuffer);
        int bufferSize = bytesPerRow * height;
    
        uint8_t *tempAddress = malloc( bufferSize );
        memcpy( tempAddress, baseAddress, bytesPerRow * height );
    
        baseAddress = tempAddress;
    
        //
        // Apply affects to the pixels stored in (uint32_t *)baseAddress
        //
        //
        // example: grayScale( (uint32_t *)baseAddress, width, height );
        // example: sepia( (uint32_t *)baseAddress, width, height );
        //
    
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
        CGContextRef newContext = nil;
    
        if ( cameraDeviceSetting != CameraDeviceSetting640x480 )        // not an iPhone4 or iTouch 5th gen
            newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace,  kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
        else
            newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
    
        CGImageRef newImage = CGBitmapContextCreateImage( newContext );
        CGColorSpaceRelease( colorSpace );
        CGContextRelease( newContext );
    
        free( tempAddress );
    
        CVPixelBufferUnlockBaseAddress(imageBuffer,0);
    
        if ( newImage == nil )
            {
            return;
            }
    
        // To be able to display the CGImageRef newImage in your UI you will need to do it like this
        // because you are running on a different thread here…
        //
        [self performSelectorOnMainThread:@selector(newCameraImageNotification:) withObject:(id)newImage waitUntilDone:YES];
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using UIImagePickerController to take photos on iPhone. I'd like to adjust the
I’m using UIImagePickerController to take photos through my app. If I use the default
In my iPhone app, I use UIImagePickerController to allow the users to take photos
I am using a UIImagePickerController subclass to take photos in my app. The toolbar
I am using UIImagePickerController to take a photo from the camera. However, the I
I'm using the UIImagePickerController to take a photo and then upload the photo to
I'm using UIImagePickerController to let my user take a photo or choose a photo
I am writing an application that records video on an iPhone using the UIImagePickerController
In my iPhone application, I've noticed that when using the UIImagePickerController it typically causes
I am using UIImagePickerController to load saved photo from iphone library. but when I

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.