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

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2010, 09:34 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 29
cowgod2007 is on a distinguished road
Default Editing an image?

Hey guys!
So right now I'm making an app that takes the data of pixels (like rgb values) and I want to modify these values to smoothen out the image. I already have the getting the values done, now I just need to set them. How would I go about changing the rgb values on pixels in an image?

Thanks in advance!
cowgod2007 is offline   Reply With Quote
Old 08-16-2010, 09:11 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 29
cowgod2007 is on a distinguished road
Default

bump! can anyone help at all?
cowgod2007 is offline   Reply With Quote
Old 08-16-2010, 12:20 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 29
cowgod2007 is on a distinguished road
Default

So I found out how to create a totally new CGImage and then add the pixel data into that. This is what I have so far:

Code:
for (int index = 0; index < length; index += 4)  
	{  
		
		/*m_PixelBuf[index + 1] = 255 - m_PixelBuf[index + 1];  
		m_PixelBuf[index + 2] = 255 - m_PixelBuf[index + 2];  
		m_PixelBuf[index + 3] =    255 - m_PixelBuf[index + 3]; 
		*/
		
		m_PixelBuf[index + 1] = red2;  
		 m_PixelBuf[index + 2] = green2;  
		 m_PixelBuf[index + 3] = blue2;      
		 
		
		//NSLog(@"lol");
		
	}  
	
	//index+=4;
	ctx = CGBitmapContextCreate(m_PixelBuf,  
								CGImageGetWidth( inImage ),  
								CGImageGetHeight( inImage ),  
								CGImageGetBitsPerComponent(inImage),
								CGImageGetBytesPerRow( inImage ),  
								CGImageGetColorSpace( inImage ),  
								CGImageGetBitmapInfo(inImage) );	
	
	
	CGImageRef imageRef = CGBitmapContextCreateImage (ctx);  
	UIImage* rawImage = [UIImage imageWithCGImage:imageRef];  
	
	theimageView.image = rawImage;
	CGContextRelease(ctx);
The code keeps on crashing without giving me an error and I can't find out why. Is it due to formats? My red2, green2, and blue2 are all unsigned int's and my m_PixelBuf is a UInt8 pointer. Here is the code where I initialized everything:

Code:
	CGImageRef inImage = mycgImage;          
		CGContextRef ctx;  
		
		
		CFDataRef m_DataRef;  
		m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));  
		UInt8 *m_PixelBuf = (UInt8 *) CFDataGetBytePtr(m_DataRef);  
		//    Byte tmpByte;  
		int length = CFDataGetLength(m_DataRef);
cowgod2007 is offline   Reply With Quote
Reply

Bookmarks

Tags
editing, images, rgb, set

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: 352
4 members and 348 guests
givensur, linkmx, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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