Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 01-08-2012, 08:37 AM   #1 (permalink)
Velvet Rock Apps
 
Join Date: Sep 2010
Posts: 231
ChrisYates is on a distinguished road
Default Converting to B&W and then back to colour?

I'm thinking that this is probably not possible but let's say the user converts a photo to B&W by tapping a button, is it possible to undo that action and make it colour again!?

Here's the code I'm using for B&W conversion:

Code:
UIImage *originalImage = photo1Holder.image; // this image we get from UIImagePickerController
    
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
    CGContextRef context = CGBitmapContextCreate(nil, originalImage.size.width, originalImage.size.height, 8, originalImage.size.width, colorSpace, kCGImageAlphaNone);
    CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    CGContextSetShouldAntialias(context, NO);
    CGContextDrawImage(context, CGRectMake(0, 0, originalImage.size.width, originalImage.size.height), [originalImage CGImage]);
    
    CGImageRef bwImage = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CGColorSpaceRelease(colorSpace);
    
    photo1Holder.image = [UIImage imageWithCGImage:bwImage]; // This is result B/W image.
    CGImageRelease(bwImage);
__________________
Screen Pimp - iPhone
LightsOut! - iPad
LightsOut Pocket - iPhone
Postage UK HD - iPad
Halves HD - iPad
ChrisYates is offline   Reply With Quote
Old 01-08-2012, 07:37 PM   #2 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Why not just make originalImage a property in your .h file? Then you can just revert back with
Code:
photo1Holder.image = self.originalImage;
But without saving the originalImage, I don't think it's possible.
architectpianist is offline   Reply With Quote
Old 01-09-2012, 06:24 AM   #3 (permalink)
Velvet Rock Apps
 
Join Date: Sep 2010
Posts: 231
ChrisYates is on a distinguished road
Default

The problem I'm having is the user picks the image from their photo library.
__________________
Screen Pimp - iPhone
LightsOut! - iPad
LightsOut Pocket - iPhone
Postage UK HD - iPad
Halves HD - iPad
ChrisYates is offline   Reply With Quote
Old 01-09-2012, 10:24 PM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,002
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by ChrisYates View Post
The problem I'm having is the user picks the image from their photo library.
So make a copy of the original before doing the B&W conversion. Then if they decide to revert, go back to the original.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
13 members and 386 guests
bignoggins, BSH, djqbert, Duncan C, epaga, flamingliquid, jbro, jcdevelopments, leighec68, markolo, nobstudio, revg, taylor202
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0