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 02-19-2009, 08:03 PM   #26 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 89
TOMSOFT is on a distinguished road
Default

Just an update - for some reason the afastrunner's code works fine on the simulator but not on the actual device (the image is still coming through blue). Anyone had a similar experience when messing around with pixel data?
TOMSOFT is offline   Reply With Quote
Old 01-19-2010, 11:45 AM   #27 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: Linslade, UK
Posts: 29
ng93 is on a distinguished road
Default

how would i get the image RGB values into a NSString?

i've tried:
Code:
for (int index = 0; index < length; index += 4) {
    NSString *string = [[NSString alloc] initWithString:[NSString stringWithFormat:@"RGB: %d, %d, %d",m_PixelBuf[index+1],m_PixelBuf[index+2],m_PixelBuf[index+3]]];
    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];   
}
but it just says 255 for every value

cheers for any help
ng93
ng93 is offline   Reply With Quote
Old 02-05-2010, 09:07 AM   #28 (permalink)
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default

ng93, your code only will get the RGB values of last pixel of the image.
And I dont recommend putting the Alloc inside a loop. That just gonna eat up your memory.
rocotilos is offline   Reply With Quote
Old 02-16-2010, 12:14 AM   #29 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 6
LaMarmotte is on a distinguished road
Default

Quote:
Originally Posted by TOMSOFT View Post
Just an update - for some reason the afastrunner's code works fine on the simulator but not on the actual device (the image is still coming through blue). Anyone had a similar experience when messing around with pixel data?
I am encountering the same issue, Did you manage to fix it?

Thanks
LaMarmotte is offline   Reply With Quote
Old 06-02-2010, 06:46 PM   #30 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 1
markyD is on a distinguished road
Default

Quote:
Originally Posted by LaMarmotte View Post
I am encountering the same issue, Did you manage to fix it?

Thanks
Sorry for bring up an old issue but there are probably others that search these forums also.

The error is in the call to CGBitmapContextCreate(), the last argument should be the bitmap-info and not the alpha-info.
Just replace that line with:
Code:
	ctx = CGBitmapContextCreate(m_PixelBuf,  
				CGImageGetWidth( inImage ),  
				CGImageGetHeight( inImage ),  
				CGImageGetBitsPerComponent(inImage),
				CGImageGetBytesPerRow( inImage ),  
				CGImageGetColorSpace( inImage ),  
				CGImageGetBitmapInfo(inImage) );
--Mark
markyD is offline   Reply With Quote
Old 06-03-2010, 12:18 AM   #31 (permalink)
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default

SPAMBOT DETECTED.

ADMIN, BRING THE RAIN!

(i always wanted to say that lol)
rocotilos is offline   Reply With Quote
Old 08-18-2010, 07:10 AM   #32 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 1
abolfoooud2 is on a distinguished road
Default

Hi

this is my first post here

have looked at this code and tried and it all works fine. But there is something that i dont understand and i hope you can explain it:

Why do i need to create a new bitmap context with CGBitmapContextCreate? Shouldn't creating a new UIImage with imageWithCGImage and the CGImageRef already created and manipulated at the beginning be sufficient? Why to duplicate the image and memory?


if i try the following i get a crash

Code:
        UIImage* img = [UIImage imageNamed:@"img.jpg"];	
        CGImageRef image = [img CGImage];
	CFDataRef dat = CGDataProviderCopyData(CGImageGetDataProvider(image));
	UInt8* data = (UInt8*)CFDataGetBytePtr(dat);
	
	for(int i=0; i<img.size.width*img.size.height*4; i+=4 )
	{
		data[i] = 255;
		data[i+1] = 255;
		data[i+2] = 0;
		data[i+3] = 0;
	}

        // removed the CGBitmapContextCreate code

	UIImage* rawImage = [UIImage imageWithCGImage:image]; 
	UIImageView *imgv = [[UIImageView alloc] initWithImage:rawImage];
Hope you can enlighten me
regs
AF

Last edited by abolfoooud2; 08-18-2010 at 07:18 AM.
abolfoooud2 is offline   Reply With Quote
Old 06-16-2011, 12:36 PM   #33 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 1
wensi is on a distinguished road
Default

Quote:
Originally Posted by TOMSOFT View Post
Thanks afastrunner for providing the code. Its been really helpful.

If I comment out all your filter effects within your code and run the app the image comes out blue. Why is that? How do I recreate the original image without applying any effect (just so I know how the code works before I apply custom effects).

Thanks in advance.
you need something like this (last argument is kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big):

Code:
ctx = CGBitmapContextCreate(m_PixelBuf,  
                                CGImageGetWidth( inImage ),  
                                CGImageGetHeight( inImage ),  
                                8,  
                                CGImageGetBytesPerRow( inImage ),  
                                CGImageGetColorSpace( inImage ),  
                                kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );
wensi is offline   Reply With Quote
Old 06-16-2011, 01:03 PM   #34 (permalink)
Registered Member
 
Join Date: Dec 2010
Location: Paris, France
Posts: 946
7twenty7 is on a distinguished road
Default

Quote:
Originally Posted by wensi View Post
you need something like this (last argument is kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big):
Way to reply to a post that was almost 2.5 years old. I'm sure he appreciates your input.
7twenty7 is offline   Reply With Quote
Old 12-07-2011, 05:41 PM   #35 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 112
RoryHarvey is on a distinguished road
Default

Quote:
Originally Posted by 7twenty7 View Post
Way to reply to a post that was almost 2.5 years old. I'm sure he appreciates your input.
Well I appreciated his input, seeing as this thread is indexed by something called 'Google'...

Anyway, the way to stop it coming out as blue is like so:

Code:
ctx = CGBitmapContextCreate(m_PixelBuf, 
                                CGImageGetWidth( inImage ), 
                                CGImageGetHeight( inImage ), 
                                8, 
                                CGImageGetBytesPerRow( inImage ), 
                                CGImageGetColorSpace( inImage ), 
                                kCGImageAlphaPremultipliedLast );
RoryHarvey is offline   Reply With Quote
Old 12-10-2011, 10:18 AM   #36 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 112
RoryHarvey is on a distinguished road
Default

Quote:
Originally Posted by yvmkpqzl43 View Post
Thanks for the quick answer. I've tried, but CoreGraphics is not present in my system?! I can see CoreAudio, Data, Foundation, Midi, Services, Video, but not Graphics?! How can that be???
You need to include

Code:
#include <ApplicationServices/ApplicationServices.h>

Last edited by baja_yu; 12-10-2011 at 11:12 AM.
RoryHarvey is offline   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: 339
8 members and 331 guests
chiataytuday, givensur, ipodphone, jbro, mtl_tech_guy, Punkjumper, vilisei, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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